Imporve luasnip Tab jump behaviour

This commit is contained in:
socialsmoker223 2022-03-04 07:53:40 +08:00 committed by siduck
parent ef6ecab861
commit 1278a3b703
1 changed files with 4 additions and 4 deletions

View File

@ -37,7 +37,7 @@ local default = {
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = true, select = true,
}, },
["<Tab>"] = function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then elseif require("luasnip").expand_or_jumpable() then
@ -45,8 +45,8 @@ local default = {
else else
fallback() fallback()
end end
end, end, { "i", "s" }),
["<S-Tab>"] = function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then elseif require("luasnip").jumpable(-1) then
@ -54,7 +54,7 @@ local default = {
else else
fallback() fallback()
end end
end, end, { "i", "s" }),
}, },
sources = { sources = {
{ name = "nvim_lsp" }, { name = "nvim_lsp" },