From 1e427911ac0abd86aed9e4c12a9c0d87d81f9398 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Thu, 21 Nov 2024 21:21:28 -0500 Subject: [PATCH] feat: Updates nvim-cmp --- nvim/m-housh/lua/user/plugin/cmp.lua | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/nvim/m-housh/lua/user/plugin/cmp.lua b/nvim/m-housh/lua/user/plugin/cmp.lua index b5e7c5a..0785230 100755 --- a/nvim/m-housh/lua/user/plugin/cmp.lua +++ b/nvim/m-housh/lua/user/plugin/cmp.lua @@ -32,19 +32,26 @@ return { mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.select_prev_item(), -- previous suggestion [""] = cmp.mapping.select_next_item(), -- next suggestion - [""] = cmp.mapping.complete(), -- show completion suggestions + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }), -- select completion, this makes it so it doesn't auto complete when suggesting. [""] = cmp.mapping.abort(), -- close completion window - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - if luasnip.expandable() then - luasnip.expand() + [""] = cmp.mapping({ + i = function(fallback) + if cmp.visible() then + if luasnip.expandable() then + luasnip.expand() + else + cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }) + end else - cmp.confirm({ select = true }) + fallback() end - else - fallback() - end - end), + end, + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), + }), -- TODO: -- The next two mappings are also implemented in the LuaSnip configuration, -- as and do they actually need to be here??