Nvim: fix luasnip keymappings

This commit is contained in:
Marko Korhonen 2023-10-04 13:17:43 +03:00
parent 747b4b8990
commit 8a3fb3ad45
Signed by: FunctionalHacker
GPG key ID: A7F78BCB859CD890
2 changed files with 6 additions and 25 deletions

View file

@ -32,7 +32,7 @@ return function()
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 luasnip.expand_or_jumpable() then elseif luasnip.expand_or_jumpable() then
@ -40,8 +40,8 @@ return function()
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 luasnip.jumpable(-1) then elseif luasnip.jumpable(-1) then
@ -49,7 +49,7 @@ return function()
else else
fallback() fallback()
end end
end, end, { "i", "s" }),
}, },
sources = { sources = {
{ name = "copilot" }, { name = "copilot" },

View file

@ -1,23 +1,4 @@
return function() return function()
local luasnip = require("luasnip") -- load friendly-snippets to luasnip
local wk = require("which-key") require("luasnip/loaders/from_vscode").lazy_load()
-- load friendly-snippets to luasnip
require("luasnip/loaders/from_vscode").lazy_load()
-- Register snippet navigation keybindings
local snippet_mappings = {
["<c-j>"] = {
function()
luasnip.jump(1)
end,
},
["<c-k>"] = {
function()
luasnip.jump(-1)
end,
},
}
--wk.register(snippet_mappings, {mode = "i"})
--wk.register(snippet_mappings, {mode = "s"})
end end