local map = core.misc.map return { "L3MON4D3/LuaSnip", branch = "v2.*", config = function() vim.cmd("make install_jsregexp") end, lazy = function(load) load:keymap({"i", "s"}, "") load:keymap({"i", "s"}, "") load:keymap({"i", "s"}, "") load:keymap({"i", "s"}, "") load:auto("InsertEnter") end, load = function() local ls = require("luasnip") -- replace the builtin snippet handler with luasnip so I get all my fancy -- stuff vim.snippet.expand = ls.lsp_expand ls.config.setup { keep_roots = true, link_roots = true, link_children = true, exit_roots = not true } map({"i", "s"}, "", ls.expand) map({"i", "s"}, "", function() ls.jump(1) end) map({"i", "s"}, "", function() ls.jump(-1) end) map({"i", "s"}, "", function() if ls.choice_active() then ls.change_choice(1) end end) -- collect all snippets and add them for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua", true)) do local fn = file:gsub("^.*/", ""):gsub("%.lua$", "") local ret = require("snippets."..fn) if type(ret) ~= "boolean" then ls.add_snippets(fn, ret, { key = fn }) end end end }