From fc2f333223ca140d0be49f2e17b0f0661505c062 Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Sun, 27 Aug 2023 10:59:48 -0400 Subject: [PATCH] nvim: typst auto root finding --- src/.config/nvim/ftplugin/typst.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/.config/nvim/ftplugin/typst.vim b/src/.config/nvim/ftplugin/typst.vim index 6b81002..e65673f 100644 --- a/src/.config/nvim/ftplugin/typst.vim +++ b/src/.config/nvim/ftplugin/typst.vim @@ -17,13 +17,18 @@ function ScreenshotFig() endf nnoremap fs :call ScreenshotFig() +function GitRoot() + return fnamemodify(finddir('.git', ";"), ":h") +endfunc + " compile typst doc on write function TypstWatch() vsp vertical resize 20 - exec 'terminal ' .. 'typst watch ' .. expand("%:") + exec 'terminal ' .. 'typst watch --root ' .. GitRoot() .. " " .. expand("%:") exec "norm \h" endfunc + nnoremap fc :call TypstWatch() nnoremap fr :silent exec "!zathura --fork " . expand("%:p:r") . ".pdf &"