
## Description this makes the extra luasnip lazy load at the same time as nvim cmp. just putting `lazy = true` works because `nvim-cmp` when being loaded with `InsertEnter` also load `cmp-luasnip`, which itself load `LUASNIP`. you can see the problem in the following discussion https://github.com/LazyVim/LazyVim/discussions/3966 where luasnip was not lazy loaded when starting lazyvim. This was also loading nvim-cmp and all its dep when starting lazyvim, which negatively impacted performance. ## Related Issue(s) https://github.com/LazyVim/LazyVim/discussions/3966 ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines.
55 lines
1.3 KiB
Lua
55 lines
1.3 KiB
Lua
return {
|
|
{
|
|
"L3MON4D3/LuaSnip",
|
|
lazy = true,
|
|
build = (not LazyVim.is_win())
|
|
and "echo 'NOTE: jsregexp is optional, so not a big deal if it fails to build'; make install_jsregexp"
|
|
or nil,
|
|
dependencies = {
|
|
{
|
|
"rafamadriz/friendly-snippets",
|
|
config = function()
|
|
require("luasnip.loaders.from_vscode").lazy_load()
|
|
end,
|
|
},
|
|
{
|
|
"nvim-cmp",
|
|
dependencies = {
|
|
"saadparwaiz1/cmp_luasnip",
|
|
},
|
|
opts = function(_, opts)
|
|
opts.snippet = {
|
|
expand = function(args)
|
|
require("luasnip").lsp_expand(args.body)
|
|
end,
|
|
}
|
|
table.insert(opts.sources, { name = "luasnip" })
|
|
end,
|
|
},
|
|
},
|
|
opts = {
|
|
history = true,
|
|
delete_check_events = "TextChanged",
|
|
},
|
|
},
|
|
{
|
|
"nvim-cmp",
|
|
-- stylua: ignore
|
|
keys = {
|
|
{
|
|
"<tab>",
|
|
function()
|
|
return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
|
|
end,
|
|
expr = true, silent = true, mode = "i",
|
|
},
|
|
{ "<tab>", function() require("luasnip").jump(1) end, mode = "s" },
|
|
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } },
|
|
},
|
|
},
|
|
{
|
|
"garymjr/nvim-snippets",
|
|
enabled = false,
|
|
},
|
|
}
|