hrsh7th / cmp-buffer

nvim-cmp source for buffer words

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any way to skip redundant completions?

ribru17 opened this issue · comments

I was wondering if there is any way to hide entries for this cmp source that have been fully typed already? For instance in the below screenshot the word available has already finished being typed, yet the autocompletion item exists for it still, meaning there are sometimes redundant <Tab> presses when I am trying to, e.g. jump to another snippet item (which I also use <Tab> for).

cmpbufferquestion

I managed to do it with the following:

['<Tab>'] = cmp.mapping(function(fallback)
  local entry = cmp.get_selected_entry()
  if
    cmp.visible()
    and not (entry.source.name == 'buffer' and entry.exact)
  then
    cmp.confirm { select = true }
  elseif luasnip.expand_or_jumpable() then
    luasnip.expand_or_jump()
  else
    fallback()
  end
end, { 'i', 's', 'c' }),