summaryrefslogtreecommitdiff
path: root/.config/nvim
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim')
-rw-r--r--.config/nvim/lua/custom/snippets/go.lua49
1 files changed, 49 insertions, 0 deletions
diff --git a/.config/nvim/lua/custom/snippets/go.lua b/.config/nvim/lua/custom/snippets/go.lua
new file mode 100644
index 0000000..c6ddd09
--- /dev/null
+++ b/.config/nvim/lua/custom/snippets/go.lua
@@ -0,0 +1,49 @@
+require('luasnip.session.snippet_collection').clear_snippets('go')
+local ls = require('luasnip')
+local i = ls.insert_node
+
+---@param abbr string
+---@param expansion string
+---@param args table
+local function s(abbr, expansion, args)
+ return ls.snippet(abbr, require('luasnip.extras.fmt').fmt(expansion, args))
+end
+
+local tea_model = [=[
+import (
+ "fmt"
+
+ tea "github.com/charmbracelet/bubbletea"
+)
+
+type Model struct{{
+ {}
+}}
+
+func New() Model {{
+ return Model{{
+ }}
+}}
+
+func (m Model) Init() tea.Cmd {{
+ return nil
+}}
+
+func (m Model) View() string {{
+ return fmt.Sprintf(
+ "%s",
+ "",
+ )
+}}
+
+func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {{
+ switch msg := msg.(type) {{
+ default:
+ return m, nil
+ }}
+}}
+]=]
+
+ls.add_snippets('go', {
+ s('tmod', tea_model, { i(0) }),
+})