feat: only confirm autocomplete with enter if item selected

main
mandlm 2022-05-18 10:22:09 +02:00
parent fde2607ca2
commit 415fcc08ae
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
1 changed files with 9 additions and 3 deletions

View File

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