neovim: setup snippets mappings and load vsc*de snippets

This commit is contained in:
2023-11-26 11:30:44 +03:00
parent 70d799f33e
commit 91748f16a4
2 changed files with 18 additions and 3 deletions

View File

@@ -38,9 +38,21 @@ cmp.setup({
end, end,
}, },
mapping = { mapping = {
["<C-j>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), ["<C-j>"] = cmp.mapping(function()
["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), if ls.in_snippet() then
["<C-space>"] = cmp.mapping(function(fallback) ls.jump(1)
else
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
end
end),
["<C-k>"] = cmp.mapping(function()
if ls.in_snippet() then
ls.jump(-1)
else
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
end
end),
["<C-space>"] = cmp.mapping(function()
if cmp.visible() then if cmp.visible() then
cmp.close() cmp.close()
else else
@@ -124,3 +136,5 @@ cmp.setup.filetype("gitcommit", {
{ name = "buffer" }, { name = "buffer" },
}), }),
}) })
require("luasnip.loaders.from_vscode").lazy_load()

View File

@@ -47,6 +47,7 @@ require("packer").startup(function(use)
}) })
use({ "L3MON4D3/LuaSnip", { use({ "L3MON4D3/LuaSnip", {
"saadparwaiz1/cmp_luasnip", "saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
} }) } })
use({ "neovim/nvim-lspconfig" }) use({ "neovim/nvim-lspconfig" })