diff options
author | Squibid <me@zacharyscheiman.com> | 2025-05-31 03:32:58 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2025-05-31 03:32:58 -0400 |
commit | e830931ff421e4380d5de8b1926842000ba9be34 (patch) | |
tree | 207584548026db649bc6ab21df3b41b71ebfd830 /lua/conf/plugins/luasnip.lua | |
parent | ef678f31fdf24c0e6c4eca9a13ad9f63a53447b9 (diff) | |
download | nvim-e830931ff421e4380d5de8b1926842000ba9be34.tar.gz nvim-e830931ff421e4380d5de8b1926842000ba9be34.tar.bz2 nvim-e830931ff421e4380d5de8b1926842000ba9be34.zip |
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 } |