1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:30:04 +08:00
SpaceVim/bundle/cmp-buffer
2022-01-01 22:13:13 +08:00
..
after/plugin feat(autocomplete): add nvim-cmp support 2022-01-01 22:13:13 +08:00
lua/cmp_buffer feat(autocomplete): add nvim-cmp support 2022-01-01 22:13:13 +08:00
LICENSE feat(autocomplete): add nvim-cmp support 2022-01-01 22:13:13 +08:00
README.md feat(autocomplete): add nvim-cmp support 2022-01-01 22:13:13 +08:00

cmp-buffer

nvim-cmp source for buffer words.

Setup

require'cmp'.setup {
  sources = {
    { name = 'buffer' }
  }
}

Configuration

The below source configuration are available.

keyword_length (type: number)

Default: 3

Specify word length to gather.

keyword_pattern (type: string)

Default: [[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%([\-.]\w*\)*\)]]

A vim's regular expression for creating a word list from buffer content.

You can set this to \k\+ if you want to use the iskeyword option for recognizing words.

get_bufnrs (type: fun(): number[])

Default: function() return { vim.api.nvim_get_current_buf() } end

A function that specifies the buffer numbers to complete.

You can use the following pre-defined recipes.

All buffers
get_bufnrs = function()
  return vim.api.nvim_list_bufs()
end
Visible buffers
get_bufnrs = function()
  local bufs = {}
  for _, win in ipairs(vim.api.nvim_list_wins()) do
    bufs[vim.api.nvim_win_get_buf(win)] = true
  end
  return vim.tbl_keys(bufs)
end