Skip to content

Commit

Permalink
feat(view): add g:vimtex_view_automatic_xwin
Browse files Browse the repository at this point in the history
  • Loading branch information
lervag committed Apr 9, 2021
1 parent bc9c0eb commit 8178ade
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
1 change: 1 addition & 0 deletions autoload/vimtex/options.vim
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ function! vimtex#options#init() abort " {{{1

call s:init_option('vimtex_view_enabled', 1)
call s:init_option('vimtex_view_automatic', 1)
call s:init_option('vimtex_view_automatic_xwin', 1)
call s:init_option('vimtex_view_method', 'general')
call s:init_option('vimtex_view_use_temp_files', 0)
call s:init_option('vimtex_view_forward_search_on_start', 1)
Expand Down
4 changes: 3 additions & 1 deletion autoload/vimtex/view/_template_xwin.vim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ function! vimtex#view#_template_xwin#compiler_callback() abort " {{{1
let self = b:vimtex.viewer
if !filereadable(self.out()) | return | endif

if g:vimtex_view_automatic && !has_key(self, 'started_through_callback')
if (g:vimtex_view_automatic
\ && g:vimtex_view_automatic_xwin)
\ && !has_key(self, 'started_through_callback')
"
" Search for existing window created by latexmk
" Note: It may be necessary to wait some time before it is opened and
Expand Down
39 changes: 31 additions & 8 deletions doc/vimtex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2564,17 +2564,39 @@ OPTIONS *vimtex-options*
Default value: 1

*g:vimtex_view_automatic*
If enabled, the viewer will open automatically when compilation has started
in `continuous` mode and if `callback` is enabled, or if `continuous` mode
is disabled.
If enabled, the viewer should open automatically when compilation has
started in `continuous` mode and if `callback` is enabled, or if
`continuous` mode is disabled.

`latexmk` will typically start the viewer directly. However, with this
option enabled, VimTeX will start the viewer through callbacks for these
compilers:
option enabled, VimTeX will start the viewer through callbacks also for
these compilers:
* |vimtex-compiler-latexrun|
* |vimtex-compiler-arara|
* |vimtex-compiler-tectonic|

Note: If you are using |vimtex_viewer_mupdf| or |vimtex_viewer_zathura|,
then you should also be aware of the related option
|g:vimtex_view_automatic_xwin| below.

Default value: 1

*g:vimtex_view_automatic_xwin*
This option is closely related to |g:vimtex_view_automatic|. With the
previous option enabled, the xwin based viewers |vimtex_viewer_mupdf| and
|vimtex_viewer_zathura| will use `xdotool` to check if a viewer was opened
by the compiler. If a viewer window is not found, VimTeX will automatically
start one.

However, the search for a viewer window is implemented with a loop that
calls `xdotool` 30 times with 50 ms interval. If a window is not found, the
search will therefore interrupt the editing session for 1.5 seconds; this
happens on every successful compile callback.

Some users can't use `xdotool`, e.g. on Wayland, but the viewers may still
work quite reliably. In these cases, one may want to disable this automatic
view feature by setting this option to 0.

Default value: 1

*g:vimtex_view_use_temp_files*
Expand Down Expand Up @@ -2748,7 +2770,7 @@ OPTIONS *vimtex-options*
for viewing any PDF file. The VimTeX implementation supports forward
search and uses a callback to update Skim after successful compilations.

Note: One may set |g:vimtex_view_automatic| to 1 if one wants to prevent
Note: One may set |g:vimtex_view_automatic| to 0 if one wants to prevent
`latexmk` (or other build tools) from starting Skim and instead
let VimTeX start Skim through the callback feature.

Expand Down Expand Up @@ -4536,9 +4558,9 @@ LATEXRUN *vimtex-compiler-latexrun*
> format, and generally enables other tools to do what they do best.

`latexrun` is a compiler backend that handles recompilation of LaTeX documents
when source files have been changed. However, it is a much simpler backend,
when source files have been changed. However, it is a much simpler backend,
and does not support e.g. continuous mode and automatic starting of viewers.
The latter is supported by VimTeX, though, through the callback. See
The latter is supported by VimTeX, though, through the callback. See
|g:vimtex_view_automatic|.

The compiler may be configured through the |g:vimtex_compiler_latexrun| option.
Expand Down Expand Up @@ -4806,6 +4828,7 @@ viewer is opened.
Associated settings:
* |g:vimtex_view_enabled|
* |g:vimtex_view_automatic|
* |g:vimtex_view_automatic_xwin|
* |g:vimtex_view_forward_search_on_start|
* |g:vimtex_view_use_temp_files|
* |g:vimtex_view_method|
Expand Down

0 comments on commit 8178ade

Please sign in to comment.