Skip to content

Commit

Permalink
chore(view): minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
lervag committed Apr 9, 2021
1 parent bded2b4 commit c6a921c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 22 deletions.
8 changes: 8 additions & 0 deletions autoload/vimtex/view.vim
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ function! vimtex#view#reverse_search() abort " {{{1
endif
endfunction

" }}}1
function! vimtex#view#not_readable(output) abort " {{{1
if filereadable(a:output) | return 0 | endif

call vimtex#log#warning('Viewer cannot read PDF file!', a:output)
return 1
endfunction

" }}}1

function! vimtex#view#reverse_goto(line, filename) abort " {{{1
Expand Down
14 changes: 1 addition & 13 deletions autoload/vimtex/view/common.vim
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ function! vimtex#view#common#apply_xwin_template(class, viewer) abort " {{{1
return a:viewer
endfunction

" }}}1
function! vimtex#view#common#not_readable(output) abort " {{{1
if !filereadable(a:output)
call vimtex#log#warning('Viewer cannot read PDF file!', a:output)
return 1
else
return 0
endif
endfunction

" }}}1

let s:common_template = {}
Expand Down Expand Up @@ -92,9 +82,7 @@ function! s:xwin_template.view(file) dict abort " {{{1
else
let outfile = a:file
endif
if vimtex#view#common#not_readable(outfile)
return
endif
if vimtex#view#not_readable(outfile) | return | endif

if self.xwin_exists()
call self.forward_search(outfile)
Expand Down
5 changes: 2 additions & 3 deletions autoload/vimtex/view/general.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ function! s:general.view(file) dict abort " {{{1
let outfile = self.out()

" Only copy files if they don't exist
if g:vimtex_view_use_temp_files
\ && vimtex#view#common#not_readable(outfile)
if g:vimtex_view_use_temp_files && !filereadable(outfile)
call self.copy_files()
endif
else
Expand All @@ -51,7 +50,7 @@ function! s:general.view(file) dict abort " {{{1
\ vimtex#process#capture('cygpath -aw "' . outfile . '"'), '')
endif

if vimtex#view#common#not_readable(outfile) | return | endif
if vimtex#view#not_readable(outfile) | return | endif

" Parse options
let l:cmd = g:vimtex_view_general_viewer
Expand Down
2 changes: 1 addition & 1 deletion autoload/vimtex/view/mupdf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function! s:mupdf.reverse_search() dict abort " {{{1
if !executable('synctex') | return | endif

let outfile = self.out()
if vimtex#view#common#not_readable(outfile) | return | endif
if vimtex#view#not_readable(outfile) | return | endif

if !self.xwin_exists()
call vimtex#log#warning('Reverse search failed (is MuPDF open?)')
Expand Down
5 changes: 2 additions & 3 deletions autoload/vimtex/view/skim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ function! s:skim.view(file) dict abort " {{{1
let outfile = self.out()

" Only copy files if they don't exist
if g:vimtex_view_use_temp_files
\ && vimtex#view#common#not_readable(outfile)
if g:vimtex_view_use_temp_files && !filereadable(outfile)
call self.copy_files()
endif
else
let outfile = a:file
endif
if vimtex#view#common#not_readable(outfile) | return | endif
if vimtex#view#not_readable(outfile) | return | endif

let l:cmd = join([
\ 'osascript',
Expand Down
2 changes: 1 addition & 1 deletion autoload/vimtex/view/zathura.vim
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function! vimtex#view#zathura#compiler_callback() abort " {{{1
sleep 50m
endfor

if ! l:xwin_exists
if !l:xwin_exists
call self.start(self.out())
let self.started_through_callback = 1
endif
Expand Down
5 changes: 4 additions & 1 deletion doc/vimtex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4806,14 +4806,17 @@ viewer is opened.
Associated settings:
* |g:vimtex_view_enabled|
* |g:vimtex_view_automatic|
* |g:vimtex_view_method|
* |g:vimtex_view_forward_search_on_start|
* |g:vimtex_view_use_temp_files|
* |g:vimtex_view_method|
* |g:vimtex_view_general_options|
* |g:vimtex_view_general_options_latexmk|
* |g:vimtex_view_general_viewer|
* |g:vimtex_view_mupdf_options|
* |g:vimtex_view_mupdf_send_keys|
* |g:vimtex_view_skim_activate|
* |g:vimtex_view_skim_reading_bar|
* |g:vimtex_view_zathura_check_libsynctex|
* |g:vimtex_view_zathura_options|

Associated events:
Expand Down

0 comments on commit c6a921c

Please sign in to comment.