diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-31 07:45:05 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-10-31 07:45:18 -0300 |
commit | 822d813575e53ac16bdc93a656a509adcbaadb2a (patch) | |
tree | 8a7837c64d4e54d82de47a52a7845ff0904dcab8 /runtime/plugin/python_setup.vim | |
parent | 4b0f8f2a4d8f1f1db1900079061cad2098bf0ac0 (diff) | |
parent | f10779fb7a7ee8990a7db723e71d5081a7cb9b6b (diff) | |
download | rneovim-822d813575e53ac16bdc93a656a509adcbaadb2a.tar.gz rneovim-822d813575e53ac16bdc93a656a509adcbaadb2a.tar.bz2 rneovim-822d813575e53ac16bdc93a656a509adcbaadb2a.zip |
Merge PR #1358 'Fix python setup'
Diffstat (limited to 'runtime/plugin/python_setup.vim')
-rw-r--r-- | runtime/plugin/python_setup.vim | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/runtime/plugin/python_setup.vim b/runtime/plugin/python_setup.vim index 3a6c61bd1d..0070885958 100644 --- a/runtime/plugin/python_setup.vim +++ b/runtime/plugin/python_setup.vim @@ -4,6 +4,14 @@ if exists("did_python_setup") || &cp endif let did_python_setup = 1 +" Prefix for naming things and displaying output. +let s:plugin_name = 'Python setup' + +function! s:ShowError(message) + echohl ErrorMsg + echomsg s:plugin_name . ': ' . a:message . '.' + echohl None +endfunction let s:get_version = \ ' -c "import sys; sys.stdout.write(str(sys.version_info[0]) + '. @@ -24,23 +32,29 @@ elseif executable('python2') " In some distros, python3 is the default python let s:python_interpreter = 'python2' else + call s:ShowError('No python interpreter found') finish endif +" Make sure we pick correct python version on path. +let s:python_interpreter_path = exepath(s:python_interpreter) +let s:python_version = systemlist(s:python_interpreter_path . ' --version')[0] + " Execute python, import neovim and print a string. If import_result matches " the printed string, we can probably start the host -let s:import_result = system(s:python_interpreter . +let s:import_result = system(s:python_interpreter_path . \ ' -c "import neovim, sys; sys.stdout.write(\"ok\")"') if s:import_result != 'ok' + call s:ShowError('No neovim module found for ' . s:python_version) finish endif -let s:pyhost_id = rpcstart(s:python_interpreter, +let s:pyhost_id = rpcstart(s:python_interpreter_path, \ ['-c', 'import neovim; neovim.start_host()']) " Evaluate an expression in the script host as an additional sanity check, and " to block until all providers have been registered(or else some plugins loaded " by the user's vimrc would not get has('python') == 1 if rpcrequest(s:pyhost_id, 'python_eval', '"o"+"k"') != 'ok' || !has('python') - " Something went wrong + call s:ShowError('Something went wrong setting up ' . s:python_version) call rpcstop(s:pyhost_id) endif |