mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
nvim: refactor luasnip as plugin
luasnip works better as a plugin and not a ftplugin
This commit is contained in:
parent
6062f0313b
commit
c8e4bcc675
4 changed files with 44 additions and 64 deletions
|
|
@ -1,21 +1 @@
|
|||
vim.bo.expandtab = false
|
||||
|
||||
local once = require("once")
|
||||
once.test_and_load("ft_go", function()
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -3,10 +3,3 @@ opts.matchit_let_in()
|
|||
|
||||
vim.bo.shiftwidth = 2
|
||||
vim.bo.expandtab = true
|
||||
|
||||
local once = require("once")
|
||||
once.test_and_load("ft_haskell", function()
|
||||
local luasnip = require("luasnip")
|
||||
local haskell_snippets = require("haskell-snippets").all
|
||||
luasnip.add_snippets("haskell", haskell_snippets, { key = "haskell" })
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -2,40 +2,9 @@ vim.bo.shiftwidth = 2
|
|||
vim.bo.tabstop = 2
|
||||
vim.bo.textwidth = 100
|
||||
|
||||
local once = require("once")
|
||||
|
||||
once.test_and_load("ft_typst", function()
|
||||
vim.keymap.set("n", "<leader>f", function()
|
||||
local tw = vim.bo.textwidth
|
||||
local saved = vim.fn.winsaveview()
|
||||
vim.cmd('silent exec "%!typstyle -c ' .. tostring(tw) .. ' "')
|
||||
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
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>f", function()
|
||||
local tw = vim.bo.textwidth
|
||||
local saved = vim.fn.winsaveview()
|
||||
vim.cmd('silent exec "%!typstyle -c ' .. tostring(tw) .. ' "')
|
||||
vim.fn.winrestview(saved)
|
||||
end, { desc = "ft(typst): Format with typstyle" })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue