feat(overseer): Add templates for compiling and watching typst files
This commit is contained in:
parent
3ae9e70c4d
commit
ec74c2d18f
22
lua/overseer/template/typst/compile.lua
Normal file
22
lua/overseer/template/typst/compile.lua
Normal 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,
|
||||||
|
},
|
||||||
|
}
|
29
lua/overseer/template/typst/watch.lua
Normal file
29
lua/overseer/template/typst/watch.lua
Normal 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,
|
||||||
|
},
|
||||||
|
}
|
|
@ -1,6 +1,11 @@
|
||||||
return {
|
return {
|
||||||
'stevearc/overseer.nvim',
|
'stevearc/overseer.nvim',
|
||||||
opts = {},
|
opts = {
|
||||||
|
templates = {
|
||||||
|
"typst.watch",
|
||||||
|
"typst.compile",
|
||||||
|
},
|
||||||
|
},
|
||||||
keys = {
|
keys = {
|
||||||
{"<leader>ot", "<cmd>OverseerToggle<cr>", desc = "Toggle Overseer"},
|
{"<leader>ot", "<cmd>OverseerToggle<cr>", desc = "Toggle Overseer"},
|
||||||
{"<leader>or", "<cmd>OverseerRun<cr>", desc = "Start an Overseer task"},
|
{"<leader>or", "<cmd>OverseerRun<cr>", desc = "Start an Overseer task"},
|
||||||
|
|
Loading…
Reference in a new issue