2022-10-05 19:29:01 +00:00
|
|
|
local cmp = require 'cmp'
|
2022-10-07 14:08:14 +00:00
|
|
|
|
2021-10-05 20:19:30 +00:00
|
|
|
cmp.setup({
|
2022-10-05 19:29:01 +00:00
|
|
|
window = {documentation = cmp.config.window.bordered({border = "single"})},
|
|
|
|
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 = {
|
|
|
|
keyword_length = 1,
|
|
|
|
max_item_count = 20
|
|
|
|
-- autocomplete = false
|
|
|
|
},
|
|
|
|
snippet = {expand = function(args) vim.fn["UltiSnips#Anon"](args.body) end},
|
|
|
|
mapping = {
|
2022-10-07 14:08:14 +00:00
|
|
|
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
|
|
|
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
2022-10-05 19:29:01 +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
|
|
|
|
})
|
|
|
|
},
|
|
|
|
sources = {
|
|
|
|
{name = 'nvim_lsp', max_item_count = 8, keyword_length = 3},
|
|
|
|
{name = 'path'},
|
|
|
|
{name = 'buffer', keyword_length = 4, max_item_count = 20},
|
|
|
|
{name = 'ultisnips', priority_weight = 10, keyword_length = 1}
|
|
|
|
}
|
2021-10-05 20:19:30 +00:00
|
|
|
})
|