From 033da30308a8a3959fa64ad17aa690e669775453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Sun, 28 Feb 2016 21:36:53 +0100 Subject: [PATCH] Added latexmk callback hook (#383) --- autoload/vimtex/latexmk.vim | 6 ++++++ doc/vimtex.txt | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/autoload/vimtex/latexmk.vim b/autoload/vimtex/latexmk.vim index 13c3109..a2445a5 100644 --- a/autoload/vimtex/latexmk.vim +++ b/autoload/vimtex/latexmk.vim @@ -13,6 +13,7 @@ function! vimtex#latexmk#init_options() " {{{1 call vimtex#util#set_default('g:vimtex_latexmk_background', 0) call vimtex#util#set_default('g:vimtex_latexmk_callback', 1) + call vimtex#util#set_default('g:vimtex_latexmk_callback_hook', '') call vimtex#util#set_default('g:vimtex_latexmk_continuous', 1) call vimtex#util#set_default('g:vimtex_latexmk_file_line_error', 1) call vimtex#util#set_default('g:vimtex_latexmk_options', '') @@ -105,6 +106,11 @@ function! vimtex#latexmk#callback(status) " {{{1 call vimtex#echo#status(['latexmk compile: ', \ a:status ? ['VimtexSuccess', 'success'] : ['VimtexWarning', 'fail']]) + try + call call(g:vimtex_latexmk_callback_hook, [a:status]) + catch /.*/ + endtry + return '' endfunction diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 55f7a41..219d26f 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -630,6 +630,21 @@ Options~ Default value: 1 +*g:vimtex_latexmk_callback_hook* + If defined and given the name of a function, it will be called from the + vimtex latexmk callback with the status as the sole argument. This allows + users to add custom callback functionality. + + Example: > + + let g:vimtex_latexmk_callback_hook = 'MyTestHook' + + function! MyTestHook(status) + echom a:status + endfunction + +< Default value: '' + *g:vimtex_latexmk_continuous* If enabled, `latexmk` will run in continuous mode, i.e. with the `-pvc` argument. This means that the document is compiled every time a document @@ -1626,6 +1641,7 @@ with |VimtexErrors|. Associated settings: |g:vimtex_latexmk_enabled| |g:vimtex_latexmk_callback| + |g:vimtex_latexmk_callback_hook| |g:vimtex_latexmk_autojump| |g:vimtex_latexmk_continuous| |g:vimtex_latexmk_background|