refactor(nvim): split snippets into separate files

Refs: #23
This commit is contained in:
Oliver Davies 2022-01-09 01:08:48 +00:00
parent 7932fb1d55
commit 7d1e320c30
4 changed files with 55 additions and 37 deletions

View file

@ -0,0 +1,9 @@
local luasnip = require "luasnip"
local snippet = luasnip.s
local insert = luasnip.insert_node
local text = luasnip.text_node
return {
snippet({ trig = "log", dscr = "console.log" }, { text "console.log(", insert(1, "value"), text ");" }),
}

View file

@ -0,0 +1,14 @@
local luasnip = require "luasnip"
local snippet = luasnip.s
local insert = luasnip.insert_node
local text = luasnip.text_node
return {
snippet({ trig = "frontmatter", dscr = "Document frontmatter" }, {
text { "---", "tags: " },
insert(1, "value"),
text { "", "---", "" },
insert(0),
}),
}

View file

@ -0,0 +1,23 @@
local luasnip = require "luasnip"
local snippet = luasnip.s
local choice = luasnip.choice_node
local insert = luasnip.insert_node
local text = luasnip.text_node
return {
snippet({ trig = "test", dscr = "Test block" }, {
text { "/* @test **/", "" },
text "public function ",
choice(1, {
text "test",
text "it",
text "should",
}),
insert(2), -- The method name.
text { "(): void {", "" },
text " ",
insert(0), -- The method body.
text { "", "}" },
}),
}