1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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"}, { "<C-e>", "<C-a>" }, function()
if luasnip.choice_active() then
luasnip.change_choice(1)
end
end)
map({"i", "s"}, "<C-k>", 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
}
|