0

I just realized that vim's completion list could be a bit nicer to use if it mimicked the vertical-style command-line completion menu (wildoptions=pum), which gives some scrolloff.

This lets the user see what's coming next, which can prevent some overshooting.

Is there any way to do this? It seems rather unpleasant to implement in vimscript.

1 Answer 1

0

As a workaround, one can use these mappings:

inoremap <c-n> <c-n><c-n><c-n><c-p><c-p>
inoremap <c-p> <c-p><c-p><c-p><c-n><c-n>

They will move the selection further than needed and come back to the correct spot, seemingly scrolling the list before reaching its limits.

Luckily enough, this does not break when wrapping.

One drawback though. If one holds <c-n>, the selection update is far from instantaneous.

For coc users, here's an equivalent:

inoremap <silent> <expr> <c-j> coc#pum#visible()
      \ ? coc#pum#next(1) .. coc#pum#next(1) .. coc#pum#next(1) .. coc#pum#prev(1) .. coc#pum#prev(1) : coc#refresh()

inoremap <silent> <expr> <c-k> coc#pum#visible()
    \ ? coc#pum#prev(1) .. coc#pum#prev(1) .. coc#pum#prev(1) .. coc#pum#next(1) .. coc#pum#next(1) : coc#refresh()

It suffers the same drawback, only worst.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.