nvim/plug: improve cmdline (:) completions
This commit enables nvim-cmp's cmdline completion support, overriding the builtin neovim's. We gain a nicer menu, more sources (paths, history), and a slightly more intelligent listing with some support for file specific commands (e, r, w). We also switch out the 'path' completion source with 'async_path', preventing delays / freezes when traversing slow or large fs trees
This commit is contained in:
parent
79a7215464
commit
7c385263f1
|
@ -45,7 +45,6 @@ return function()
|
|||
['<C-Space>'] = kmap.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }),
|
||||
}
|
||||
defaults.mapping = mode.insert(defaults.mapping)
|
||||
defaults.mapping = mode.cmd(defaults.mapping)
|
||||
|
||||
-- Sources of auto completion
|
||||
--
|
||||
|
@ -53,7 +52,7 @@ return function()
|
|||
-- that is, 'path's will be shown before 'nvim_lsp's, etc
|
||||
defaults.sources = sources(
|
||||
{
|
||||
{ name = 'path', },
|
||||
{ name = 'async_path', },
|
||||
},
|
||||
{
|
||||
{ name = 'nvim_lsp', keyword_length = 2 },
|
||||
|
@ -91,4 +90,29 @@ return function()
|
|||
}
|
||||
|
||||
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 },
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
cmp.setup.cmdline({'/', '?', '@'}, {
|
||||
mapping = mode.cmd(),
|
||||
sources = sources(
|
||||
{
|
||||
{ name = 'cmdline_history', max_item_count = 1 },
|
||||
},
|
||||
{
|
||||
{ name = 'buffer', max_item_count = 9 },
|
||||
}
|
||||
)
|
||||
})
|
||||
end
|
||||
|
|
|
@ -149,8 +149,10 @@ local plugins = {
|
|||
|
||||
-- Other sources:
|
||||
{ 'hrsh7th/cmp-vsnip' },
|
||||
{ 'hrsh7th/cmp-path' },
|
||||
{ 'FelipeLema/cmp-async-path' },
|
||||
{ 'hrsh7th/cmp-buffer' },
|
||||
{ 'hrsh7th/cmp-cmdline' },
|
||||
{ 'dmitmel/cmp-cmdline-history' },
|
||||
{ 'f3fora/cmp-spell',
|
||||
after = { 'lspconfig' },
|
||||
config = require 'psoxizsh.plugins.config.cmp-spell'
|
||||
|
|
Loading…
Reference in New Issue