Snippets: Markdown, Go

- Go: Add section snippet
- Markdown: Update golang codeblock
This commit is contained in:
t0xa 2026-10-17 20:36:26 +03:00
parent 4c89fa6339
commit e0b6f4ba88
2 changed files with 31 additions and 7 deletions

View file

@ -0,0 +1,24 @@
-- Clear snippets collection when souring lua file
require("luasnip.session.snippet_collection").clear_snippets "go"
local ls = require "luasnip"
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local util = require "custom.snippets.util"
ls.add_snippets("go", {
s({ trig = "gosection", dscr = "Section header" }, {
t { string.rep("/", 80), "" },
t "//",
f(util.pad_left(80, 2), { 1 }),
i(1, "Section topic"),
f(util.pad_right(80, 2), { 1 }),
t "//",
t { "", string.rep("/", 80), "" },
i(0),
}),
})

View file

@ -42,7 +42,7 @@ ls.add_snippets(
```
]],
{
c(1, { t "python", t "bash", t "", t "swift", t "c" }),
c(1, { t "python", t "bash", t "go", t "", t "swift", t "c" }),
i(2),
}
)
@ -50,13 +50,13 @@ ls.add_snippets(
s({ trig = "iq", dscr = "Insert question" },
fmt(
[[
┏━━━━━━━━━━━━━━ Question 0 ━━━━━━━━━━━━━━━
┏━━━━━━━━━━━━━━ Question 0 ━━━━━━━━━━━━━━━
**Question**
{}
**Answer**:
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
]],
{
i(0),
@ -66,13 +66,13 @@ ls.add_snippets(
s({ trig = "ip", dscr = "Insert problem" },
fmt(
[[
┏━━━━━━━━━━━━━━ Problem 0 ━━━━━━━━━━━━━━━
┏━━━━━━━━━━━━━━ Problem 0 ━━━━━━━━━━━━━━━
**Problem**:
{}
**Solution**:
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
]],
{
i(0),
@ -83,10 +83,10 @@ ls.add_snippets(
s({ trig = "isn", dscr = "Insert side notes" },
fmt(
[[
┏━━━━━━━━━━━━━ Sticky notes ━━━━━━━━━━━━━━
┏━━━━━━━━━━━━━ Sticky notes ━━━━━━━━━━━━━━
**Theme**: {}
{}
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
]],
{
i(1),