You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
991 B
Lua

local cmp = require('cmp')
cmp.setup({
completion = {
keyword_length = 1, -- TODO set this back 3, when fine with snippets
},
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<cr>'] = cmp.mapping.confirm({ select = true }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{
name = 'buffer',
option = {
get_bufnrs = function()
return vim.api.nvim_list_bufs()
end
},
},
{ name = 'path' },
{ name = 'tmux', option = { all_panes = true } }, -- TODO 'true' makes things sloppy
{ name = 'calc' },
}),
formatting = {
format = function(entry, vim_item)
vim_item.menu = ({
buffer = "[Buffer]",
calc = "[Calc]",
nvim_lsp = "[LSP]",
path = "[Path]",
tmux = "[tmux]",
vsnip = "[Snippet]",
})[entry.source.name]
return vim_item
end
},
})