diff options
Diffstat (limited to 'vim/.latexmkrc')
-rw-r--r-- | vim/.latexmkrc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/vim/.latexmkrc b/vim/.latexmkrc index ce212c3..2d07232 100644 --- a/vim/.latexmkrc +++ b/vim/.latexmkrc @@ -1,6 +1,29 @@ +# vim: ft=perl: $pdf_mode = 1; -$pdf_previewer = 'SERVER=`md5sum %T`; zathura -x "vim --servername \'$SERVER\' --remote-tab +%{line} %{input}" %S & urxvt -e vim --servername "$SERVER" %T'; +# With the following, `latexmk -pvc jobname.tex` opens a zathura instance for +# the generated PDF alongside an nvim editor, and sets up synctex from zathura +# to vim. + +# create a vim rpc socket based on the filename +$pdf_previewer = 'SERVER=/tmp/vim-latexmk-`md5sum %T | cut -d\' \' -f1`;'; + +# zathura for viewing +$pdf_previewer .= 'zathura'; +# -x for synctex: connect to the rpc socket, switch to the file and jump to the line +$pdf_previewer .= ' -x "nvim --headless --cmd'; +$pdf_previewer .= ' \'let skt=sockconnect(\\"pipe\\",\\"$SERVER\\",{\\"rpc\\":1})'; +$pdf_previewer .= ' | call rpcrequest(skt,\\"nvim_command\\",\\"SwitchToFileOrOpen %{input}\\")'; +$pdf_previewer .= ' | call rpcrequest(skt,\\"nvim_command\\",\\"%{line}\\")'; +# mysteriously, we need `cd .` to fix the file name in the tabline +$pdf_previewer .= ' | call rpcrequest(skt,\\"nvim_command\\",\\"cd .\\")'; +$pdf_previewer .= ' | call chanclose(skt)'; +$pdf_previewer .= ' | quit\'"'; +# final argument for zathura is the PDF +$pdf_previewer .= ' %S &'; + +# nvim for editing; start up the server as part of the command line +$pdf_previewer .= 'urxvt -e nvim --cmd "let g:server_name = serverstart(\'$SERVER\')" %T'; push @extra_pdflatex_options, '-synctex=1' ; push @extra_pdflatex_options, '-halt-on-error' ; |