Minor improvements to feature added in #346

This commit is contained in:
Karl Yngve Lervåg 2016-02-07 12:48:40 +01:00
parent 86916a6673
commit dfbe3f0c4b
2 changed files with 15 additions and 14 deletions

View File

@ -98,6 +98,10 @@ function! s:general.init() dict " {{{2
call vimtex#util#set_default('g:vimtex_view_general_options', '@pdf')
call vimtex#util#set_default('g:vimtex_view_general_options_latexmk', '')
if exists('g:vimtex_view_general_callback')
let self.latexmk_callback = function(g:vimtex_view_general_callback)
endif
if !executable(g:vimtex_view_general_viewer)
echoerr 'vimtex viewer is not executable!'
echoerr 'g:vimtex_view_general_viewer = '
@ -131,18 +135,12 @@ 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 . ' '
\ . 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())"
let l:option = g:vimtex_view_general_viewer
if !empty(g:vimtex_view_general_options_latexmk)
let l:option .= ' ' . substitute(g:vimtex_view_general_options_latexmk,
\ '@line', line('.'), 'g')
endif
return vimtex#latexmk#add_option('pdf_previewer', l:option)
endfunction
" }}}2

View File

@ -861,9 +861,12 @@ 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.
Sets the name of a function that is called within |vimtex#latexmk#callback|
after compilation has finished. The function does not take any arguments,
instead it can use the `b:vimtex` variable directly, e.g. the pdf file is
available as `b:vimtex.out()`. The function is part of the viewer
dictionary, and as such it may be defined with the |func-dict| argument. See
the source for the reference of the viewer dictionary.
Default value: ''