nvim/lua/init-cmp.lua

59 lines
1.1 KiB
Lua
Raw Normal View History

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 = {
2021-10-22 20:20:37 +00:00
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',
2021-10-05 22:16:48 +00:00
max_item_count = 8,
2021-10-22 20:20:37 +00:00
keyword_length = 3,
},
{ name = 'path' },
{
name = 'buffer',
2021-10-22 20:20:37 +00:00
keyword_length = 4,
max_item_count = 20,
},
{
name = 'dictionary',
keyword_length = 4,
max_item_count = 20,
},
{
name = 'ultisnips',
priority_weight = 10,
2021-10-22 20:20:37 +00:00
keyword_length = 1,
},
...
}
})