diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua index 2eabf74..9e51c87 100644 --- a/lua/plugins/nvim-cmp.lua +++ b/lua/plugins/nvim-cmp.lua @@ -107,7 +107,17 @@ return { }, -- Accept currently selected item. If none selected, `select` first item. -- Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping.confirm { select = true }, + [""] = 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 = false }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }), + }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() @@ -157,7 +167,8 @@ return { autocomplete = { require('cmp.types').cmp.TriggerEvent.TextChanged, }, - completeopt = 'menu,menuone,noselect', + + completeopt = 'menu,menuone,noselect,noinsert,preview', keyword_pattern = ".*", keyword_length = 1, -- Set to 1 for immediate as-you-type completion },