From 04cbdb51a0e02619e0ca8bc717f1a599560befa5 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 15 Jan 2023 20:48:59 +0100 Subject: Improve synctex; when clicking in the PDF focus the vim window --- vim/.vim/after/ftplugin/tex.vim | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'vim/.vim/after/ftplugin/tex.vim') diff --git a/vim/.vim/after/ftplugin/tex.vim b/vim/.vim/after/ftplugin/tex.vim index de2ec0b..6de2aea 100644 --- a/vim/.vim/after/ftplugin/tex.vim +++ b/vim/.vim/after/ftplugin/tex.vim @@ -1,10 +1,19 @@ setlocal spell spelllang=en_gb setlocal tabstop=2 shiftwidth=2 -function! Synctex() +function! SyncTeXToPDF() call system('zathura --synctex-forward ' . \ line('.') . ':' . col('.') . ':' . shellescape(bufname('%')) . ' ' . \ shellescape(g:synctex_zathura_pdf_filename)) endfunction -map :call Synctex() +function! g:SyncPDFToTeX(input, line) + " Focus the window vim is running in. + exe "silent !i3-msg '[id=\"" . environ()['WINDOWID'] . "\"] focus'" + " Open the file name and jump to the right line. + " Mysteriously, we need `cd .` to fix the file name in the tabline. + " Putting this in one `exe` seems to reduce flickering. + exe 'tab drop ' . a:input . ' | silent ' . a:line . ' | silent cd .' +endfunction + +map :call SyncTeXToPDF() -- cgit v1.2.3