aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/autoload/health/provider.vim70
1 files changed, 40 insertions, 30 deletions
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index 98e2f90155..417426c101 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -37,6 +37,7 @@ endfunction
function! s:system(cmd, ...) abort
let stdin = a:0 ? a:1 : ''
let ignore_stderr = a:0 > 1 ? a:2 : 0
+ let ignore_error = a:0 > 2 ? a:3 : 0
let opts = {
\ 'output': '',
\ 'on_stdout': function('s:system_handler'),
@@ -63,7 +64,7 @@ function! s:system(cmd, ...) abort
call health#report_error(printf('Command timed out: %s',
\ type(a:cmd) == type([]) ? join(a:cmd) : a:cmd))
call jobstop(jobid)
- elseif s:shell_error != 0
+ elseif s:shell_error != 0 && !ignore_error
call health#report_error(printf("Command error (%d) %s: %s", jobid,
\ type(a:cmd) == type([]) ? join(a:cmd) : a:cmd,
\ opts.output))
@@ -83,8 +84,8 @@ endfunction
" Fetch the contents of a URL.
function! s:download(url) abort
if executable('curl')
- let rv = s:system(['curl', '-sL', a:url])
- return s:shell_error ? 'curl error: '.s:shell_error : rv
+ let rv = s:system(['curl', '-sL', a:url], '', 1, 1)
+ return s:shell_error ? 'curl error with '.a:url.': '.s:shell_error : rv
elseif executable('python')
let script = "
\try:\n
@@ -155,13 +156,10 @@ function! s:version_info(python) abort
endif
let nvim_path = s:trim(s:system([
- \ a:python,
- \ '-c',
- \ 'import neovim; print(neovim.__file__)']))
- let nvim_path = s:shell_error ? '' : nvim_path
-
- if empty(nvim_path)
- return [python_version, 'unable to find nvim executable', pypi_version, 'unable to get nvim executable']
+ \ a:python, '-c', 'import neovim; print(neovim.__file__)']))
+ if s:shell_error || empty(nvim_path)
+ return [python_version, 'unable to load neovim Python module', pypi_version,
+ \ nvim_path]
endif
" Assuming that multiple versions of a package are installed, sort them
@@ -172,24 +170,34 @@ function! s:version_info(python) abort
return a == b ? 0 : a > b ? 1 : -1
endfunction
- let nvim_version = 'unable to find nvim version'
- let base = fnamemodify(nvim_path, ':h')
- let metas = glob(base.'-*/METADATA', 1, 1) + glob(base.'-*/PKG-INFO', 1, 1)
- let metas = sort(metas, 's:compare')
-
- if !empty(metas)
- for meta_line in readfile(metas[0])
- if meta_line =~# '^Version:'
- let nvim_version = matchstr(meta_line, '^Version: \zs\S\+')
- break
- endif
- endfor
+ " Try to get neovim.VERSION (added in 0.1.11dev).
+ let nvim_version = s:system(['python', '-c',
+ \ 'from neovim import VERSION as v; '.
+ \ 'print("{}.{}.{}{}".format(v.major, v.minor, v.patch, v.prerelease))'],
+ \ '', 1, 1)
+ if empty(nvim_version)
+ let nvim_version = 'unable to find neovim Python module version'
+ let base = fnamemodify(nvim_path, ':h')
+ let metas = glob(base.'-*/METADATA', 1, 1)
+ \ + glob(base.'-*/PKG-INFO', 1, 1)
+ \ + glob(base.'.egg-info/PKG-INFO', 1, 1)
+ let metas = sort(metas, 's:compare')
+
+ if !empty(metas)
+ for meta_line in readfile(metas[0])
+ if meta_line =~# '^Version:'
+ let nvim_version = matchstr(meta_line, '^Version: \zs\S\+')
+ break
+ endif
+ endfor
+ endif
endif
- let version_status = 'unknown'
+ let nvim_path_base = fnamemodify(nvim_path, ':~:h')
+ let version_status = 'unknown; '.nvim_path_base
if !s:is_bad_response(nvim_version) && !s:is_bad_response(pypi_version)
if s:version_cmp(nvim_version, pypi_version) == -1
- let version_status = 'outdated'
+ let version_status = 'outdated; from '.nvim_path_base
else
let version_status = 'up to date'
endif
@@ -372,7 +380,11 @@ function! s:check_python(version) abort
endif
call health#report_info('Python'.a:version.' version: ' . pyversion)
- call health#report_info(printf('%s-neovim version: %s', python_bin_name, current))
+ if s:is_bad_response(status)
+ call health#report_info(printf('%s-neovim version: %s (%s)', python_bin_name, current, status))
+ else
+ call health#report_info(printf('%s-neovim version: %s', python_bin_name, current))
+ endif
if s:is_bad_response(current)
call health#report_error(
@@ -381,14 +393,12 @@ function! s:check_python(version) abort
endif
if s:is_bad_response(latest)
- call health#report_warn('Unable to contact PyPI.')
+ call health#report_warn('Could not contact PyPI to get latest version.')
call health#report_error('HTTP request failed: '.latest)
- endif
-
- if s:is_bad_response(status)
+ elseif s:is_bad_response(status)
call health#report_warn(printf('Latest %s-neovim is NOT installed: %s',
\ python_bin_name, latest))
- elseif !s:is_bad_response(latest)
+ elseif !s:is_bad_response(current)
call health#report_ok(printf('Latest %s-neovim is installed: %s',
\ python_bin_name, latest))
endif