forked from lervag/vimtex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimtex.vim
155 lines (125 loc) · 3.94 KB
/
vimtex.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
function! health#vimtex#check() abort
call vimtex#options#init()
call health#report_start('VimTeX')
call s:check_general()
call s:check_plugin_clash()
call s:check_view()
call s:check_compiler()
endfunction
function! s:check_general() abort " {{{1
if !has('nvim') || v:version < 800
call health#report_warn('VimTeX works best with Vim 8 or neovim')
else
call health#report_ok('Vim version should have full support!')
endif
if !executable('bibtex')
call health#report_warn('bibtex is not executable!',
\ 'bibtex is required for cite completions.')
endif
if !executable('biber')
call health#report_warn(
\ 'biber is not executable!',
\ 'Biber is often required so this may give unexpected problems.')
endif
endfunction
" }}}1
function! s:check_compiler() abort " {{{1
if !g:vimtex_compiler_enabled | return | endif
if !executable(g:vimtex_compiler_method)
let l:ind = ' '
call health#report_error(printf(
\ '|g:vimtex_compiler_method| (`%s`) is not executable!',
\ g:vimtex_compiler_method))
return
endif
call health#report_ok('Compiler should work!')
endfunction
" }}}1
function! s:check_plugin_clash() abort " {{{1
" Note: This duplicates the code in after/ftplugin/tex.vim
let l:scriptnames = vimtex#util#command('scriptnames')
let l:latexbox = !empty(filter(copy(l:scriptnames), "v:val =~# 'latex-box'"))
if l:latexbox
call health#report_warn('Conflicting plugin detected: LaTeX-Box')
call health#report_info('VimTeX does not work as expected when LaTeX-Box is installed!')
call health#report_info('Please disable or remove it to use VimTeX!')
endif
endfunction
" }}}1
function! s:check_view() abort " {{{1
call s:check_view_{g:vimtex_view_method}()
if executable('xdotool') && !executable('pstree')
call health#report_warn('pstree is not available',
\ 'vimtex#view#inverse_search is better if pstree is available.')
endif
endfunction
" }}}1
function! s:check_view_general() abort " {{{1
if executable(g:vimtex_view_general_viewer)
call health#report_ok('General viewer should work properly!')
else
call health#report_error(
\ 'Selected viewer is not executable!',
\ '- Selection: ' . g:vimtex_view_general_viewer,
\ '- Please see :h g:vimtex_view_general_viewer')
endif
endfunction
" }}}1
function! s:check_view_zathura() abort " {{{1
let l:ok = 1
if !executable('zathura')
call health#report_error('Zathura is not executable!')
let l:ok = 0
endif
if !executable('xdotool')
call health#report_warn('Zathura requires xdotool for forward search!')
let l:ok = 0
endif
if l:ok
call health#report_ok('Zathura should work properly!')
endif
endfunction
" }}}1
function! s:check_view_mupdf() abort " {{{1
let l:ok = 1
if !executable('mupdf')
call health#report_error('MuPDF is not executable!')
let l:ok = 0
endif
if !executable('xdotool')
call health#report_warn('MuPDF requires xdotool for forward search!')
let l:ok = 0
endif
if !executable('synctex')
call health#report_warn('MuPDF requires synctex for forward search!')
let l:ok = 0
endif
if l:ok
call health#report_ok('MuPDF should work properly!')
endif
endfunction
" }}}1
function! s:check_view_sioyek() abort " {{{1
let l:ok = 1
if !executable(g:vimtex_view_sioyek_exe)
call health#report_error('Sioyek is not executable!')
let l:ok = 0
endif
if l:ok
call health#report_ok('Sioyek should work properly!')
endif
endfunction
" }}}1
function! s:check_view_skim() abort " {{{1
call vimtex#jobs#run(join([
\ 'osascript -e ',
\ '''tell application "Finder" to POSIX path of ',
\ '(get application file id (id of application "Skim") as alias)''',
\]))
if v:shell_error == 0
call health#report_ok('Skim viewer should work!')
else
call health#report_error('Skim is not installed!')
endif
endfunction
" }}}1