nvim/lua/init-cmp.lua

59 lines
1.1 KiB
Lua

local cmp = require'cmp'
cmp.setup({
formatting = {
format = function(entry, vim_item)
-- set a name for each source
vim_item.menu = ({
nvim_lsp = "[LSP]",
path = "[Path]",
buffer = "[Buffer]",
dictionary = "[Dict]",
ultisnips = "[UltiSnips]",
})[entry.source.name]
return vim_item
end,
},
completion = {
keyword_length = 1,
max_item_count = 20,
-- autocomplete = false
},
snippet = {
expand = function(args)
vim.fn["UltiSnips#Anon"](args.body)
end,
},
mapping = {
['<C-n>'] = cmp.mapping.complete(),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
-- ['<C-e>'] = cmp.mapping.close(),
['<C-e>'] = cmp.mapping.abort(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-u>'] = cmp.mapping.scroll_docs(4),
},
sources = {
{
name = 'nvim_lsp',
max_item_count = 8,
keyword_length = 3,
},
{ name = 'path' },
{
name = 'buffer',
keyword_length = 4,
max_item_count = 20,
},
{
name = 'dictionary',
keyword_length = 4,
max_item_count = 20,
},
{
name = 'ultisnips',
priority_weight = 10,
keyword_length = 1,
},
...
}
})