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