2021-10-05 20:19:30 +00:00
|
|
|
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]",
|
|
|
|
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,
|
2021-10-05 20:19:30 +00:00
|
|
|
-- autocomplete = false
|
|
|
|
},
|
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
vim.fn["UltiSnips#Anon"](args.body)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
mapping = {
|
|
|
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
|
|
|
['<C-u>'] = cmp.mapping.scroll_docs(4),
|
2021-12-13 15:16:24 +00:00
|
|
|
["<C-n>"] = cmp.mapping({
|
|
|
|
i = function()
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
|
|
|
|
else
|
|
|
|
cmp.complete()
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
}),
|
2021-10-05 20:19:30 +00:00
|
|
|
},
|
|
|
|
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,
|
2021-10-05 20:19:30 +00:00
|
|
|
},
|
|
|
|
{ name = 'path' },
|
|
|
|
{
|
|
|
|
name = 'buffer',
|
2021-10-22 20:20:37 +00:00
|
|
|
keyword_length = 4,
|
2021-10-05 20:19:30 +00:00
|
|
|
max_item_count = 20,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = 'ultisnips',
|
|
|
|
priority_weight = 10,
|
2021-10-22 20:20:37 +00:00
|
|
|
keyword_length = 1,
|
2021-10-05 20:19:30 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
})
|