From da40af5a2492be6b72e563976f6f00ff05d8b630 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 20 May 2018 15:32:03 -0400 Subject: try to call synctex a bit less often --- vim/ftplugin/tex.vim | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'vim') diff --git a/vim/ftplugin/tex.vim b/vim/ftplugin/tex.vim index c600070..3a62790 100644 --- a/vim/ftplugin/tex.vim +++ b/vim/ftplugin/tex.vim @@ -30,13 +30,22 @@ function! s:is_running(re) return 0 endfunction -function! Synctex() +function! s:synctex() if s:is_running('^zathura') exe "silent !zathura --synctex-forward " . line('.') . ":" . col('.') . ":" . expand('%:p') . " " . s:current_pdf() redraw endif endfunction +let g:_tex_last_line_seen = -1 +function! s:cursor_moved() + let line = line('.') + if line != g:_tex_last_line_seen + call s:synctex() + endif + let g:_tex_last_line_seen = line +endfunction + " don't load the pdf if the make failed function! s:make_errors() let qf = getqflist() @@ -53,7 +62,7 @@ augroup _tex if executable('zathura') && strlen(expand('$DISPLAY')) autocmd QuickFixCmdPost make if !s:make_errors() | call s:zathura() | endif endif - autocmd CursorMoved call Synctex() + autocmd CursorMoved call s:cursor_moved() augroup END " see :help errorformat-LaTeX -- cgit v1.2.3-54-g00ecf