From b1d8de600f18b0e7136929539cb0e76518dd0a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Mon, 26 Sep 2016 22:45:42 +0200 Subject: [PATCH] Added option g:vimtex_view_automatic This makes it possible to disable the automatic opening of viewer window when compilation is started. --- autoload/vimtex/latexmk.vim | 15 +++++++++------ autoload/vimtex/view.vim | 1 + autoload/vimtex/view/common.vim | 2 +- autoload/vimtex/view/mupdf.vim | 13 +++++++------ autoload/vimtex/view/zathura.vim | 12 +++++++----- doc/vimtex.txt | 7 +++++++ 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/autoload/vimtex/latexmk.vim b/autoload/vimtex/latexmk.vim index f7dc0a7..2cbcef7 100644 --- a/autoload/vimtex/latexmk.vim +++ b/autoload/vimtex/latexmk.vim @@ -587,9 +587,17 @@ function! s:latexmk_build_cmd() " {{{1 if g:vimtex_latexmk_continuous let cmd .= ' -pvc' - if get(b:vimtex.viewer, 'xwin_id', 0) > 0 + + " + " Set viewer options + " + if !g:vimtex_view_automatic + \ || get(b:vimtex.viewer, 'xwin_id', 0) > 0 \ || get(s:, 'silence_next_callback', 0) let cmd .= ' -view=none' + elseif g:vimtex_view_enabled + \ && has_key(b:vimtex.viewer, 'latexmk_append_argument') + let cmd .= b:vimtex.viewer.latexmk_append_argument() endif endif @@ -603,11 +611,6 @@ function! s:latexmk_build_cmd() " {{{1 let s:first_callback = 1 endif - if g:vimtex_view_enabled - \ && has_key(b:vimtex.viewer, 'latexmk_append_argument') - let cmd .= b:vimtex.viewer.latexmk_append_argument() - endif - let cmd .= ' ' . vimtex#util#shellescape(b:vimtex.base) if g:vimtex_latexmk_continuous || g:vimtex_latexmk_background diff --git a/autoload/vimtex/view.vim b/autoload/vimtex/view.vim index f2e0055..c91b042 100644 --- a/autoload/vimtex/view.vim +++ b/autoload/vimtex/view.vim @@ -8,6 +8,7 @@ function! vimtex#view#init_options() " {{{1 call vimtex#util#set_default('g:vimtex_view_enabled', 1) if !g:vimtex_view_enabled | return | endif + call vimtex#util#set_default('g:vimtex_view_automatic', 1) call vimtex#util#set_default('g:vimtex_view_method', 'general') call vimtex#util#set_default('g:vimtex_view_use_temp_files', 0) endfunction diff --git a/autoload/vimtex/view/common.vim b/autoload/vimtex/view/common.vim index 7cee10d..1be7dcb 100644 --- a/autoload/vimtex/view/common.vim +++ b/autoload/vimtex/view/common.vim @@ -20,7 +20,7 @@ function! vimtex#view#common#use_temp_files_p(viewer) " {{{1 let a:viewer.copy_files = function('s:copy_files') else let a:viewer.out = b:vimtex.out() - let a:viewer.synctex = b:vimtex.ext('synctex.gz') + let a:viewer.synctex = fnamemodify(a:viewer.out, ':r') . '.synctex.gz' endif return a:viewer diff --git a/autoload/vimtex/view/mupdf.vim b/autoload/vimtex/view/mupdf.vim index 3e8f4d7..d06620d 100644 --- a/autoload/vimtex/view/mupdf.vim +++ b/autoload/vimtex/view/mupdf.vim @@ -127,7 +127,9 @@ function! s:mupdf.latexmk_callback(status) dict " {{{1 if g:vimtex_view_use_temp_files call self.copy_files() - else + endif + + if g:vimtex_view_automatic " " Search for existing window created by latexmk " It may be necessary to wait some time before it is opened and @@ -140,18 +142,17 @@ function! s:mupdf.latexmk_callback(status) dict " {{{1 if self.xwin_exists() | break | endif endfor endif - endif - if !self.xwin_exists() && !has_key(self, 'started_through_callback') - call self.start(self.out) - let self.started_through_callback = 1 + if !self.xwin_exists() && !has_key(self, 'started_through_callback') + call self.start(self.out) + let self.started_through_callback = 1 + endif endif if g:vimtex_view_use_temp_files call self.xwin_send_keys('r') endif - call self.xwin_send_keys(g:vimtex_view_mupdf_send_keys) if has_key(self, 'hook_callback') call self.hook_callback() endif diff --git a/autoload/vimtex/view/zathura.vim b/autoload/vimtex/view/zathura.vim index 4b159fe..c8568fa 100644 --- a/autoload/vimtex/view/zathura.vim +++ b/autoload/vimtex/view/zathura.vim @@ -74,7 +74,9 @@ function! s:zathura.latexmk_callback(status) dict " {{{1 if g:vimtex_view_use_temp_files call self.copy_files() - else + endif + + if g:vimtex_view_automatic " " Search for existing window created by latexmk " It may be necessary to wait some time before it is opened and @@ -87,11 +89,11 @@ function! s:zathura.latexmk_callback(status) dict " {{{1 if self.xwin_exists() | break | endif endfor endif - endif - if !self.xwin_exists() && !has_key(self, 'started_through_callback') - call self.start(self.out) - let self.started_through_callback = 1 + if !self.xwin_exists() && !has_key(self, 'started_through_callback') + call self.start(self.out) + let self.started_through_callback = 1 + endif endif if has_key(self, 'hook_callback') diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 1e3f259..136133e 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -807,6 +807,12 @@ Options~ Default value: 1 +*g:vimtex_view_automatic* + If enabled, the viewer will open automatically when compilation is started + in continuous mode. This is the default behaviour of `latexmk`. + + Default value: 1 + *g:vimtex_view_use_temp_files* If enabled, this will copy output files to a corresponding set of files with `_vimtex` prepended to the name. If one combines this with the callback @@ -1892,6 +1898,7 @@ viewer is opened. Associated settings: |g:vimtex_view_enabled| + |g:vimtex_view_automatic| |g:vimtex_view_method| |g:vimtex_view_use_temp_files| |g:vimtex_view_general_viewer|