summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/custom/snippets/go.lua
blob: 42e30f796b08c00db4a3f883b1cdd81ec573cf01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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) (tea.Model, tea.Cmd) {{
	switch msg := msg.(type) {{
	default:
		return m, nil
	}}
}}
]=]

ls.add_snippets('go', {
    s('tmod', tea_model, { i(0) }),
})