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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
vim.filetype.add({
extension = { snippets = "snippets" },
})
local function silent_map(mode, lhs, rhs, desc)
vim.keymap.set(mode, lhs, rhs, { silent = true, desc = desc or "" })
end
silent_map("i", "<Plug>luasnip-expand-or-jump", function()
require("luasnip").expand_or_jump()
end, "LuaSnip: Expand or jump in the current snippet")
silent_map("i", "<Plug>luasnip-expand-snippet", function()
require("luasnip").expand()
end, "LuaSnip: Expand the current snippet")
silent_map("i", "<Plug>luasnip-next-choice", function()
require("luasnip").change_choice(1)
end, "LuaSnip: Change to the next choice from the choiceNode")
silent_map("i", "<Plug>luasnip-prev-choice", function()
require("luasnip").change_choice(-1)
end, "LuaSnip: Change to the previous choice from the choiceNode")
silent_map("i", "<Plug>luasnip-jump-next", function()
require("luasnip").jump(1)
end, "LuaSnip: Jump to the next node")
silent_map("i", "<Plug>luasnip-jump-prev", function()
require("luasnip").jump(-1)
end, "LuaSnip: Jump to the previous node")
silent_map("n", "<Plug>luasnip-delete-check", function()
require("luasnip").unlink_current_if_deleted()
end, "LuaSnip: Removes current snippet from jumplist")
silent_map("!", "<Plug>luasnip-delete-check", function()
require("luasnip").unlink_current_if_deleted()
end, "LuaSnip: Removes current snippet from jumplist")
silent_map("", "<Plug>luasnip-expand-repeat", function()
require("luasnip").expand_repeat()
end, "LuaSnip: Repeat last node expansion")
silent_map("!", "<Plug>luasnip-expand-repeat", function()
require("luasnip").expand_repeat()
end, "LuaSnip: Repeat last node expansion")
silent_map("s", "<Plug>luasnip-expand-or-jump", function()
require("luasnip").expand_or_jump()
end, "LuaSnip: Expand or jump in the current snippet")
silent_map("s", "<Plug>luasnip-expand-snippet", function()
require("luasnip").expand()
end, "LuaSnip: Expand the current snippet")
silent_map("s", "<Plug>luasnip-next-choice", function()
require("luasnip").change_choice(1)
end, "LuaSnip: Change to the next choice from the choiceNode")
silent_map("s", "<Plug>luasnip-prev-choice", function()
require("luasnip").change_choice(-1)
end, "LuaSnip: Change to the previous choice from the choiceNode")
silent_map("s", "<Plug>luasnip-jump-next", function()
require("luasnip").jump(1)
end, "LuaSnip: Jump to the next node")
silent_map("s", "<Plug>luasnip-jump-prev", function()
require("luasnip").jump(-1)
end, "LuaSnip: Jump to the previous node")
vim.api.nvim_create_user_command("LuaSnipUnlinkCurrent", function()
require("luasnip").unlink_current()
end, { force = true })
--stylua: ignore
vim.api.nvim_create_user_command("LuaSnipListAvailable", function()
(
(
vim.version
and type(vim.version) == "table"
and (
((vim.version().major == 0) and (vim.version().minor >= 9))
or (vim.version().major > 0) )
) and vim.print
or vim.pretty_print
)(require("luasnip").available())
end, { force = true })
require("luasnip.config")._setup()
-- register these during startup so lazy_load will also load filetypes whose
-- events fired only before lazy_load is actually called.
-- (BufWinEnter -> lazy_load() wouldn't load any files without these).
vim.api.nvim_create_augroup("_luasnip_lazy_load", {})
vim.api.nvim_create_autocmd({ "BufWinEnter", "FileType" }, {
callback = function(event)
require("luasnip.loaders").load_lazy_loaded(tonumber(event.buf))
end,
group = "_luasnip_lazy_load",
})
|