Improved flow
This commit is contained in:
52
snippets/go.lua
Normal file
52
snippets/go.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
-- Go snippets
|
||||
-- See docs/guides/snippets.md for how to create snippets
|
||||
--
|
||||
-- Quick reference:
|
||||
-- s(trigger, nodes, opts) - Create a snippet
|
||||
-- t(text) - Text node
|
||||
-- i(index, default) - Insert node (tab stop)
|
||||
-- c(index, choices) - Choice node
|
||||
-- f(func, args) - Function node
|
||||
-- d(index, func, args) - Dynamic node
|
||||
-- rep(index) - Repeat node
|
||||
--
|
||||
-- Example:
|
||||
-- s("iferr", fmt("if err != nil {{\n\treturn {}\n}}", { i(1, "err") }))
|
||||
-- Typing "iferr" + expand will give error handling template
|
||||
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local c = ls.choice_node
|
||||
local f = ls.function_node
|
||||
local d = ls.dynamic_node
|
||||
local sn = ls.snippet_node
|
||||
local rep = require("luasnip.extras").rep
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
|
||||
-- Add your Go snippets here
|
||||
return {
|
||||
-- Example: Uncomment and modify as needed
|
||||
--
|
||||
-- Error handling
|
||||
-- s("iferr", fmt([[
|
||||
-- if err != nil {{
|
||||
-- return {}
|
||||
-- }}
|
||||
-- ]], { i(1, "err") })),
|
||||
--
|
||||
-- Function
|
||||
-- s("fn", fmt([[
|
||||
-- func {}({}) {} {{
|
||||
-- {}
|
||||
-- }}
|
||||
-- ]], { i(1, "name"), i(2), i(3, "error"), i(0) })),
|
||||
--
|
||||
-- Struct
|
||||
-- s("st", fmt([[
|
||||
-- type {} struct {{
|
||||
-- {}
|
||||
-- }}
|
||||
-- ]], { i(1, "Name"), i(0) })),
|
||||
}
|
||||
Reference in New Issue
Block a user