Fix: cmp mapping (tab to confirm)

This commit is contained in:
Bertrand Benjamin 2022-02-03 10:26:39 +01:00
parent ecf6b9fb6a
commit 4e6384ac3e
1 changed files with 19 additions and 19 deletions

View File

@ -65,26 +65,26 @@ cmp.setup{
},
mapping = {
-- ["<cr>"] = cmp.mapping.confirm({select = true, behavior = cmp.ConfirmBehavior.Replace}),
["<cr>"] = cmp.mapping.confirm({select = true, behavior = cmp.ConfirmBehavior.Insert}),
["<Tab>"] = cmp.mapping(function(fallback)
if vim.fn.pumvisible() == 1 then
feedkey("<C-n>", "n")
elseif vim.fn["vsnip#available"]() == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
end, { "i", "s" }),
["<Tab>"] = cmp.mapping.confirm({select = true, behavior = cmp.ConfirmBehavior.Insert}),
-- ["<Tab>"] = cmp.mapping(function(fallback)
-- if vim.fn.pumvisible() == 1 then
-- feedkey("<C-n>", "n")
-- elseif vim.fn["vsnip#available"]() == 1 then
-- feedkey("<Plug>(vsnip-expand-or-jump)", "")
-- elseif has_words_before() then
-- cmp.complete()
-- else
-- fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
-- end
-- end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function()
if vim.fn.pumvisible() == 1 then
feedkey("<C-p>", "n")
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
-- ["<S-Tab>"] = cmp.mapping(function()
-- if vim.fn.pumvisible() == 1 then
-- feedkey("<C-p>", "n")
-- elseif vim.fn["vsnip#jumpable"](-1) == 1 then
-- feedkey("<Plug>(vsnip-jump-prev)", "")
-- end
-- end, { "i", "s" }),
},
sources = {
{ name = 'vsnip' },