Skip to content

rasulomaroff/cmp-bufname

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmp-bufname

Buffer name completion source for nvim-cmp.

Setup

require('cmp').setup {
  sources = {
    { name = 'bufname' }
  }
}

Configuration

The following is a default configuration:

require('cmp').setup {
  sources = {
    {
      name = 'bufname',
      option = {
        -- use only current buffer for filename exractions
        current_buf_only = false,

        -- allows to configure what buffers to extract a filename from
        bufs = function()
          return vim.api.nvim_list_bufs()
        end,

        -- configure which entries you want to include in your completion:
        -- - you have to return a table of entries
        -- - empty string means skip that particular entry
        extractor = function(filename, full_path)
          return { filename:match '[^.]*'}
        end
      }
    }
  }
}