fix cmp, modularise lua plugin settings
This commit is contained in:
parent
e43e75b20e
commit
5bad300475
7 changed files with 223 additions and 187 deletions
55
lua/init-cmp.lua
Normal file
55
lua/init-cmp.lua
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
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 = 4,
|
||||
-- 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 = 20,
|
||||
},
|
||||
{ name = 'path' },
|
||||
{
|
||||
name = 'buffer',
|
||||
max_item_count = 20,
|
||||
},
|
||||
{
|
||||
name = 'dictionary',
|
||||
keyword_length = 4,
|
||||
max_item_count = 20,
|
||||
},
|
||||
{
|
||||
name = 'ultisnips',
|
||||
priority_weight = 10,
|
||||
keyword_length = 2,
|
||||
},
|
||||
...
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue