6

I'm using lspkind and nvim-cmp with Neovim 0.7.

When <C-n> or <C-p> is pressed to scroll through the items from the list of possible completions it gets completely overwritten by the standard completion suggestions. See link for an example.

Why does it change from lspkind suggestions to basic completion? Why do I get --keyword completion (^N^P) back to original?

Sixten
  • 318
  • 3
  • 8
ttyago
  • 63
  • 1
  • 4

1 Answers1

10

I had the same issue. I solved it by adding

['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item()),
['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item()),

inside of the mapping list of the LUA config (I'm not actually sure this is a list I only use LUA for Nvim)

mapping = { ...,
['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item()),
['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item()),
...

The reason for this issue coming up in the first place is that (from the config I copied) the select_next_item/select_prev_item functions simply wasn't bound so there was nothing to overwrite the standard completion.

I found these functions in the cmp documentation.

Sixten
  • 318
  • 3
  • 8
  • 1
    thanks it works like a charm! I think that I've overwrite that mappings during some plugin development! – ttyago Apr 19 '22 at 14:34
  • 2
    Thank you for the solution -- this was driving me crazy! I'm not sure what changed because I did not run into this problem previously. – Trevor Manz Apr 28 '22 at 16:53