lsp: update CR mapping function

This commit is contained in:
2024-07-24 11:43:30 +03:00
parent 4ccc8ae093
commit 56316c6986

View File

@@ -46,20 +46,17 @@ return {
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
-- `Enter` key to confirm completion -- `Enter` key to confirm completion
['<CR>'] = cmp.mapping(function(fallback) ["<CR>"] = cmp.mapping({
if cmp.visible() then i = function(fallback)
if luasnip.expandable() then if cmp.visible() and cmp.get_active_entry() then
luasnip.expand() cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
else
cmp.confirm({
select = false,
})
end
else else
fallback() fallback()
end end
end), end,
s = cmp.mapping.confirm({ select = true }),
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
}),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()