0

I used to rely heavily on the default autocompletion provided by the Ctrl + n keys in the insert mode.

But when I started to use NeoVim and its LSP functionality, the keys started to provide a completely different list of suggestions. The most relevant difference is the miss of the keywords from other buffers.

What's the most easy way (if any) to get this back?

Intuitively it looks like it's too much for me to modify the behavior of LSP. Ideally it could be something like a remap of the Generic Keyword Autocompletion to different keys.

Could someone advise something on this?

2 Answers 2

1

If your LSP bridge overrides the Ctrl+n and Ctrl+p (with Coc you can configure the keys) and don't include the standard Neovim completion (Coc merges the two completions in the same menu) you could reintroduce them:

To reintroduce them as Ctrl+h Ctrl+l/kbd>:

inoremap <C-h> <C-n>
inoremap <C-l> <C-p>
6
  • Actually I removed Coc. Should I use it, if I use LSP?
    – d.k
    Commented May 28 at 20:15
  • Coc is an LSP bridge. When you says you are using LSP I suppose it means that you are using the built-in Neovim LSP bridge and probably some plugins that configure it for the languages you use. Ther is no reason to have two bridges, better to choose one or the other. I'm using coc that merge the completion (I should check if the builtin LSP bridge do the same but I suppose not otherwise you would not have your question :-) I'll test tomorrow) Commented May 28 at 20:21
  • Would you mind if I ask one more question? Is there an LSP server for JS? I couldn't find one, have to use TypeScript server. That's what led me to a conclusion, that Coc and LSP are completely different things. Does it mean that Coc also uses TypeScript server?
    – d.k
    Commented May 28 at 20:28
  • 1
    I don’t recommend remapping c-j, which may cause issues with enter (C-m definitely does)
    – D. Ben Knoble
    Commented May 28 at 22:01
  • 1
    @d.k I confirm that the coc.nvim bridge merge the completion suggestions and that at least by default the Neovim builtin LSP bridge does not merge the suggestions. Commented May 29 at 3:53
0

One possible solution, which seem to work is to remap the original Ctrl + n to another key sequence.

I remapped it to Ctrl + J

inoremap <C-j> <C-n>

It seems to preserve the original behavior of the so called Generic Keyword Autocompletion, yet the LSP functionality remains in place.

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.