Added option g:vimtex_view_automatic

This makes it possible to disable the automatic opening of viewer
window when compilation is started.
This commit is contained in:
Karl Yngve Lervåg 2016-09-26 22:45:42 +02:00
parent 87e186b4ab
commit b1d8de600f
6 changed files with 32 additions and 18 deletions

View File

@ -587,9 +587,17 @@ function! s:latexmk_build_cmd() " {{{1
if g:vimtex_latexmk_continuous if g:vimtex_latexmk_continuous
let cmd .= ' -pvc' 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) \ || get(s:, 'silence_next_callback', 0)
let cmd .= ' -view=none' 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
endif endif
@ -603,11 +611,6 @@ function! s:latexmk_build_cmd() " {{{1
let s:first_callback = 1 let s:first_callback = 1
endif 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) let cmd .= ' ' . vimtex#util#shellescape(b:vimtex.base)
if g:vimtex_latexmk_continuous || g:vimtex_latexmk_background if g:vimtex_latexmk_continuous || g:vimtex_latexmk_background

View File

@ -8,6 +8,7 @@ function! vimtex#view#init_options() " {{{1
call vimtex#util#set_default('g:vimtex_view_enabled', 1) call vimtex#util#set_default('g:vimtex_view_enabled', 1)
if !g:vimtex_view_enabled | return | endif 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_method', 'general')
call vimtex#util#set_default('g:vimtex_view_use_temp_files', 0) call vimtex#util#set_default('g:vimtex_view_use_temp_files', 0)
endfunction endfunction

View File

@ -20,7 +20,7 @@ function! vimtex#view#common#use_temp_files_p(viewer) " {{{1
let a:viewer.copy_files = function('s:copy_files') let a:viewer.copy_files = function('s:copy_files')
else else
let a:viewer.out = b:vimtex.out() 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 endif
return a:viewer return a:viewer

View File

@ -127,7 +127,9 @@ function! s:mupdf.latexmk_callback(status) dict " {{{1
if g:vimtex_view_use_temp_files if g:vimtex_view_use_temp_files
call self.copy_files() call self.copy_files()
else endif
if g:vimtex_view_automatic
" "
" Search for existing window created by latexmk " Search for existing window created by latexmk
" It may be necessary to wait some time before it is opened and " 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 if self.xwin_exists() | break | endif
endfor endfor
endif endif
endif
if !self.xwin_exists() && !has_key(self, 'started_through_callback') if !self.xwin_exists() && !has_key(self, 'started_through_callback')
call self.start(self.out) call self.start(self.out)
let self.started_through_callback = 1 let self.started_through_callback = 1
endif endif
endif
if g:vimtex_view_use_temp_files if g:vimtex_view_use_temp_files
call self.xwin_send_keys('r') call self.xwin_send_keys('r')
endif endif
call self.xwin_send_keys(g:vimtex_view_mupdf_send_keys)
if has_key(self, 'hook_callback') if has_key(self, 'hook_callback')
call self.hook_callback() call self.hook_callback()
endif endif

View File

@ -74,7 +74,9 @@ function! s:zathura.latexmk_callback(status) dict " {{{1
if g:vimtex_view_use_temp_files if g:vimtex_view_use_temp_files
call self.copy_files() call self.copy_files()
else endif
if g:vimtex_view_automatic
" "
" Search for existing window created by latexmk " Search for existing window created by latexmk
" It may be necessary to wait some time before it is opened and " It may be necessary to wait some time before it is opened and
@ -87,12 +89,12 @@ function! s:zathura.latexmk_callback(status) dict " {{{1
if self.xwin_exists() | break | endif if self.xwin_exists() | break | endif
endfor endfor
endif endif
endif
if !self.xwin_exists() && !has_key(self, 'started_through_callback') if !self.xwin_exists() && !has_key(self, 'started_through_callback')
call self.start(self.out) call self.start(self.out)
let self.started_through_callback = 1 let self.started_through_callback = 1
endif endif
endif
if has_key(self, 'hook_callback') if has_key(self, 'hook_callback')
call self.hook_callback() call self.hook_callback()

View File

@ -807,6 +807,12 @@ Options~
Default value: 1 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* *g:vimtex_view_use_temp_files*
If enabled, this will copy output files to a corresponding set of 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 with `_vimtex` prepended to the name. If one combines this with the callback
@ -1892,6 +1898,7 @@ viewer is opened.
Associated settings: Associated settings:
|g:vimtex_view_enabled| |g:vimtex_view_enabled|
|g:vimtex_view_automatic|
|g:vimtex_view_method| |g:vimtex_view_method|
|g:vimtex_view_use_temp_files| |g:vimtex_view_use_temp_files|
|g:vimtex_view_general_viewer| |g:vimtex_view_general_viewer|