Fixed init problem (fixes #183)

This commit is contained in:
Karl Yngve Lervåg 2015-06-10 08:05:49 +02:00
parent b33268b204
commit 692df6c245

View File

@ -45,12 +45,14 @@ function! vimtex#view#init_buffer() " {{{1
" "
" Create view and/or callback hooks (if they exist) " Create view and/or callback hooks (if they exist)
" "
for hook in ['view', 'callback'] for point in ['view', 'callback']
execute 'let hookfunc = ''*'' execute 'let hook = ''g:vimtex_view_'
\ . g:vimtex_view_' . g:vimtex_view_method . '_hook_' . hook \ . g:vimtex_view_method . '_hook_' . point . ''''
if exists(hookfunc) if exists(hook)
execute 'let b:vimtex.viewer.hook_' . hook . ' = function(g:vimtex_view_' execute 'let hookfunc = ''*'' . ' . hook
\ . g:vimtex_view_method . '_hook_' . hook . ')' if exists(hookfunc)
execute 'let b:vimtex.viewer.hook_' . point . ' = function(' . hook . ')'
endif
endif endif
endfor endfor
@ -82,12 +84,6 @@ endfunction
" "
" {{{1 General " {{{1 General
function! s:general.init() dict " {{{2 function! s:general.init() dict " {{{2
if !executable(g:vimtex_view_general_viewer)
echoerr 'vimtex viewer is not executable!'
echoerr 'g:vimtex_view_general_viewer = '
\ . g:vimtex_view_general_viewer
endif
" "
" Set default options " Set default options
" "
@ -97,6 +93,12 @@ function! s:general.init() dict " {{{2
\ 'mac' : 'open', \ 'mac' : 'open',
\ }) \ })
call vimtex#util#set_default('g:vimtex_view_general_options', '') call vimtex#util#set_default('g:vimtex_view_general_options', '')
if !executable(g:vimtex_view_general_viewer)
echoerr 'vimtex viewer is not executable!'
echoerr 'g:vimtex_view_general_viewer = '
\ . g:vimtex_view_general_viewer
endif
endfunction endfunction
" }}}2 " }}}2
@ -133,14 +135,6 @@ function! s:mupdf.init() dict " {{{2
" Only initialize once " Only initialize once
if has_key(self, 'xwin_id') | return | endif if has_key(self, 'xwin_id') | return | endif
if !executable('mupdf')
echoerr 'vimtex viewer MuPDF is not executable!'
endif
if !executable('xdotool')
call vimtex#echo#warning('vimtex viewer MuPDF requires xdotool!')
endif
" "
" Default MuPDF settings " Default MuPDF settings
" "
@ -151,6 +145,14 @@ function! s:mupdf.init() dict " {{{2
call vimtex#util#set_default('g:vimtex_view_mupdf_hook_view', call vimtex#util#set_default('g:vimtex_view_mupdf_hook_view',
\ 's:focus_viewer') \ 's:focus_viewer')
if !executable('mupdf')
echoerr 'vimtex viewer MuPDF is not executable!'
endif
if !executable('xdotool')
call vimtex#echo#warning('vimtex viewer MuPDF requires xdotool!')
endif
let self.class = 'MuPDF' let self.class = 'MuPDF'
let self.xwin_id = 0 let self.xwin_id = 0
let self.xwin_exists = function('s:xwin_exists') let self.xwin_exists = function('s:xwin_exists')
@ -286,11 +288,11 @@ endfunction
" {{{1 Okular " {{{1 Okular
function! s:okular.init() dict " {{{2 function! s:okular.init() dict " {{{2
call vimtex#util#set_default('g:vimtex_view_okular_options', '')
if !executable('okular') if !executable('okular')
echoerr 'vimtex viewer Okular is not executable!' echoerr 'vimtex viewer Okular is not executable!'
endif endif
call vimtex#util#set_default('g:vimtex_view_okular_options', '')
endfunction endfunction
" }}}2 " }}}2
@ -314,11 +316,11 @@ endfunction
" {{{1 qpdfview " {{{1 qpdfview
function! s:qpdfview.init() dict " {{{2 function! s:qpdfview.init() dict " {{{2
call vimtex#util#set_default('g:vimtex_view_qpdfview_options', '')
if !executable('qpdfview') if !executable('qpdfview')
echoerr 'vimtex viewer qpdfview is not executable!' echoerr 'vimtex viewer qpdfview is not executable!'
endif endif
call vimtex#util#set_default('g:vimtex_view_qpdfview_options', '')
endfunction endfunction
" }}}2 " }}}2
@ -344,11 +346,11 @@ endfunction
" {{{1 SumatraPDF " {{{1 SumatraPDF
function! s:sumatrapdf.init() dict " {{{2 function! s:sumatrapdf.init() dict " {{{2
call vimtex#util#set_default('g:vimtex_view_sumatrapdf_options', '')
if !executable('SumatraPDF') if !executable('SumatraPDF')
echoerr 'vimtex viewer SumatraPDF is not executable!' echoerr 'vimtex viewer SumatraPDF is not executable!'
endif endif
call vimtex#util#set_default('g:vimtex_view_sumatrapdf_options', '')
endfunction endfunction
" }}}2 " }}}2
@ -376,14 +378,6 @@ function! s:zathura.init() dict " {{{2
" Only initialize once " Only initialize once
if has_key(self, 'xwin_id') | return | endif if has_key(self, 'xwin_id') | return | endif
if !executable('zathura')
echoerr 'vimtex viewer Zathura is not executable!'
endif
if !executable('xdotool')
call vimtex#echo#warning('vimtex viewer Zathura requires xdotool!')
endif
" "
" Default Zathura settings " Default Zathura settings
" "
@ -393,6 +387,14 @@ function! s:zathura.init() dict " {{{2
call vimtex#util#set_default('g:vimtex_view_zathura_hook_view', call vimtex#util#set_default('g:vimtex_view_zathura_hook_view',
\ 's:focus_viewer') \ 's:focus_viewer')
if !executable('zathura')
echoerr 'vimtex viewer Zathura is not executable!'
endif
if !executable('xdotool')
call vimtex#echo#warning('vimtex viewer Zathura requires xdotool!')
endif
let self.class = 'Zathura' let self.class = 'Zathura'
let self.xwin_id = 0 let self.xwin_id = 0
let self.xwin_get_id = function('s:xwin_get_id') let self.xwin_get_id = function('s:xwin_get_id')