use luasnip and change stuff in nvim-cmp

This commit is contained in:
cy 2024-12-02 23:17:18 -05:00
parent 2ffef35935
commit da4e060f40
3 changed files with 45 additions and 27 deletions

View file

@ -1,36 +1,53 @@
local cmp = require("cmp")
local luasnip = require("luasnip");
cmp.setup {
snippet = {
expand = function(args)
vim.fn["UltiSnips#Anon"](args.body)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert {
["<Tab>"] = function(fallback)
mapping = {
["<C-e"] = cmp.mapping.abort(),
["<C-k>"] = cmp.mapping(function(fallback)
if cmp.visible() then
if luasnip.expandable() then
luasnip.expand()
else
cmp.confirm({
select = true,
})
end
else
fallback()
end
end),
["<C-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end,
["<S-Tab"] = function(fallback)
end, { "i", "s" }),
["<C-p>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end,
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = false }),
end, { "i", "s" }),
},
sources = cmp.config.sources {
sources = cmp.config.sources ({
{ name = "nvim_lsp" },
{ name = "ultisnips" },
{ name = "luasnip" },
}, {
{ name = "buffer" },
{ name = "path" },
}
})
}

View file

@ -41,16 +41,18 @@ local plugin_specs = {
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-omni",
"hrsh7th/cmp-cmdline",
"quangnguyen30192/cmp-nvim-ultisnips",
"saadparwaiz1/cmp_luasnip",
},
config = function()
require("config.nvim-cmp")
end,
},
{ "SirVer/ultisnips", dependencies = {
"honza/vim-snippets",
}, event = "InsertEnter" },
{
"L3MON4D3/LuaSnip",
version = "v2.*",
build = "make install_jsregexp",
},
{ "stevearc/dressing.nvim", event = "VeryLazy" },