diff options
Diffstat (limited to 'lua/conf/plugins/luasnip.lua')
-rw-r--r-- | lua/conf/plugins/luasnip.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lua/conf/plugins/luasnip.lua b/lua/conf/plugins/luasnip.lua index 7385af1..fc6b2e4 100644 --- a/lua/conf/plugins/luasnip.lua +++ b/lua/conf/plugins/luasnip.lua @@ -1,5 +1,4 @@ -local misc = require("core.misc") -local map = misc.map +local map, auto = core.misc.map, core.misc.auto return { "L3MON4D3/LuaSnip", branch = "v2.4.0", @@ -55,14 +54,21 @@ return { "L3MON4D3/LuaSnip", end end) - -- load all snippets from snippet directory + -- collect all snippets and add them when in the correct file type for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua", true)) do local fn = file:gsub("^.*/", ""):gsub("%.lua$", "") - local ret = misc.include("snippets."..fn) - if type(ret) ~= "boolean" then - luasnip.add_snippets(fn, ret, { key = fn }) - end + + auto("FileType", { + pattern = fn, + once = true, + callback = function() + local ret = require("snippets."..fn) + if type(ret) ~= "boolean" then + luasnip.add_snippets(fn, ret, { key = fn }) + end + end + }) end end } |