nvim-cmp icon indicating copy to clipboard operation
nvim-cmp copied to clipboard

default mappings for cmdline <C-n> and <C-p> can be obstrusive

Open perrin4869 opened this issue 2 years ago • 4 comments

I added the mapping shown in the README below:

  cmp.setup.cmdline(':', {
    mapping = cmp.mapping.preset.cmdline(),
    sources = cmp.config.sources({
      { name = 'path' }
    }, {
      { name = 'cmdline' }
    })
  })

I ran into a problem when hitting <C-p> to select previous commands. As soon as I run into a command that triggers cmp to open the menu, preset.cmdline <C-p> mapping takes effect, and prevents me from scrolling onto previous commands. Instead, I scroll the different available completion items. I don't know if this is an actionable issue, or what a solution to it might look like, but I found the default behavior to be somewhat unintuitive, so I thought I'd report it here.

perrin4869 avatar Aug 15 '23 15:08 perrin4869

This works for me

cmp.setup.cmdline(':', {
  mapping = cmp.mapping.preset.cmdline {
    ['<C-n>'] = cmp.config.disable,
    ['<C-p>'] = cmp.config.disable,
  },
  sources = cmp.config.sources({
    { name = 'path' }
  }, {
    { name = 'cmdline' }
  })
})

v1nh1shungry avatar Aug 28 '23 09:08 v1nh1shungry

Right, I'm wondering if something like that should be the default?

perrin4869 avatar Aug 28 '23 09:08 perrin4869

You can also always abort the current completion using <C-e> and then <C-n/p> should do command history completion again.

camoz avatar May 25 '24 08:05 camoz

Since neovim's wildmenu by default also uses <C-n> and <C-p> for navigating the completion (when wildmenu is currently active), I think nvim-cmp's defaults are fine and this issue can be closed.

camoz avatar May 25 '24 08:05 camoz