mirror of
https://github.com/Ascyii/nvim.git
synced 2026-01-01 04:04:24 -05:00
auto up 11:48:23 up 3:25, 2 users, load average: 0.17, 0.26, 0.17
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user