Fixed no complete on < CR >

This commit is contained in:
Daveanand Mannie
2024-09-05 20:55:37 -04:00
parent 0b40e540c8
commit 660f9ec75a
2 changed files with 12 additions and 8 deletions

View File

@@ -15,12 +15,16 @@ local cmp = require("cmp")
cmp.setup({
mapping = {
["<Tab>"] = cmp.mapping.confirm({ select = true }),
["<CR>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm({ select = false })
else
fallback() -- Insert a new line if completion is not visible
end
end, { "i", "s" }), -- 'i' for insert mode, 's' for select mode
["<CR>"] = 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 }),
}),
},
})