nvim/cmp: load snippets per filetype

This commit is contained in:
Primrose 2025-07-09 11:26:38 +02:00
parent b6522ffbba
commit 14bfbece87
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
4 changed files with 50 additions and 111 deletions

View file

@ -1 +1,17 @@
vim.bo.expandtab = false
do
local luasnip = require("luasnip")
local s = luasnip.snippet
local t = luasnip.text_node
local cr = function() return t { "", "" } end
local i = luasnip.insert_node
luasnip.add_snippets("go", {
s("ie", {
t("if err != nil {"), cr(),
t("\t"), i(0), cr(),
t("}"),
}),
})
end

View file

@ -3,3 +3,7 @@ opts.matchit_let_in()
vim.bo.shiftwidth = 2
vim.bo.expandtab = true
local luasnip = require("luasnip")
local haskell_snippets = require("haskell-snippets").all
luasnip.add_snippets("haskell", haskell_snippets, { key = "haskell" })

View file

@ -7,3 +7,30 @@ vim.keymap.set("n", "<leader>f", function()
vim.cmd([[silent exec "%!typstyle -c 100"]])
vim.fn.winrestview(saved)
end, { desc = "ft(typst): Format with typstyle" })
do
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(),
}),
})
end