feat(overseer): Add templates for compiling and watching typst files

This commit is contained in:
kalmenn 2024-09-19 23:21:34 +02:00
parent 3ae9e70c4d
commit ec74c2d18f
Signed by: kalmenn
GPG key ID: F500055C44BC3834
3 changed files with 66 additions and 10 deletions

View file

@ -0,0 +1,22 @@
local overseer = require("overseer")
return {
name = "Compile typst",
builder = function()
local file = vim.fn.expand("%:p")
local cwd = vim.fn.getcwd()
return {
name = "Compile " .. vim.fn.bufname(),
cmd = { "typst" },
args = { "compile", file, "--root", cwd },
}
end,
tags = {overseer.TAG.BUILD},
condition = {
filetype = { "typst" },
callback = function()
return vim.fn.executable("typst") == 1
end,
},
}

View file

@ -0,0 +1,29 @@
return {
name = "Watch typst",
params = {
pdf_viewer = {
type = "string",
optional = false,
default = "xdg-open",
validate = function(value)
return vim.fn.executable(value) ~= 0
end,
},
},
builder = function(params)
local file = vim.fn.expand("%:p")
local cwd = vim.fn.getcwd()
return {
name = "Watch " .. vim.fn.bufname(),
cmd = { "typst" },
args = { "watch", file, "--root", cwd, "--open", params.pdf_viewer },
}
end,
condition = {
filetype = { "typst" },
callback = function()
return vim.fn.executable("typst") == 1
end,
},
}

View file

@ -1,12 +1,17 @@
return {
'stevearc/overseer.nvim',
opts = {},
keys = {
{"<leader>ot", "<cmd>OverseerToggle<cr>", desc = "Toggle Overseer"},
{"<leader>or", "<cmd>OverseerRun<cr>", desc = "Start an Overseer task"},
{"<leader>os", "<cmd>OverseerRunCmd<cr>", desc = "Run a shell command with Overseer"},
{"<leader>ob", "<cmd>OverseerBuild<cr>", desc = "Open the Overseer task builder"},
{"<leader>oo", "<cmd>OverseerOpen<cr>", desc = "Open a window with the output of an Overseer task"},
{"<leader>oa", "<cmd>OverseerTaskAction<cr>", desc = "Add an action to an Overseer task"},
},
'stevearc/overseer.nvim',
opts = {
templates = {
"typst.watch",
"typst.compile",
},
},
keys = {
{"<leader>ot", "<cmd>OverseerToggle<cr>", desc = "Toggle Overseer"},
{"<leader>or", "<cmd>OverseerRun<cr>", desc = "Start an Overseer task"},
{"<leader>os", "<cmd>OverseerRunCmd<cr>", desc = "Run a shell command with Overseer"},
{"<leader>ob", "<cmd>OverseerBuild<cr>", desc = "Open the Overseer task builder"},
{"<leader>oo", "<cmd>OverseerOpen<cr>", desc = "Open a window with the output of an Overseer task"},
{"<leader>oa", "<cmd>OverseerTaskAction<cr>", desc = "Add an action to an Overseer task"},
},
}