Add check for required executables

This commit is contained in:
Karl Yngve Lervåg 2014-02-04 13:20:12 +01:00
parent 678193b362
commit 051a1c2085
3 changed files with 66 additions and 6 deletions

View File

@ -1,11 +1,31 @@
" {{{1 latex#complete#init " {{{1 latex#complete#init
function! latex#complete#init(initialized) function! latex#complete#init(initialized)
"
" Check if bibtex is available
"
if !executable('bibtex')
echom "Warning: bibtex completion not available"
echom " Missing executable: bibtex"
let s:bibtex = 0
endif
"
" Check if kpsewhich is required and available
"
if g:latex_complete_recursive_bib && !executable('kpsewhich')
echom "Warning: bibtex completion not available"
echom " Missing executable: kpsewhich"
echom " You could try to turn off recursive bib functionality"
let s:bibtex = 0
endif
if g:latex_complete_enabled if g:latex_complete_enabled
setlocal omnifunc=latex#complete#omnifunc setlocal omnifunc=latex#complete#omnifunc
endif endif
endfunction endfunction
" {{{1 latex#complete#omnifunc " {{{1 latex#complete#omnifunc
let s:bibtex = 1
let s:completion_type = '' let s:completion_type = ''
function! latex#complete#omnifunc(findstart, base) function! latex#complete#omnifunc(findstart, base)
if a:findstart if a:findstart
@ -38,7 +58,7 @@ function! latex#complete#omnifunc(findstart, base)
" "
if s:completion_type == 'ref' if s:completion_type == 'ref'
return latex#complete#labels(a:base) return latex#complete#labels(a:base)
elseif s:completion_type == 'bib' elseif s:completion_type == 'bib' && s:bibtex
return latex#complete#bibtex(a:base) return latex#complete#bibtex(a:base)
endif endif
endif endif
@ -319,6 +339,7 @@ function! s:labels_extract_inputs(file)
endfor endfor
return matches return matches
endfunction endfunction
" }}}1 " }}}1
" {{{1 s:next_chars_match " {{{1 s:next_chars_match

View File

@ -2,6 +2,11 @@
function! latex#latexmk#init(initialized) function! latex#latexmk#init(initialized)
if !g:latex_latexmk_enabled | return | endif if !g:latex_latexmk_enabled | return | endif
"
" Check if system is incompatible with latexmk
"
if s:system_incompatible() | return | endif
" "
" Initialize pid for current tex file " Initialize pid for current tex file
" "
@ -187,6 +192,14 @@ function! latex#latexmk#stop_all()
endfunction endfunction
" }}}1 " }}}1
" {{{1 s:execute
function! s:execute(cmd)
silent execute a:cmd
if !has('gui_running')
redraw!
endif
endfunction
" {{{1 s:stop_buffer " {{{1 s:stop_buffer
function! s:stop_buffer() function! s:stop_buffer()
" "
@ -219,13 +232,27 @@ function! s:stop_buffer()
endif endif
endfunction endfunction
" {{{1 s:execute " {{{1 s:system_incompatible()
function! s:execute(cmd) function! s:system_incompatible()
silent execute a:cmd "
if !has('gui_running') " Windows will not be supported
redraw! "
if has('win32')
return 1
endif endif
"
" Check if latexmk or pgrep is missing
"
for cmd in [ 'latexmk', 'pgrep' ]
if !executable(cmd)
echom "Warning: Could not initialize latex#latexmk"
echom " Missing executable: " . cmd
return 1
endif
endfor
endfunction endfunction
" }}}1 " }}}1
" vim:fdm=marker:ff=unix " vim:fdm=marker:ff=unix

View File

@ -49,6 +49,18 @@ that is easy to customize and evolve. Most of the functionality provided is
turned on by default, but the user may turn off features that are not desired. turned on by default, but the user may turn off features that are not desired.
The plugin will hereafter be referred to as |vim-latex|. The plugin will hereafter be referred to as |vim-latex|.
*vim-latex-requirements*
Some of the functionalities of |vim-latex| has certain requirements:
|vim-latex-latexmk|
Requires that the user has installed both `latexmk` and `pgrep`. If these
are not available, then the functionalities provided by
|vim-latex-latexmk| will not be available.
|vim-latex-completion|
The function |latex#complete#bibtex| requires `bibtex` and `kpsewhich` to
parse bib files for bibliography completion.
============================================================================== ==============================================================================
MAIN INTERFACE *vim-latex-main* MAIN INTERFACE *vim-latex-main*