nvim/plug/cmp: various fixes

- Pull completions from all buffers, not just current
- Limit total items to 15
- Better organization of cmd completions
This commit is contained in:
Paul Stemmet 2023-06-04 22:00:26 +00:00
parent c9d7e5ca50
commit 707f9daafe
Signed by: Paul Stemmet
GPG Key ID: EDEA539F594E7E75
1 changed files with 19 additions and 10 deletions

View File

@ -15,6 +15,10 @@ return function()
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), md or '', true)
end
local buffer_options = {
get_bufnrs = vim.api.nvim_list_bufs
}
-- Snippet provider
defaults.snippet.expand = function(args)
vim.fn['vsnip#anonymous'](args.body)
@ -62,7 +66,10 @@ return function()
{ name = 'vsnip', keyword_length = 2 },
},
{
{ name = 'buffer', keyword_length = 2 },
{ name = 'buffer',
option = buffer_options,
keyword_length = 2,
},
{ name = 'spell', max_item_count = 3, keyword_length = 3 },
}
)
@ -89,17 +96,20 @@ return function()
end,
}
-- Performance settings
defaults.performance = {
max_view_entries = 15
}
cmp.setup(util.mconfig('config.nvim-cmp', defaults))
cmp.setup.cmdline(':', {
mapping = mode.cmd(),
sources = sources(
{
{ name = 'async_path', max_item_count = 2 },
},
{
{ name = 'cmdline_history', max_item_count = 2 },
{ name = 'cmdline', max_item_count = 6 },
{ name = 'cmdline_history', max_item_count = 1 },
{ name = 'cmdline', max_item_count = 10 },
{ name = 'async_path', max_item_count = 2 },
}
)
})
@ -108,10 +118,9 @@ return function()
mapping = mode.cmd(),
sources = sources(
{
{ name = 'cmdline_history', max_item_count = 1 },
},
{
{ name = 'buffer', max_item_count = 9 },
{ name = 'cmdline_history', max_item_count = 1 },
{ name = 'cmdline', max_item_count = 10 },
{ name = 'buffer', max_item_count = 2 },
}
)
})