From c489d393695e90d424f9ae51e35c4d42358e6a71 Mon Sep 17 00:00:00 2001 From: Squibid Date: Fri, 9 Aug 2024 02:45:31 -0400 Subject: yes there's a bit of java in my nvim config why do you ask? --- lua/conf/plugins/luasnip.lua | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 lua/conf/plugins/luasnip.lua (limited to 'lua/conf/plugins/luasnip.lua') diff --git a/lua/conf/plugins/luasnip.lua b/lua/conf/plugins/luasnip.lua new file mode 100644 index 0000000..26b293b --- /dev/null +++ b/lua/conf/plugins/luasnip.lua @@ -0,0 +1,52 @@ +local misc = require('core.misc') +local map = misc.map + +return { 'L3MON4D3/LuaSnip', + branch = 'v2.3.0', + disable = vim.version().minor < 7, + config = function() + vim.cmd('make install_jsregexp') + end, + function() + local luasnip = require('luasnip') + local types = require("luasnip.util.types") + + luasnip.config.set_config { + history = true, -- return back into snippet + updateevents = { "TextChanged", "TextChangedI" }, -- update on text insert + ext_opts = { + [types.choiceNode] = { + active = { + virt_text = {{ "●", "@boolean" }} + } + }, + [types.insertNode] = { + active = { + virt_text = {{ "●", "@constant" }} + } + }, + }, + } + + map({"i", "s"}, { "", "" }, function() + if luasnip.choice_active() then + luasnip.change_choice(1) + end + end) + + map({"i", "s"}, "", function() + if luasnip.expandable(-1) then + luasnip.expand(-1) + end + end) + + -- load all snippets from snippet directory + 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 + end + end +} -- cgit v1.2.1