diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index 198070908..f20e7b60d 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -127,7 +127,6 @@ return function() }, -- You can set mappings if you want mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Replace }), [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), [""] = cmp.mapping.scroll_docs(-4), @@ -151,6 +150,17 @@ return function() fallback() end end, { "i", "s" }), + [""] = cmp.mapping({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }) + else + fallback() + end + end, + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }), + }), }), snippet = { expand = function(args) diff --git a/lua/modules/configs/completion/mason-lspconfig.lua b/lua/modules/configs/completion/mason-lspconfig.lua index c345c7f78..567ff9f94 100644 --- a/lua/modules/configs/completion/mason-lspconfig.lua +++ b/lua/modules/configs/completion/mason-lspconfig.lua @@ -25,7 +25,11 @@ M.setup = function() }) local opts = { - capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), + capabilities = vim.tbl_deep_extend( + "force", + vim.lsp.protocol.make_client_capabilities(), + require("cmp_nvim_lsp").default_capabilities() + ), } ---A handler to setup all servers defined under `completion/servers/*.lua` ---@param lsp_name string