aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2016-05-28 17:07:27 +0200
committerDaniel Hahler <git@thequod.de>2016-05-28 17:10:16 +0200
commitdab5d1368a2e3a8d2f961e54db37d4222e2f770b (patch)
tree5e6de1c3a2f315575c67eadd11e399bc565e0825
parent48e945e588c1f32b0ae358d674f033328e2696c6 (diff)
downloadrneovim-dab5d1368a2e3a8d2f961e54db37d4222e2f770b.tar.gz
rneovim-dab5d1368a2e3a8d2f961e54db37d4222e2f770b.tar.bz2
rneovim-dab5d1368a2e3a8d2f961e54db37d4222e2f770b.zip
provider/pythonx: handle exit code 127 from pyenv
This also checks the major/min version only for expected return codes. With pyenv, you might get the following (return code 127): pyenv: python3.4: command not found The `python3.4' command exists in these Python versions: 3.4.3 3.4.3/envs/tmp-3.4.3-eElS6Y tmp-3.4.3-eElS6Y
-rw-r--r--runtime/autoload/provider/pythonx.vim19
1 files changed, 12 insertions, 7 deletions
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index 05815a4896..b59cf92f59 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -83,8 +83,8 @@ function! s:check_interpreter(prog, major_ver, skip) abort
" Try to load neovim module, and output Python version.
" Return codes:
" 0 Neovim module can be loaded.
- " 1 Something else went wrong.
" 2 Neovim module cannot be loaded.
+ " Otherwise something else went wrong (e.g. 1 or 127).
let prog_ver = system([ a:prog , '-c' ,
\ 'import sys; ' .
\ 'sys.path.remove(""); ' .
@@ -93,7 +93,8 @@ function! s:check_interpreter(prog, major_ver, skip) abort
\ 'exit(2*int(pkgutil.get_loader("neovim") is None))'
\ ])
- if prog_ver
+ if v:shell_error == 2 || v:shell_error == 0
+ " Check version only for expected return codes.
if prog_ver !~ '^' . a:major_ver
return [0, prog_path . ' is Python ' . prog_ver . ' and cannot provide Python '
\ . a:major_ver . '.']
@@ -103,12 +104,16 @@ function! s:check_interpreter(prog, major_ver, skip) abort
endif
endif
- if v:shell_error == 1
- return [0, 'Checking ' . prog_path . ' caused an unknown error. '
- \ . 'Please report this at github.com/neovim/neovim.']
- elseif v:shell_error == 2
- return [0, prog_path . ' does have not have the neovim module installed. '
+ if v:shell_error == 2
+ return [0, prog_path . ' does not have the neovim module installed. '
\ . 'See ":help nvim-python".']
+ elseif v:shell_error == 127
+ " This can happen with pyenv's shims.
+ return [0, prog_path . ' does not exist: ' . prog_ver]
+ elseif v:shell_error
+ return [0, 'Checking ' . prog_path . ' caused an unknown error. '
+ \ . '(' . v:shell_error . ', output: ' . prog_ver . ')'
+ \ . ' Please report this at github.com/neovim/neovim.']
endif
return [1, '']