From 785fa9a80b107861d1d4d4eda73147cfd5d82320 Mon Sep 17 00:00:00 2001 From: azathoth Date: Sun, 7 Jul 2024 13:26:40 -0400 Subject: [PATCH] nvim: update completion keybinds to be less sucky --- .config/nvim/lua/plugins/completion.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.config/nvim/lua/plugins/completion.lua b/.config/nvim/lua/plugins/completion.lua index eea099c..e467e8a 100644 --- a/.config/nvim/lua/plugins/completion.lua +++ b/.config/nvim/lua/plugins/completion.lua @@ -46,8 +46,28 @@ return { mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ select = true }), + [''] = 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() + }), + [''] = 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 }) + }), [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expandable() then luasnip.expand()