auto up 11:48:23 up 3:25, 2 users, load average: 0.17, 0.26, 0.17

This commit is contained in:
2025-11-14 11:48:23 +01:00
parent b467a414c4
commit ea0b19b71a
2 changed files with 93 additions and 63 deletions

View File

@@ -77,4 +77,26 @@ function M.watch_and_open()
})
end
function M.just_open()
-- Parse the current file and check for typst
local input = vim.fn.expand("%:p")
if not input:match("%.typ$") then
vim.notify("Not a Typst file", vim.log.levels.WARN)
return
end
local dir = vim.fn.fnamemodify(input, ":h") -- directory of the Typst file
local filename = vim.fn.expand("%:t:r") .. ".pdf" -- filename without extension + .pdf
local output = dir .. "/" .. filename
-- Start typst watch
local cwd = vim.fn.getcwd() -- set the starting directory
-- TODO: root setting does not work
local watch_cmd = { "typst", "compile", "--root", cwd, input, output }
vim.fn.jobstart(watch_cmd)
functions.sleep(0.5)
vim.fn.jobstart({ "sioyek", output })
end
return M

View File

@@ -25,6 +25,14 @@ return {
{ "<leader>tw", function() require("custom.typst").watch_and_open() end, desc = "Watch Typst" },
},
},
{
dir = get_custom_dir("typst"),
name = "typst",
dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" },
keys = {
{ "<leader>tu", function() require("custom.typst").just_open() end, desc = "Open Typst" },
},
},
{
dir = get_custom_dir("journal"),
name = "journal",