nvim: update completion keybinds to be less sucky

This commit is contained in:
azathoth 2024-07-07 13:26:40 -04:00
parent 394332cd72
commit 785fa9a80b
1 changed files with 22 additions and 2 deletions

View File

@ -46,8 +46,28 @@ return {
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(4),
['<C-f>'] = cmp.mapping.scroll_docs(-4),
['<Esc>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<Esc>'] = cmp.mapping({
i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.abort()
else
fallback()
end
end,
s = cmp.mapping.abort(),
c = cmp.mapping.abort()
}),
['<CR>'] = cmp.mapping({
i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
else
fallback()
end
end,
s = cmp.mapping.confirm({ select = true }),
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })
}),
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then cmp.select_next_item()
elseif luasnip.expandable() then luasnip.expand()