mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 12:46:00 +01:00
Just support latexsuite for now
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
b6af22c525
commit
c64b4f545a
1 changed files with 6 additions and 37 deletions
|
@ -1,50 +1,19 @@
|
||||||
" See LICENSE file for license and copyright information
|
" See LICENSE file for license and copyright information
|
||||||
|
|
||||||
|
" 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
|
||||||
|
" are not using latexsuite, it should be enough to adopt output accordingly.
|
||||||
|
|
||||||
" avoid re-execution
|
" avoid re-execution
|
||||||
if exists("b:did_zathura_synctex_plugin")
|
if exists("b:did_zathura_synctex_plugin") || !exists("*Tex_GetMainFileName")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let b:did_zathura_synctex_plugin = 1
|
let b:did_zathura_synctex_plugin = 1
|
||||||
|
|
||||||
" set up global variables
|
|
||||||
if !exists("g:zathura_synctex_latex_suite")
|
|
||||||
let g:zathura_synctex_latex_suite = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
function! Zathura_SyncTexForward()
|
function! Zathura_SyncTexForward()
|
||||||
let source = expand("%:p")
|
let source = expand("%:p")
|
||||||
let input = shellescape(line(".").":".col(".").":".source)
|
let input = shellescape(line(".").":".col(".").":".source)
|
||||||
let output = "<none>"
|
let output = Tex_GetMainFileName(":p:r").".pdf"
|
||||||
if exists("*Tex_GetMainFileName") && g:zathura_synctex_latex_suite == 1
|
|
||||||
" use Tex_GetMainFileName from latex-suite if it is available
|
|
||||||
let output = Tex_GetMainFileName(":p:r").".pdf"
|
|
||||||
else
|
|
||||||
" try to find synctex files and use them to determine the output file
|
|
||||||
let synctex_files = split(glob("%:p:h/*.synctex.gz"), "\n")
|
|
||||||
if len(synctex_files) == 0
|
|
||||||
echo "No synctex file found"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let found = 0
|
|
||||||
for synctex in synctex_files
|
|
||||||
let pdffile = substitute(synctex, "synctex.gz", "pdf", "")
|
|
||||||
let out = system("synctex view -i ".input." -o ".shellescape(pdffile))
|
|
||||||
if match(out, "No tag for ".source) >= 0
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
let found = 1
|
|
||||||
let output = pdffile
|
|
||||||
break
|
|
||||||
endfor
|
|
||||||
|
|
||||||
if found == 0
|
|
||||||
echo "No synctex file containing reference to source file found"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
let execstr = "zathura --synctex-forward=".input." ".shellescape(output)
|
let execstr = "zathura --synctex-forward=".input." ".shellescape(output)
|
||||||
silent call system(execstr)
|
silent call system(execstr)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
Loading…
Reference in a new issue