hrsh7th / cmp-cmdline

nvim-cmp source for vim's cmdline
MIT License
550 stars 42 forks source link

disable completion for specific cmdline commands. eg: Man #47

Closed cevhyruz closed 1 year ago

Shougo commented 2 years ago

Why the feature is needed?

cevhyruz commented 2 years ago

@Shougo I currently enabled cmdline completion using this snippet from README.

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

However neovim is choking when completing commands like :Man I figured this is because Man command usually returns a very long list. Is there anyway to disable cmdline completion say for example only on the Man command?

Shougo commented 2 years ago

Hm.. You can use keyword_pattern for it.

https://github.com/hrsh7th/nvim-cmp/issues/821#issuecomment-1056160923

cevhyruz commented 2 years ago

I'm not quite familiar with regular expression, could you give a sample.

Shougo commented 2 years ago

I think it should work.

cmp.setup.cmdline(':', {
  sources = {
    {name = 'path'},
    -- Do not show completion for words starting with 'Man'
    {name = 'cmdline', keyword_pattern = [[^\@<!Man\s]]},
  }
})
hiberabyss commented 2 years ago

Meet same problem here. Could it possible to specify separate keyword length for the command to reduce the completion list size?

Shougo commented 2 years ago

:help cmp-config.completion.keyword_length help cmp-config.sources[n].keyword_length

hiberabyss commented 2 years ago

This controlled whether the completion started with the whole commandline.

What I mean here is that consider the arguments size of command, for example, Man won't complete while Man m will do complete if length set to 1.

Shougo commented 2 years ago

Hm.

                                          *cmp-config.sources[n].max_item_count*
sources[n].max_item_count~
  `number`
  The source-specific item count.
hiberabyss commented 2 years ago

Is there any way to get source conf? Thus I could add some conf to verify the command argument length.

hrsh7th commented 1 year ago

Fixed. You can modify ignore_cmds option.

sidesteps commented 1 year ago

It doesn't work. How do you use it? Perhaps document it's usage?