.files/.config/nvim/plugin/luasnip.lua
Léana 江 c8e4bcc675
nvim: refactor luasnip as plugin
luasnip works better as a plugin and not a ftplugin
2025-08-09 09:00:25 +02:00

38 lines
863 B
Lua

local luasnip = require("luasnip")
local s = luasnip.snippet
local t = luasnip.text_node
local cr = function() return t { "", "" } end
local i = luasnip.insert_node
local f = luasnip.function_node
local function show_date_typst_entry() return os.date('"%Y-%m-%d %H:%M:%S"') end
luasnip.add_snippets("typst", {
s("entry", {
t("#entry("),
f(show_date_typst_entry),
t { ")[", "" },
t(" "),
i(0),
t { "", "]" },
}),
s("lang", {
t('#set text(lang: "'),
i(0),
t('")'),
cr(),
}),
})
luasnip.add_snippets("go", {
s("ie", {
t("if err != nil {"),
cr(),
t("\t"),
i(0),
cr(),
t("}"),
}),
})
local haskell_snippets = require("haskell-snippets").all
luasnip.add_snippets("haskell", haskell_snippets, { key = "haskell" })