Use generic interface for generic viewers
This update removes the viewers qpdfview sumatrapdf skim okular from the possible g:vimtex_view_method values. Instead, these viewers may now be defined with the `general` view method using the options g:vimtex_view_general_viewer g:vimtex_view_general_options g:vimtex_view_general_options_latexmk Resolves: #180
This commit is contained in:
parent
b29b91affc
commit
22eabfe48e
@ -7,10 +7,6 @@
|
|||||||
let s:viewers = [
|
let s:viewers = [
|
||||||
\ 'general',
|
\ 'general',
|
||||||
\ 'mupdf',
|
\ 'mupdf',
|
||||||
\ 'okular',
|
|
||||||
\ 'qpdfview',
|
|
||||||
\ 'skim',
|
|
||||||
\ 'sumatrapdf',
|
|
||||||
\ 'zathura',
|
\ 'zathura',
|
||||||
\ ]
|
\ ]
|
||||||
for viewer in s:viewers
|
for viewer in s:viewers
|
||||||
@ -38,6 +34,8 @@ function! vimtex#view#init_buffer() " {{{1
|
|||||||
let viewer = 's:' . g:vimtex_view_method
|
let viewer = 's:' . g:vimtex_view_method
|
||||||
if !exists(viewer)
|
if !exists(viewer)
|
||||||
echoerr 'vimtex viewer ' . g:vimtex_view_method . ' does not exist!'
|
echoerr 'vimtex viewer ' . g:vimtex_view_method . ' does not exist!'
|
||||||
|
echo "\nPlease see :h g:vimtex_view_method\n\n"
|
||||||
|
let b:vimtex.viewer = {}
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
execute 'let b:vimtex.viewer = ' . viewer
|
execute 'let b:vimtex.viewer = ' . viewer
|
||||||
@ -88,12 +86,14 @@ function! s:general.init() dict " {{{2
|
|||||||
"
|
"
|
||||||
" Set default options
|
" Set default options
|
||||||
"
|
"
|
||||||
|
|
||||||
call vimtex#util#set_default_os_specific('g:vimtex_view_general_viewer',
|
call vimtex#util#set_default_os_specific('g:vimtex_view_general_viewer',
|
||||||
\ {
|
\ {
|
||||||
\ 'linux' : 'xdg-open',
|
\ 'linux' : 'xdg-open',
|
||||||
\ 'mac' : 'open',
|
\ 'mac' : 'open',
|
||||||
\ })
|
\ })
|
||||||
call vimtex#util#set_default('g:vimtex_view_general_options', '')
|
call vimtex#util#set_default('g:vimtex_view_general_options', '@pdf')
|
||||||
|
call vimtex#util#set_default('g:vimtex_view_general_options_latexmk', '')
|
||||||
|
|
||||||
if !executable(g:vimtex_view_general_viewer)
|
if !executable(g:vimtex_view_general_viewer)
|
||||||
echoerr 'vimtex viewer is not executable!'
|
echoerr 'vimtex viewer is not executable!'
|
||||||
@ -107,10 +107,17 @@ function! s:general.view(file) dict " {{{2
|
|||||||
let outfile = a:file !=# '' ? a:file : b:vimtex.out()
|
let outfile = a:file !=# '' ? a:file : b:vimtex.out()
|
||||||
if s:output_not_readable(outfile) | return | endif
|
if s:output_not_readable(outfile) | return | endif
|
||||||
|
|
||||||
|
" Parse options
|
||||||
|
let opts = g:vimtex_view_general_options
|
||||||
|
let opts = substitute(opts, '@line', line('.'), 'g')
|
||||||
|
let opts = substitute(opts, '@col', col('.'), 'g')
|
||||||
|
let opts = substitute(opts, '@tex',
|
||||||
|
\ vimtex#util#fnameescape(expand('%:p')), 'g')
|
||||||
|
let opts = substitute(opts, '@pdf', vimtex#util#fnameescape(outfile), 'g')
|
||||||
|
|
||||||
|
" Construct the command
|
||||||
let exe = {}
|
let exe = {}
|
||||||
let exe.cmd = g:vimtex_view_general_viewer
|
let exe.cmd = g:vimtex_view_general_viewer . ' ' . opts
|
||||||
let exe.cmd .= ' ' . g:vimtex_view_general_options
|
|
||||||
let exe.cmd .= ' ' . vimtex#util#fnameescape(outfile)
|
|
||||||
call vimtex#util#execute(exe)
|
call vimtex#util#execute(exe)
|
||||||
let self.cmd_view = exe.cmd
|
let self.cmd_view = exe.cmd
|
||||||
|
|
||||||
@ -121,12 +128,9 @@ endfunction
|
|||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
function! s:general.latexmk_append_argument() dict " {{{2
|
function! s:general.latexmk_append_argument() dict " {{{2
|
||||||
let cmd = vimtex#latexmk#add_option('new_viewer_always', '0')
|
return vimtex#latexmk#add_option('pdf_previewer', 'start '
|
||||||
let cmd .= vimtex#latexmk#add_option('pdf_update_method', '0')
|
|
||||||
let cmd .= vimtex#latexmk#add_option('pdf_previewer', 'start '
|
|
||||||
\ . g:vimtex_view_general_viewer . ' '
|
\ . g:vimtex_view_general_viewer . ' '
|
||||||
\ . g:vimtex_view_general_options)
|
\ . g:vimtex_view_general_options_latexmk)
|
||||||
return cmd
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
@ -287,123 +291,6 @@ endfunction
|
|||||||
|
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
" {{{1 Okular
|
|
||||||
function! s:okular.init() dict " {{{2
|
|
||||||
call vimtex#util#set_default('g:vimtex_view_okular_options', '')
|
|
||||||
|
|
||||||
if !executable('okular')
|
|
||||||
echoerr 'vimtex viewer Okular is not executable!'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}2
|
|
||||||
function! s:okular.view(file) dict " {{{2
|
|
||||||
let outfile = a:file !=# '' ? a:file : b:vimtex.out()
|
|
||||||
if s:output_not_readable(outfile) | return | endif
|
|
||||||
|
|
||||||
let exe = {}
|
|
||||||
let exe.cmd = 'okular ' . g:vimtex_view_okular_options
|
|
||||||
let exe.cmd .= ' --unique ' . vimtex#util#fnameescape(outfile)
|
|
||||||
let exe.cmd .= '\#src:' . line('.') . vimtex#util#fnameescape(expand('%:p'))
|
|
||||||
call vimtex#util#execute(exe)
|
|
||||||
let self.cmd_view = exe.cmd
|
|
||||||
|
|
||||||
if has_key(self, 'hook_view')
|
|
||||||
call self.hook_view()
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}2
|
|
||||||
|
|
||||||
" {{{1 qpdfview
|
|
||||||
function! s:qpdfview.init() dict " {{{2
|
|
||||||
call vimtex#util#set_default('g:vimtex_view_qpdfview_options', '')
|
|
||||||
|
|
||||||
if !executable('qpdfview')
|
|
||||||
echoerr 'vimtex viewer qpdfview is not executable!'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}2
|
|
||||||
function! s:qpdfview.view(file) dict " {{{2
|
|
||||||
let outfile = a:file !=# '' ? a:file : b:vimtex.out()
|
|
||||||
if s:output_not_readable(outfile) | return | endif
|
|
||||||
|
|
||||||
let exe = {}
|
|
||||||
let exe.cmd = 'qpdfview ' . g:vimtex_view_qpdfview_options
|
|
||||||
let exe.cmd .= ' --unique ' . vimtex#util#fnameescape(outfile)
|
|
||||||
let exe.cmd .= '\#src:' . vimtex#util#fnameescape(expand('%:p'))
|
|
||||||
let exe.cmd .= ':' . line('.')
|
|
||||||
let exe.cmd .= ':' . col('.')
|
|
||||||
call vimtex#util#execute(exe)
|
|
||||||
let self.cmd_view = exe.cmd
|
|
||||||
|
|
||||||
if has_key(self, 'hook_view')
|
|
||||||
call self.hook_view()
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}2
|
|
||||||
|
|
||||||
" {{{1 Skim
|
|
||||||
function! s:skim.init() dict " {{{2
|
|
||||||
call vimtex#util#set_default('g:vimtex_view_skim_options', '')
|
|
||||||
|
|
||||||
if !executable('/Applications/Skim.app/Contents/SharedSupport/displayline')
|
|
||||||
echoerr 'vimtex viewer Skim is not executable!'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}2
|
|
||||||
function! s:skim.view(file) dict " {{{2
|
|
||||||
let outfile = a:file !=# '' ? a:file : b:vimtex.out()
|
|
||||||
if s:output_not_readable(outfile) | return | endif
|
|
||||||
|
|
||||||
let exe = {}
|
|
||||||
let exe.cmd = '/Applications/Skim.app/Contents/SharedSupport/displayline'
|
|
||||||
let exe.cmd .= ' ' . g:vimtex_view_skim_options
|
|
||||||
let exe.cmd .= ' ' . line('.')
|
|
||||||
let exe.cmd .= ' ' . vimtex#util#fnameescape(outfile)
|
|
||||||
let exe.cmd .= ' ' . vimtex#util#fnameescape(expand('%:p'))
|
|
||||||
call vimtex#util#execute(exe)
|
|
||||||
let self.cmd_view = exe.cmd
|
|
||||||
|
|
||||||
if has_key(self, 'hook_view')
|
|
||||||
call self.hook_view()
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}2
|
|
||||||
|
|
||||||
" {{{1 SumatraPDF
|
|
||||||
function! s:sumatrapdf.init() dict " {{{2
|
|
||||||
call vimtex#util#set_default('g:vimtex_view_sumatrapdf_options', '')
|
|
||||||
|
|
||||||
if !executable('SumatraPDF')
|
|
||||||
echoerr 'vimtex viewer SumatraPDF is not executable!'
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}2
|
|
||||||
function! s:sumatrapdf.view(file) dict " {{{2
|
|
||||||
let outfile = a:file !=# '' ? a:file : b:vimtex.out()
|
|
||||||
if s:output_not_readable(outfile) | return | endif
|
|
||||||
|
|
||||||
let exe = {}
|
|
||||||
let exe.cmd = 'SumatraPDF ' . g:vimtex_view_sumatrapdf_options
|
|
||||||
let exe.cmd .= ' -forward-search ' . vimtex#util#fnameescape(expand('%:p'))
|
|
||||||
let exe.cmd .= ' ' . line('.')
|
|
||||||
let exe.cmd .= ' ' . vimtex#util#fnameescape(outfile)
|
|
||||||
call vimtex#util#execute(exe)
|
|
||||||
let self.cmd_view = exe.cmd
|
|
||||||
|
|
||||||
if has_key(self, 'hook_view')
|
|
||||||
call self.hook_view()
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}2
|
|
||||||
|
|
||||||
" {{{1 Zathura
|
" {{{1 Zathura
|
||||||
function! s:zathura.init() dict " {{{2
|
function! s:zathura.init() dict " {{{2
|
||||||
" Only initialize once
|
" Only initialize once
|
||||||
|
145
doc/vimtex.txt
145
doc/vimtex.txt
@ -586,15 +586,78 @@ Options~
|
|||||||
Default value: 1
|
Default value: 1
|
||||||
|
|
||||||
*g:vimtex_view_method*
|
*g:vimtex_view_method*
|
||||||
Set the viewer method. The supported viewers are listed below. Please see
|
Set the viewer method. The general viewer |vimtex_viewer_general| defines
|
||||||
|vimtex-synctex| for explanations of the terms 'forward search' and
|
a generic interface that allows sufficient customization for most viewer
|
||||||
'backward search'.
|
applications. However, a few applications require some special attention,
|
||||||
|
and so |vimtex| provides a couple of custom viewers: |vimtex_viewer_mupdf| and
|
||||||
|
|vimtex_viewer_zathura|.
|
||||||
|
|
||||||
general~
|
Possible values:
|
||||||
This is a basic interface where the viewer can be specified through
|
'general' (default)
|
||||||
|g:vimtex_view_general_viewer|.
|
'mupdf'
|
||||||
|
'zathura'
|
||||||
|
|
||||||
mupdf~
|
*vimtex_viewer_general*
|
||||||
|
This is a generic interface where the viewer application is specified
|
||||||
|
through |g:vimtex_view_general_viewer| and the viewer options are given
|
||||||
|
with |g:vimtex_view_general_options|. After successful compilation with
|
||||||
|
`latexmk`, the viewer is started with the options provided by
|
||||||
|
|g:vimtex_view_general_options_latexmk|. The interface allows the
|
||||||
|
general viewer to support forward search with a lot of different
|
||||||
|
applications:
|
||||||
|
|
||||||
|
*vimtex_viewer_okular*
|
||||||
|
https://okular.kde.org/
|
||||||
|
Okular is a very feature rich PDF viewer that supports forward
|
||||||
|
and backward search. Backward search must be set up from the
|
||||||
|
viewer. >
|
||||||
|
|
||||||
|
let g:vimtex_view_general_viewer = 'okular'
|
||||||
|
let g:vimtex_view_general_options = '--unique @pdf\#src:@line@tex'
|
||||||
|
let g:vimtex_view_general_options_latexmk = '--unique'
|
||||||
|
<
|
||||||
|
*vimtex_viewer_qpdfview*
|
||||||
|
https://launchpad.net/qpdfview
|
||||||
|
qpdfview is a tabbed document viewer. It supports forward search.
|
||||||
|
Backward search must be set up from the viewer. >
|
||||||
|
|
||||||
|
let g:vimtex_view_general_viewer = 'qpdfview'
|
||||||
|
let g:vimtex_view_general_options = '--unique @pdf\#src:@tex:@line:@col'
|
||||||
|
let g:vimtex_view_general_options_latexmk = '--unique'
|
||||||
|
<
|
||||||
|
*vimtex_viewer_skim*
|
||||||
|
http://skim-app.sourceforge.net/
|
||||||
|
Skim is a PDF reader and note-taker for OS X. It is designed to help
|
||||||
|
you read and annotate scientific papers in PDF, but is also great
|
||||||
|
for viewing any PDF file. >
|
||||||
|
|
||||||
|
let g:vimtex_view_general_viewer
|
||||||
|
\ = '/Applications/Skim.app/Contents/SharedSupport/displayline'
|
||||||
|
let g:vimtex_view_general_options = '@line @pdf @tex'
|
||||||
|
<
|
||||||
|
*vimtex_viewer_sumatrapdf*
|
||||||
|
http://www.sumatrapdfreader.org/free-pdf-reader.html
|
||||||
|
SumatraPDF is a PDF viewer for windows that is powerful, small,
|
||||||
|
portable and starts up very fast. It supports forward search.
|
||||||
|
Backward search must be set up from the viewer. >
|
||||||
|
|
||||||
|
let g:vimtex_view_general_viewer = 'SumatraPDF'
|
||||||
|
let g:vimtex_view_general_options = '-forward-search @tex @line @pdf'
|
||||||
|
let g:vimtex_view_general_options_latexmk = '-reuse-instance'
|
||||||
|
<
|
||||||
|
Note: It is possible to set up inverse search for SumatraPDF through
|
||||||
|
the command line. This can be utilized to set the correct
|
||||||
|
|servername| for inverse search: >
|
||||||
|
|
||||||
|
let g:vimtex_view_general_viewer = 'SumatraPDF -reuse-instance '
|
||||||
|
\ . '-inverse-search "gvim --servername ' . v:servername
|
||||||
|
\ . ' --remote-send \"^<C-\^>^<C-n^>'
|
||||||
|
\ . ':drop \%f^<CR^>:\%l^<CR^>:normal\! zzzv^<CR^>'
|
||||||
|
\ . ':execute ''drop '' . fnameescape(''\%f'')^<CR^>'
|
||||||
|
\ . ':\%l^<CR^>:normal\! zzzv^<CR^>'
|
||||||
|
\ . ':call remote_foreground('''.v:servername.''')^<CR^>\""'
|
||||||
|
<
|
||||||
|
*vimtex_viewer_mupdf*
|
||||||
http://www.mupdf.com/
|
http://www.mupdf.com/
|
||||||
A very minimalistic and quick PDF viewer. Supports forward and backward
|
A very minimalistic and quick PDF viewer. Supports forward and backward
|
||||||
search. Backward search is available with |VimtexRSearch|, which is
|
search. Backward search is available with |VimtexRSearch|, which is
|
||||||
@ -606,38 +669,7 @@ Options~
|
|||||||
search will take you to the line in Vim that corresponds to the
|
search will take you to the line in Vim that corresponds to the
|
||||||
first line of the current page in MuPDF.
|
first line of the current page in MuPDF.
|
||||||
|
|
||||||
okular~
|
*vimtex_viewer_zathura*
|
||||||
https://okular.kde.org/
|
|
||||||
A very feature rich PDF viewer. Supports forward search. Backward
|
|
||||||
search must be set up from the viewer.
|
|
||||||
|
|
||||||
qpdfview~
|
|
||||||
https://launchpad.net/qpdfview
|
|
||||||
A tabbed document viewer. Supports forward search. Backward search
|
|
||||||
must be set up from the viewer.
|
|
||||||
|
|
||||||
sumatrapdf~
|
|
||||||
http://www.sumatrapdfreader.org/free-pdf-reader.html
|
|
||||||
SumatraPDF is a PDF viewer for windows that is powerful, small, portable
|
|
||||||
and starts up very fast. It supports forward search. Backward search
|
|
||||||
must be set up from the viewer.
|
|
||||||
|
|
||||||
Note: It is possible to set up inverse search for SumatraPDF through the
|
|
||||||
command line. This can be utilized to improve the current
|
|
||||||
implementation in order to set the correct |servername| for
|
|
||||||
inverse search. At the moment, this is not implemented. However,
|
|
||||||
one can achieve the functionality by using the general viewer with
|
|
||||||
the following setting: >
|
|
||||||
|
|
||||||
let g:vimtex_view_general_viewer = 'SumatraPDF -reuse-instance '
|
|
||||||
\ . '-inverse-search "gvim --servername ' . v:servername
|
|
||||||
\ . ' --remote-send \"^<C-\^>^<C-n^>'
|
|
||||||
\ . ':drop \%f^<CR^>:\%l^<CR^>:normal\! zzzv^<CR^>'
|
|
||||||
\ . ':execute ''drop '' . fnameescape(''\%f'')^<CR^>'
|
|
||||||
\ . ':\%l^<CR^>:normal\! zzzv^<CR^>'
|
|
||||||
\ . ':call remote_foreground('''.v:servername.''')^<CR^>\""'
|
|
||||||
<
|
|
||||||
zathura~
|
|
||||||
https://pwmt.org/projects/zathura/
|
https://pwmt.org/projects/zathura/
|
||||||
Zathura is like MuPDF a very fast and minimalistic viewer, but it allows
|
Zathura is like MuPDF a very fast and minimalistic viewer, but it allows
|
||||||
more user configuration. Zathura supports forward search and backward
|
more user configuration. Zathura supports forward search and backward
|
||||||
@ -646,21 +678,38 @@ Options~
|
|||||||
Note: Forward search requires `xdotool` to work properly, in order to
|
Note: Forward search requires `xdotool` to work properly, in order to
|
||||||
not open a new Zathura instance for invocation of |VimtexView|.
|
not open a new Zathura instance for invocation of |VimtexView|.
|
||||||
|
|
||||||
If one chooses a method that is not the default method, then the viewer will
|
|
||||||
support forward search, see |vimtex-synctex-forward-search|.
|
|
||||||
|
|
||||||
Default value: 'general'
|
|
||||||
|
|
||||||
*g:vimtex_view_general_viewer*
|
*g:vimtex_view_general_viewer*
|
||||||
Use a general viewer.
|
Use generic viewer application, see |vimtex_viewer_general|.
|
||||||
|
|
||||||
Default value:
|
Default value:
|
||||||
Linux: `xdg-open`
|
Linux: `xdg-open`
|
||||||
Mac: `open`
|
Mac: `open`
|
||||||
|
|
||||||
*g:vimtex_view_<viewer>_options*
|
*g:vimtex_view_general_options*
|
||||||
Set custom options for the given viewer. See |g:vimtex_view_method| for
|
Set options for the specified general viewer, see |vimtex_viewer_general|.
|
||||||
a list of possible viewers.
|
The options are parsed to substitute the following keywords:
|
||||||
|
|
||||||
|
`@pdf` Path to pdf file
|
||||||
|
`@tex` Path to tex file
|
||||||
|
`@line` Current line number
|
||||||
|
`@col` Current column number
|
||||||
|
|
||||||
|
Default value: '@pdf'
|
||||||
|
|
||||||
|
*g:vimtex_view_general_options_latexmk*
|
||||||
|
Set options that are passed on to `latexmk` for the specified general
|
||||||
|
viewer, see |vimtex_viewer_general|. This allows to send options that
|
||||||
|
ensures a unique viewer, e.g. with |vimtex_viewer_qpdfview|.
|
||||||
|
|
||||||
|
Default value: ''
|
||||||
|
|
||||||
|
*g:vimtex_view_mupdf_options*
|
||||||
|
Set options for mupdf (|vimtex_viewer_mupdf|).
|
||||||
|
|
||||||
|
Default value: ''
|
||||||
|
|
||||||
|
*g:vimtex_view_zathura_options*
|
||||||
|
Set options for zathura (|vimtex_viewer_zathura|).
|
||||||
|
|
||||||
Default value: ''
|
Default value: ''
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user