aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamil Staps2021-06-15 15:12:06 +0200
committerCamil Staps2021-06-15 15:12:06 +0200
commitbd9cf05d9a2765b731ef579dadd3e1fdf7ecca89 (patch)
tree678ddaac1fc9ad593d7b1425066312b8b4d82111
parentFix synctex setup in .latexmkrc for neovim, which does not have --servername (diff)
Setup forward synctex for vim+zathura
-rw-r--r--vim/.latexmkrc7
-rw-r--r--vim/.vim/after/ftplugin/tex.vim8
2 files changed, 14 insertions, 1 deletions
diff --git a/vim/.latexmkrc b/vim/.latexmkrc
index 2d07232..a36a2ce 100644
--- a/vim/.latexmkrc
+++ b/vim/.latexmkrc
@@ -13,6 +13,7 @@ $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})';
+# SwitchToFileOrOpen switches to a file or opens it if there is no window yet; see .vimrc
$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
@@ -23,7 +24,11 @@ $pdf_previewer .= ' | quit\'"';
$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';
+$pdf_previewer .= 'urxvt -e nvim';
+$pdf_previewer .= ' --cmd "let g:server_name = serverstart(\'$SERVER\')"';
+# this is for forward synctex; see .vim/after/ftplugin/tex.vim
+$pdf_previewer .= ' --cmd "let g:synctex_zathura_pdf_filename = \'%S\'"';
+$pdf_previewer .= ' %T';
push @extra_pdflatex_options, '-synctex=1' ;
push @extra_pdflatex_options, '-halt-on-error' ;
diff --git a/vim/.vim/after/ftplugin/tex.vim b/vim/.vim/after/ftplugin/tex.vim
index aabdc85..de2ec0b 100644
--- a/vim/.vim/after/ftplugin/tex.vim
+++ b/vim/.vim/after/ftplugin/tex.vim
@@ -1,2 +1,10 @@
setlocal spell spelllang=en_gb
setlocal tabstop=2 shiftwidth=2
+
+function! Synctex()
+ call system('zathura --synctex-forward ' .
+ \ line('.') . ':' . col('.') . ':' . shellescape(bufname('%')) . ' ' .
+ \ shellescape(g:synctex_zathura_pdf_filename))
+endfunction
+
+map <C-T> :call Synctex()<CR>