From 99d92483bd983f8e541d780894fe0635ac6fbc01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Sun, 5 Oct 2025 10:56:01 +0800 Subject: [PATCH] nvim/luasnip: ruler snippet for time --- .config/nvim/plugin/luasnip.lua | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.config/nvim/plugin/luasnip.lua b/.config/nvim/plugin/luasnip.lua index b3e9fd94..bd6ab457 100644 --- a/.config/nvim/plugin/luasnip.lua +++ b/.config/nvim/plugin/luasnip.lua @@ -5,12 +5,14 @@ local cr = function() return t { "", "" } end local i = luasnip.insert_node local f = luasnip.function_node -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 datetime() return os.date('%Y-%m-%d %H:%M:%S') end +local function date() return os.date('%Y-%m-%d') end +local function quoted(s) return '"' .. s .. '"' end + luasnip.add_snippets("typst", { s("entry", { t("#entry("), - f(datetime), + f(function() return quoted(datetime()) end), t { ")[", "" }, t(" "), i(0), @@ -18,7 +20,7 @@ luasnip.add_snippets("typst", { }), s("from-the-future", { t("#entries.from-the-future("), - f(date), + f(function() return quoted(date()) end), t { ")[", "" }, t(" "), 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 luasnip.add_snippets("haskell", haskell_snippets, { key = "haskell" })