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

disable completion for specific cmdline commands. eg: Man

Open cevhyruz opened this issue 2 years ago • 10 comments

cevhyruz avatar Apr 15 '22 10:04 cevhyruz

Why the feature is needed?

Shougo avatar Apr 15 '22 10:04 Shougo

@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?

cevhyruz avatar Apr 15 '22 10:04 cevhyruz

Hm.. You can use keyword_pattern for it.

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

Shougo avatar Apr 15 '22 10:04 Shougo

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

cevhyruz avatar Apr 15 '22 10:04 cevhyruz

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]]},
  }
})

Shougo avatar Apr 15 '22 10:04 Shougo

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

hiberabyss avatar Aug 12 '22 02:08 hiberabyss

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

Shougo avatar Aug 12 '22 09:08 Shougo

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.

hiberabyss avatar Aug 12 '22 09:08 hiberabyss

Hm.

                                          *cmp-config.sources[n].max_item_count*
sources[n].max_item_count~
  `number`
  The source-specific item count.

Shougo avatar Aug 12 '22 10:08 Shougo

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

hiberabyss avatar Aug 12 '22 11:08 hiberabyss

Fixed. You can modify ignore_cmds option.

hrsh7th avatar Nov 13 '22 04:11 hrsh7th

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

sidesteps avatar Apr 14 '23 15:04 sidesteps