nvim/luasnip: ruler snippet for time

This commit is contained in:
Primrose 2025-10-05 10:56:01 +08:00
parent 8c63d777f1
commit 99d92483bd
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -5,12 +5,14 @@ local cr = function() return t { "", "" } end
local i = luasnip.insert_node local i = luasnip.insert_node
local f = luasnip.function_node local f = luasnip.function_node
local function datetime() return os.date('"%Y-%m-%d %H:%M:%S"') end local function datetime() return os.date('%Y-%m-%d %H:%M:%S') end
local function date() return os.date('"%Y-%m-%d"') end local function date() return os.date('%Y-%m-%d') end
local function quoted(s) return '"' .. s .. '"' end
luasnip.add_snippets("typst", { luasnip.add_snippets("typst", {
s("entry", { s("entry", {
t("#entry("), t("#entry("),
f(datetime), f(function() return quoted(datetime()) end),
t { ")[", "" }, t { ")[", "" },
t(" "), t(" "),
i(0), i(0),
@ -18,7 +20,7 @@ luasnip.add_snippets("typst", {
}), }),
s("from-the-future", { s("from-the-future", {
t("#entries.from-the-future("), t("#entries.from-the-future("),
f(date), f(function() return quoted(date()) end),
t { ")[", "" }, t { ")[", "" },
t(" "), t(" "),
i(0), i(0),
@ -43,5 +45,17 @@ luasnip.add_snippets("go", {
}), }),
}) })
luasnip.add_snippets("ruler", {
s("begin", {
f(datetime),
t(" ... "),
i(0),
}),
s("end", {
f(datetime),
i(0),
}),
})
local haskell_snippets = require("haskell-snippets").all local haskell_snippets = require("haskell-snippets").all
luasnip.add_snippets("haskell", haskell_snippets, { key = "haskell" }) luasnip.add_snippets("haskell", haskell_snippets, { key = "haskell" })