refactor(nvim): use fmta for formatting

This commit is contained in:
Oliver Davies 2022-01-09 22:10:30 +00:00
parent 7d1e320c30
commit 6a3c173766
2 changed files with 25 additions and 18 deletions

View file

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

View file

@ -1,23 +1,30 @@
local luasnip = require "luasnip"
local snippet = luasnip.s
local fmta = require("luasnip.extras.fmt").fmta
local choice = luasnip.choice_node
local insert = luasnip.insert_node
local snippet = luasnip.snippet
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 { "", "}" },
}),
snippet(
"test",
fmta(
[[
/** @test */
public function <><>(): void {
<>
}
]],
{
choice(1, {
text "test",
text "it",
text "should",
}),
insert(2),
insert(0),
}
)
),
}