hrsh7th / cmp-cmdline

nvim-cmp source for vim's cmdline
MIT License
533 stars 40 forks source link

Support for magic mode #14

Open JoseConseco opened 2 years ago

JoseConseco commented 2 years ago
cmp.setup.cmdline('/', {
  sources = {
        {name = 'buffer'}
        -- { name = 'rg'}, 
        -- {name = 'fuzzy_buffer'}   
  }
})

magic search in vim simplifies regex but it confuses cmp.cmdline, eg when I search for import word: /\vimp the buffers will not show suggestions related to 'imp' but to 'vimp'. Issue is affecting other sources that are attached to cmdline sources /imp works ok though. I hope there is way to filter out the magic characters.

msva commented 2 years ago

How about this?

  cmp.setup.cmdline('/', {
    completion = { autocomplete = false },
    sources = {
      {
        name = 'buffer',
        option = {
          keyword_pattern = [=[[^\v[:blank:]].*]=],
        }
      }
    }
  })
gegoune commented 2 years ago

It seems to show the whole line for which there is a match rather than string itself.