Closed eduardoarandah closed 1 year ago
Found it on cmp readme.
Here's the answer, for posterity.
You need to add mappings for cmdline mode as well. https://github.com/hrsh7th/nvim-cmp/issues/231#issuecomment-1098175017
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
},
mapping = cmp.mapping.preset.cmdline({
['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item()),
['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item()),
['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item()),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
})
})
Here's the answer, for posterity.
Thanks for this. I'm looking for a solution along just these lines. However, I was unable to adapt the above to the commands
-- cmp-cmdline
-- `/` cmdline setup.
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline({
['<C-j>'] = cmp.mapping(cmp.mapping.select_next_item()),
['<C-k>'] = cmp.mapping(cmp.mapping.select_prev_item()),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
}),
sources = {
{ name = 'buffer' }
}
})
-- `:` cmdline setup.
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline({
['<C-j>'] = cmp.mapping(cmp.mapping.select_next_item()),
['<C-k>'] = cmp.mapping(cmp.mapping.select_prev_item()),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
}),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline',
option = {
ignore_cmds = { 'Man', '!' }
}
},
mapping = cmp.mapping.preset.cmdline({}), -- fixes supertab
}),
})
Any help would be greatly appreciated!
How is this marked as closed?
Let's say I want to run
PackerCompile
I type
pco
and get this results:How to navigate up and down?
tried key up /down and C-n C-p but it doesn't work