aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2015-09-17 13:23:29 -0400
committerJustin M. Keyes <justinkz@gmail.com>2015-09-17 13:23:29 -0400
commit7befd0f37cac6575c34b4936371db2181e6d581a (patch)
treee5fc9fcfcfbfbe1030c2bb35ce7702f416e2fa64
parentc416e6874e7382721e52720983cd8c283dd738f1 (diff)
parente3540a430b5173131722781869b55ad08b3784aa (diff)
downloadrneovim-7befd0f37cac6575c34b4936371db2181e6d581a.tar.gz
rneovim-7befd0f37cac6575c34b4936371db2181e6d581a.tar.bz2
rneovim-7befd0f37cac6575c34b4936371db2181e6d581a.zip
Merge pull request #3351 from fwalch/provider/pythonx-error-message
provider/pythonx: Improve detection code and error messages.
-rw-r--r--runtime/autoload/provider/pythonx.vim40
1 files changed, 27 insertions, 13 deletions
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index 5ca397ea4e..022ef19914 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -52,24 +52,38 @@ function! s:check_interpreter(prog, major_ver, skip) abort
return [1, '']
endif
+ let min_version = (a:major_ver == 2) ? '2.6' : '3.3'
+
" 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.
let prog_ver = system([ a:prog , '-c' ,
- \ 'import sys; sys.path.remove(""); sys.stdout.write(str(sys.version_info[0]) + '.
- \ '"." + str(sys.version_info[1])); '.
- \ (a:major_ver == 2
- \ ? 'import pkgutil; exit(pkgutil.get_loader("neovim") is None)'
- \ : 'import importlib; exit(importlib.find_loader("neovim") is None)')
+ \ 'import sys; ' .
+ \ 'sys.path.remove(""); ' .
+ \ 'sys.stdout.write(str(sys.version_info[0]) + "." + str(sys.version_info[1])); ' .
+ \ 'import pkgutil; ' .
+ \ 'exit(2*int(pkgutil.get_loader("neovim") is None))'
\ ])
- if v:shell_error
- return [0, prog_path . ' does have not have the neovim module installed. '
- \ . 'See ":help nvim-python".']
+
+ if prog_ver
+ if prog_ver !~ '^' . a:major_ver
+ return [0, prog_path . ' is Python ' . prog_ver . ' and cannot provide Python '
+ \ . a:major_ver . '.']
+ elseif prog_ver =~ '^' . a:major_ver && prog_ver < min_version
+ return [0, prog_path . ' is Python ' . prog_ver . ' and cannot provide Python >= '
+ \ . min_version . '.']
+ endif
endif
- let min_version = (a:major_ver == 2) ? '2.6' : '3.3'
- if prog_ver =~ '^' . a:major_ver && prog_ver >= min_version
- return [1, '']
+ 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. '
+ \ . 'See ":help nvim-python".']
endif
- return [0, prog_path . ' is Python ' . prog_ver . ' and cannot provide Python '
- \ . a:major_ver . '.']
+ return [1, '']
endfunction