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()