Configure nvim-cmp for s and c mode

This commit is contained in:
2021-11-19 17:37:42 +01:00
parent e142a3ec5b
commit f4631cbaa2
3 changed files with 27 additions and 14 deletions

View File

@@ -34,15 +34,16 @@ cmp.setup {
end
},
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c', 's'}),
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c', 's' }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c', 's' }),
['<C-e>'] = cmp.mapping(cmp.mapping.close(), { 'i', 'c', 's' }),
['<CR>'] = cmp.mapping({
i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }),
c = cmp.mapping.confirm({ select = false }),
s = cmp.mapping.confirm({ select = false }),
}),
["<Tab>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then
@@ -76,9 +77,26 @@ cmp.setup {
{name = 'cmp_tabnine'}, {name = "calc"}, {name = "spell"},
{name = "emoji"}
},
completion = {completeopt = 'menu,menuone,noinsert'}
completion = {completeopt = 'menu,menuone,noinsert, noselect'},
-- experimental = { native_menu = true }
}
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' }
},
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
}),
})
-- Autopairs
--require("nvim-autopairs.completion.cmp").setup({
-- map_cr = true,