mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-07 03:04:30 +08:00
Support for force_py_version = "auto"
This will call `python` to look up its major version number.
This commit is contained in:
@@ -309,7 +309,7 @@ let s:settings = {
|
|||||||
\ 'popup_select_first': 1,
|
\ 'popup_select_first': 1,
|
||||||
\ 'quickfix_window_height': 10,
|
\ 'quickfix_window_height': 10,
|
||||||
\ 'completions_enabled': 1,
|
\ 'completions_enabled': 1,
|
||||||
\ 'force_py_version': 2
|
\ 'force_py_version': "'auto'"
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
|
|
||||||
@@ -337,8 +337,24 @@ call s:init()
|
|||||||
|
|
||||||
let s:script_path = fnameescape(expand('<sfile>:p:h:h'))
|
let s:script_path = fnameescape(expand('<sfile>:p:h:h'))
|
||||||
|
|
||||||
|
" Get g:jedi#force_py_version, handling "auto" on first call.
|
||||||
|
function! jedi#get_force_py_version()
|
||||||
|
if g:jedi#force_py_version == 'auto'
|
||||||
|
let s:def_py = system("python -c 'import sys; sys.stdout.write(str(sys.version_info[0]))'")
|
||||||
|
if v:shell_error == 0 && len(s:def_py)
|
||||||
|
let g:jedi#force_py_version = s:def_py
|
||||||
|
else
|
||||||
|
if !exists("g:jedi#squelch_py_warning")
|
||||||
|
echomsg "Error: jedi-vim failed to get Python version from sys.version_info: " . s:def_py
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
return g:jedi#force_py_version
|
||||||
|
endfunction
|
||||||
|
|
||||||
if has('python') && has('python3')
|
if has('python') && has('python3')
|
||||||
call jedi#force_py_version(g:jedi#force_py_version)
|
" Use default python with Jedi.
|
||||||
|
call jedi#force_py_version(jedi#get_force_py_version())
|
||||||
elseif has('python')
|
elseif has('python')
|
||||||
command! -nargs=1 Python python <args>
|
command! -nargs=1 Python python <args>
|
||||||
execute 'pyfile '.s:script_path.'/initialize.py'
|
execute 'pyfile '.s:script_path.'/initialize.py'
|
||||||
|
|||||||
@@ -462,7 +462,7 @@ or set directly using this function, which has the same name as the variable:
|
|||||||
Function: `jedi#force_py_version(py_version)`
|
Function: `jedi#force_py_version(py_version)`
|
||||||
|
|
||||||
Options: 2 or 3
|
Options: 2 or 3
|
||||||
Default: 2
|
Default: "auto" (will use sys.version_info from "python" in your $PATH)
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
7. Testing *jedi-vim-testing*
|
7. Testing *jedi-vim-testing*
|
||||||
|
|||||||
Reference in New Issue
Block a user