New general callback and expand @line for general_options_latexmk

This allows us to open the file currently where the cursor is, and the
callback lets people implement scripts as they like it to open their
favourite pdf viewer with the line number after compilation. latexmk's
pdf_update_command doesn't let us do that.
This commit is contained in:
Anmol Sethi 2016-02-06 18:08:48 -05:00
parent 74d19dc17d
commit 858dd7afe0
2 changed files with 19 additions and 2 deletions

View File

@ -131,9 +131,18 @@ endfunction
" }}}2
function! s:general.latexmk_append_argument() dict " {{{2
let opts = g:vimtex_view_general_options_latexmk
let opts = substitute(opts, '@line', line('.'), 'g')
return vimtex#latexmk#add_option('pdf_previewer',
\ g:vimtex_view_general_viewer . ' '
\ . g:vimtex_view_general_options_latexmk)
\ . opts)
endfunction
" }}}2
function! s:general.latexmk_callback() dict " {{{2
if exists("g:vimtex_view_general_callback")
exec "call " . g:vimtex_view_general_callback . "(b:vimtex.out())"
endif
endfunction
" }}}2

View File

@ -860,10 +860,18 @@ Options~
Default value: '@pdf'
*g:vimtex_view_general_callback*
Sets the function that is called within |vimtex#latexmk#callback| after compilation
has finished. The function should take one argument, the pdf filename. It
will be empty if it could not be compiled.
Default value: ''
*g:vimtex_view_general_options_latexmk*
Set options that are passed on to `latexmk` for the specified general
viewer, see |vimtex_viewer_general|. This allows to send options that
ensures a unique viewer, e.g. with |vimtex_viewer_qpdfview|.
ensures a unique viewer, e.g. with |vimtex_viewer_qpdfview|. Only the
`@line` escape is expanded.
Default value: ''