From fef00508a3934ce0defaf332491a2fc918a2cc16 Mon Sep 17 00:00:00 2001 From: nat Date: Thu, 27 Mar 2025 18:24:06 -0700 Subject: [PATCH] fix issue with completions being autoselected by prior to tab being pressed --- lua/plugins/nvim-cmp.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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 },