diff options
author | Camil Staps | 2021-06-15 14:41:37 +0200 |
---|---|---|
committer | Camil Staps | 2021-06-15 14:41:37 +0200 |
commit | 3d9c2336b24a17c5d80012abb2bfbc159a8b14db (patch) | |
tree | 23f4ffb556963d28540bad8bcbe585515e9782d7 /vim/.latexmkrc | |
parent | Add neovim aliases vi and vim (diff) |
Fix synctex setup in .latexmkrc for neovim, which does not have --servername
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' ; |