local ls = require("luasnip") local s = ls.snippet local t = ls.text_node local i = ls.insert_node local c = ls.choice_node local fmt = require("luasnip.extras.fmt").fmt local rep = require("luasnip.extras").rep return { -- func s( "fn", fmt("func {}() {{\n\t{}\n}}", { i(1, "functionName"), i(2, "// body"), }) ), -- main s( "main", fmt( [[ func main() {{ {} }} ]], { i(1, "// your code here"), } ) ), -- if err != nil s( "ifr", fmt( [[ if err != nil {{ return {} }} ]], { i(1, "err"), } ) ), -- for loop s( "for", fmt( [[ for {} := 0; {} < {}; {}++ {{ {} }} ]], { i(1, "i"), rep(1), i(2, "n"), rep(1), i(3, "// body"), } ) ), -- struct s( "struct", fmt( [[ type {} struct {{ {} }} ]], { i(1, "MyStruct"), i(2, "Field string"), } ) ), -- method s( "meth", fmt( [[ func ({}) {}({}) {} {{ {} }} ]], { i(1, "m *MyStruct"), i(2, "MethodName"), i(3, ""), i(4, ""), i(5, "// body"), } ) ), }