diff --git a/modules/home/vim/default.nix b/modules/home/vim/default.nix index 44fd0580..8e6bd5c6 100644 --- a/modules/home/vim/default.nix +++ b/modules/home/vim/default.nix @@ -66,12 +66,15 @@ in plenary-nvim # 'null-ls', 'telescope' dependency # Completion + luasnip # Snippet manager compatible with LSP + friendly-snippets # LSP snippets collection nvim-cmp # Completion engine cmp-async-path # More responsive path completion cmp-buffer # Words from open buffers cmp-nvim-lsp # LSP suggestions cmp-nvim-lua # NeoVim lua API cmp-under-comparator # Sort items that start with '_' lower + cmp_luasnip # Snippet suggestions from LuaSnip # UX improvements dressing-nvim # Integrate native UI hooks with Telescope etc... diff --git a/modules/home/vim/plugin/settings/completion.lua b/modules/home/vim/plugin/settings/completion.lua index d50152a9..0ed8c7f1 100644 --- a/modules/home/vim/plugin/settings/completion.lua +++ b/modules/home/vim/plugin/settings/completion.lua @@ -3,24 +3,25 @@ vim.opt.completeopt = { "menu", "menuone", "noselect" } local cmp = require("cmp") local cmp_under_comparator = require("cmp-under-comparator") +local luasnip = require("luasnip") cmp.setup({ snippet = { expand = function(args) - vim.snippet.expand(args.body) + luasnip.lsp_expand(args.body) end, }, mapping = { [""] = function(fallback) - if vim.snippet.active({ direction = 1 }) then - vim.snippet.jump(1) + if luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() else fallback() end end, [""] = function(fallback) - if vim.snippet.active({ direction = -1 }) then - vim.snippet.jump(-1) + if luasnip.jumpable(-1) then + luasnip.jump(-1) else fallback() end @@ -39,6 +40,7 @@ cmp.setup({ { name = "async_path", priority_weight = 110 }, { name = "nvim_lsp", priority_weight = 100 }, { name = "nvim_lua", priority_weight = 90 }, + { name = "luasnip", priority_weight = 80 }, { name = "buffer", max_item_count = 5, priority_weight = 50 }, }, sorting = { diff --git a/modules/home/vim/plugin/settings/luasnip.lua b/modules/home/vim/plugin/settings/luasnip.lua new file mode 100644 index 00000000..80309d7e --- /dev/null +++ b/modules/home/vim/plugin/settings/luasnip.lua @@ -0,0 +1 @@ +require("luasnip.loaders.from_vscode").lazy_load()