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 = { snippet = {
expand = function(args) luasnip.lsp_expand(args.body) end, 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({ sources = cmp.config.sources({
{ name = "luasnip" }, { name = "luasnip" },
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "path" }, { name = "path" },
}, }, {
{
{ name = "buffer" }, { name = "buffer" },
{ name = "spell", }, { name = "spell" },
}), }),
} }