From 595680ef81e929af91719c7a9417e88e35194131 Mon Sep 17 00:00:00 2001 From: LordMZTE Date: Fri, 15 Nov 2024 16:10:55 +0100 Subject: [PATCH] mzte-nv: implement TypstWatch command --- mzte-nv/conf/ftplugin/typst.fnl | 18 ++++++++++++++++++ mzte-nv/conf/lua/pluginconf/p-tterm.fnl | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mzte-nv/conf/ftplugin/typst.fnl b/mzte-nv/conf/ftplugin/typst.fnl index daa41a8..a7a21fe 100644 --- a/mzte-nv/conf/ftplugin/typst.fnl +++ b/mzte-nv/conf/ftplugin/typst.fnl @@ -1,3 +1,21 @@ ;; Use 2-space indentation for typst (set vim.o.shiftwidth 2) (set vim.o.tabstop 2) + +(let [cb (fn [p] + (let [Terminal (. (require :toggleterm.terminal) :Terminal) + lspc-util (require :lspconfig.util) + file (vim.api.nvim_buf_get_name 0) + outfile (.. :/tmp/ + (string.gsub (vim.fs.basename file) "%.typ$" :.pdf)) + root ((lspc-util.root_pattern :.typstroot) file) + term (Terminal:new {:direction :horizontal + :cmd (if root + (.. "typst watch --root " root + " " file " " outfile) + (.. "typst watch " file " " + outfile))})] + (term:toggle) + (vim.uv.spawn :zathura {:args [outfile]} + (fn [code signal] (term:shutdown)))))] + (vim.api.nvim_create_user_command :TypstWatch cb {:nargs 0})) diff --git a/mzte-nv/conf/lua/pluginconf/p-tterm.fnl b/mzte-nv/conf/lua/pluginconf/p-tterm.fnl index ff8df6f..3c4eeea 100644 --- a/mzte-nv/conf/lua/pluginconf/p-tterm.fnl +++ b/mzte-nv/conf/lua/pluginconf/p-tterm.fnl @@ -1,3 +1,3 @@ (local tterm (require :toggleterm)) -(tterm.setup {:size 64 :open_mapping : :direction :vertical}) +(tterm.setup {:open_mapping : :direction :vertical})