forked from VimPlug/jedi-vim
s:init_python: handle g:jedi#force_py_version again (#834)
It was removed previously, since it now refers to the environment being used. This brings it back for now. There could be a separate var for it later, and/or it needs changes later (or rather the environment needs a new variable name, since it should refer to the executable really) - but this is good for now I think. Fixes https://github.com/davidhalter/jedi-vim/issues/833
This commit is contained in:
@@ -57,14 +57,35 @@ endfor
|
|||||||
" ------------------------------------------------------------------------
|
" ------------------------------------------------------------------------
|
||||||
let s:script_path = fnameescape(expand('<sfile>:p:h:h'))
|
let s:script_path = fnameescape(expand('<sfile>:p:h:h'))
|
||||||
|
|
||||||
|
" Initialize Python (PythonJedi command).
|
||||||
function! s:init_python() abort
|
function! s:init_python() abort
|
||||||
if has('python3')
|
" Use g:jedi#force_py_version for loading Jedi, or fall back to using
|
||||||
call jedi#setup_python_imports(3)
|
" `has()` - preferring Python 3.
|
||||||
elseif has('python')
|
let loader_version = get(g:, 'jedi#loader_py_version', g:jedi#force_py_version)
|
||||||
call jedi#setup_python_imports(2)
|
if loader_version ==# 'auto'
|
||||||
|
if has('python3')
|
||||||
|
let loader_version = 3
|
||||||
|
elseif has('python2')
|
||||||
|
let loader_version = 2
|
||||||
|
else
|
||||||
|
throw 'jedi-vim requires Vim with support for Python 2 or 3.'
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
throw 'jedi-vim requires Vim with support for Python 2 or 3.'
|
if loader_version =~# '^3'
|
||||||
|
let loader_version = 3
|
||||||
|
elseif loader_version =~# '^2'
|
||||||
|
let loader_version = 2
|
||||||
|
else
|
||||||
|
if !exists('g:jedi#squelch_py_warning')
|
||||||
|
echohl WarningMsg
|
||||||
|
echom printf("jedi-vim: could not determine Python loader version from 'g:jedi#loader_py_version/g:jedi#force_py_version' (%s), using 3.",
|
||||||
|
\ loader_version)
|
||||||
|
echohl None
|
||||||
|
endif
|
||||||
|
let loader_version = 3
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
call jedi#setup_python_imports(loader_version)
|
||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user