dotfiles-nvim/lua/overseer/template/typst/watch.lua

30 lines
586 B
Lua
Raw Normal View History

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,
},
}