feat: only confirm autocomplete with enter if item selected

This commit is contained in:
mandlm 2022-05-18 10:22:09 +02:00
parent fde2607ca2
commit 415fcc08ae
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7

View File

@ -22,9 +22,15 @@ cmp.setup({
{ name = "calc" } { name = "calc" }
}), }),
mapping = { mapping = {
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(),
{ 'i', 'c' }), { "i", "c" }),
['<CR>'] = cmp.mapping.confirm({ select = true }), ["<CR>"] = cmp.mapping(function(fallback)
if cmp.visible() and cmp.get_selected_entry() then
cmp.confirm()
else
fallback()
end
end, { "i", "s" }),
["<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()