-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add some snippets for Go files
- Loading branch information
1 parent
757f5a5
commit 1dfe6f8
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
local luasnip = require("luasnip") | ||
local snippet = luasnip.snippet | ||
local insert_node = luasnip.insert_node | ||
local fmt = require("luasnip.extras.fmt").fmt | ||
|
||
return { | ||
-- Snippet for defining a function | ||
snippet( | ||
{ trig = "func", desc = "Create a function definition" }, | ||
fmt( | ||
[[ | ||
func {1}({2} {3}) ({4}) {{ | ||
return {5} | ||
}} | ||
]], | ||
{ | ||
insert_node(1, "FunctionName"), | ||
insert_node(2, "Argument"), | ||
insert_node(3, "ArgumentType"), | ||
insert_node(4, "ReturnType"), | ||
insert_node(5, ""), | ||
} | ||
) | ||
), | ||
|
||
-- Snippet to create a Go struct | ||
snippet( | ||
{ trig = "struct", desc = "Create a Go struct" }, | ||
fmt( | ||
[[ | ||
type {1} struct {{ | ||
{2} | ||
}} | ||
]], | ||
{ insert_node(1, "StructName"), insert_node(2, "") } | ||
) | ||
), | ||
|
||
-- Snippet to create struct method | ||
snippet( | ||
{ trig = "method", desc = "Create a struct method" }, | ||
fmt( | ||
[[ | ||
func ({1}) {2}({3}) {4} {{ | ||
return {5} | ||
}} | ||
]], | ||
{ | ||
insert_node(1, "Struct"), | ||
insert_node(2, "Method"), | ||
insert_node(3, "Args"), | ||
insert_node(4, "ReturnType"), | ||
insert_node(5, ""), | ||
} | ||
) | ||
), | ||
} |