lunasnip super-tab like mapping example from hrsh7th/nvim-cmp

This commit is contained in:
socialsmoker223 2022-02-01 21:06:01 +08:00 committed by siduck
parent d0ad028efc
commit 2eab84f8f1

View file

@ -41,24 +41,24 @@ local default = {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
["<Tab>"] = function(fallback)
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif snippets_status and require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
require("luasnip").expand_or_jump()
else
fallback()
end
end,
["<S-Tab>"] = function(fallback)
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif snippets_status and require("luasnip").jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end,
end, { "i", "s" }),
},
sources = {
{ name = "nvim_lsp" },