There is no "speed up the completion menu"/"make the completion menu async"/"make the completion menu use a cache" option, if that's what you are hoping for, so you basically have three options:
- write/use some custom completion function that behaves the way you want,
- or figure out what is causing those delays and see if fine tuning your
:help 'complete' value helps,
- or open an issue in Vim's issue tracker and see if it gets enough traction.
Fundamentally, the issue is the same as with the wildmenu: gathering suggestions may be one possible bottleneck but building the menu is definitely the main bottleneck.
*.c files from the Vim source with
$ vim **/*.c, I get 190 buffers, some of them infamously "large".
If I open a new line with
o and press
<C-n> without any text in the front, it takes about 25 seconds for the menu to be displayed, here (YMMV). Vim went through 190 buffers and god knows how many includes to build a very large list containing every keyword it found and then built the menu from that list.
If I do
<c-n> more responsibly, after something like
defi, the completion menu is displayed with a sub-second delay. Vim went through the exact same buffers and files as above but it built a much smaller menu from a much smaller list, much faster.
Basically, the larger the menu, the longer it takes Vim to build it, and I suspect that the progression is not even linear.
So, to sum it up…
- There is no user-facing way to change how the menu for the built-in
<C-n> is built.
- Adjusting the completion sources may help but not by much because the problem is elsewhere.
<C-n> responsibly (for completion vs exploration) helps a lot.
- Writing your own completion function that builds the menu incrementally could probably work but it doesn't sound particularly trivial. See
- Petitioning the dev team might work but submitting a patch seems to be the best, forward-thinking move. Not trivial either.