health.vim: always check pyenv if installed #7219

Always check for the presence of pyenv_root if pyenv is installed: if it
is not set, we don't know if it was intentional. If it wasn't
intentional, the warning is confusing (see #7176).

closes #7176
This commit is contained in:
Greg Anders 2017-08-26 17:29:12 -05:00 committed by Justin M. Keyes
parent 26d08dfd0d
commit 7c00b10d8d

View File

@ -239,7 +239,7 @@ function! s:check_python(version) abort
let pyname = 'python'.(a:version == 2 ? '' : '3')
let pyenv = resolve(exepath('pyenv'))
let pyenv_root = exists('$PYENV_ROOT') ? resolve($PYENV_ROOT) : 'n'
let pyenv_root = exists('$PYENV_ROOT') ? resolve($PYENV_ROOT) : ''
let venv = exists('$VIRTUAL_ENV') ? resolve($VIRTUAL_ENV) : ''
let host_prog_var = pyname.'_host_prog'
let loaded_var = 'g:loaded_'.pyname.'_provider'
@ -251,6 +251,19 @@ function! s:check_python(version) abort
return
endif
if !empty(pyenv)
if empty(pyenv_root)
call health#report_warn(
\ 'pyenv was found, but $PYENV_ROOT is not set.',
\ ['Did you follow the final install instructions?',
\ 'If you use a shell "framework" like Prezto or Oh My Zsh, try without.',
\ 'Try a different shell (bash).']
\ )
else
call health#report_ok(printf('pyenv found: "%s"', pyenv))
endif
endif
if exists('g:'.host_prog_var)
call health#report_info(printf('Using: g:%s = "%s"', host_prog_var, get(g:, host_prog_var)))
endif
@ -282,15 +295,6 @@ function! s:check_python(version) abort
endif
if !empty(pyenv)
if empty(pyenv_root)
call health#report_warn(
\ 'pyenv was found, but $PYENV_ROOT is not set.',
\ ['Did you follow the final install instructions?']
\ )
else
call health#report_ok(printf('pyenv found: "%s"', pyenv))
endif
let python_bin = s:trim(s:system([pyenv, 'which', pyname], '', 1))
if empty(python_bin)
@ -320,9 +324,8 @@ function! s:check_python(version) abort
if python_bin =~# '\<shims\>'
call health#report_warn(printf('`%s` appears to be a pyenv shim.', python_bin), [
\ 'The `pyenv` executable is not in $PATH,',
\ 'Your pyenv installation is broken. You should set '
\ . '`g:'.host_prog_var.'` to avoid surprises.',
\ '`pyenv` is not in $PATH, your pyenv installation is broken. '
\ .'Set `g:'.host_prog_var.'` to avoid surprises.',
\ ])
endif
endif
@ -335,7 +338,7 @@ function! s:check_python(version) abort
call health#report_warn('pyenv is not set up optimally.', [
\ printf('Create a virtualenv specifically '
\ . 'for Neovim using pyenv, and set `g:%s`. This will avoid '
\ . 'the need to install Neovim''s Python module in each '
\ . 'the need to install the Neovim Python module in each '
\ . 'version/virtualenv.', host_prog_var)
\ ])
elseif !empty(venv) && exists('g:'.host_prog_var)