nvim/cmp: add simple luasnip binding to nvim-cmp

This commit is contained in:
Primrose 2025-07-18 20:49:11 +02:00
parent a589a5bd6a
commit c8fd1b4163
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -7,14 +7,29 @@ cmp.setup {
snippet = {
expand = function(args) luasnip.lsp_expand(args.body) end,
},
mapping = cmp.mapping.preset.insert(),
mapping = cmp.mapping.preset.insert {
["<Tab>"] = cmp.mapping(function(fallback)
if luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
},
sources = cmp.config.sources({
{ name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "path" },
},
{
{ name = "buffer" },
{ name = "spell", },
}),
{ name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "path" },
}, {
{ name = "buffer" },
{ name = "spell" },
}),
}