tex_zathurasynctex.vim 799 Bytes
Newer Older
1
" SPDX-License-Identifier: Zlib
2

3 4
" This is a sample plugin that can be used for synctex forward synchronization.
" It currently uses latexsuite to obtain the file name of the document. If you
Sebastian Ramacher's avatar
Sebastian Ramacher committed
5 6
" are not using latexsuite, it should be enough to adopt the calculation of
" 'output' accordingly.
7

8
" avoid re-execution
9
if exists("b:did_zathura_synctex_plugin") || !exists("*Tex_GetMainFileName")
10 11 12 13 14 15 16
  finish
endif
let b:did_zathura_synctex_plugin = 1

function! Zathura_SyncTexForward()
  let source = expand("%:p")
  let input = shellescape(line(".").":".col(".").":".source)
17
  let output = Tex_GetMainFileName(":p:r").".pdf"
18 19
  let execstr = "zathura --synctex-forward=".input." ".shellescape(output)
  silent call system(execstr)
20 21
endfunction

22
nmap <buffer> <Leader>f :call Zathura_SyncTexForward()<Enter>