-
Notifications
You must be signed in to change notification settings - Fork 1
/
luasnip.lua
66 lines (61 loc) · 2.19 KB
/
luasnip.lua
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
return {
"L3MON4D3/LuaSnip", -- snippets
name = "luasnip",
version = "v2.*",
build = "make install_jsregexp",
config = function()
local ls = require("luasnip")
local types = require("luasnip.util.types")
local snippets = require("ag.snippets")
---#Config
ls.setup({
keep_roots = false,
link_roots = false,
link_children = false,
-- Update snippet text in _real time_
updateevents = { "TextChanged", "TextChangedI" },
enable_autosnippets = true,
delete_check_events = { "InsertLeave" },
-- Show virtual text hints for node types
ext_opts = {
[types.insertNode] = {
active = {
virt_text = { { "●", "Operator" } },
},
},
[types.choiceNode] = {
active = {
virt_text = { { "●", "Constant" } },
},
},
},
})
-- load vscode style snippets from other plugins
require("luasnip.loaders.from_vscode").lazy_load()
---#Mappings
-- Previous snippet region
vim.keymap.set({ "i", "s" }, "<C-k>", function()
if ls.jumpable(-1) then ls.jump(-1) end
end, { silent = true, desc = "Next snippet node" })
-- Expand snippet, or go to next snippet region
vim.keymap.set({ "i", "s" }, "<C-j>", function()
if ls.expand_or_jumpable() then ls.expand_or_jump() end
end, { silent = true, desc = "Prev snippet node" })
-- Cycle "choices" for current snippet region
vim.keymap.set({ "i", "s" }, "<C-l>", function()
if ls.choice_active() then ls.change_choice(1) end
end, { silent = true, desc = "Next snippet choice" })
-- load my custom snippets
ls.add_snippets("typescript", snippets.typescript)
ls.add_snippets("dart", snippets.dart)
ls.add_snippets("python", snippets.python)
end,
ft = {
"vue",
"typescript",
"javascript",
"dart",
"rust",
"python",
},
}