mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
Remove g:python{,3}_host_skip_check (#5738)
This option simplifies the configuration options: 1) `g:python{,3}_host_prog` is not set. Neovim tries its best to find a suitable interpreter. This means calling exepath(), potentially multiple times, and a system('python -c ...') with the first found interpreter, to get the Python version. 2) `g:python{,3}_host_prog` is set. Avoids everything of the above. No safety checks, no training wheels. Fast host startup time!
This commit is contained in:
parent
ddfac951ea
commit
20995c7960
@ -215,7 +215,6 @@ function! s:check_python(version) abort
|
||||
let pyenv_root = exists('$PYENV_ROOT') ? resolve($PYENV_ROOT) : 'n'
|
||||
let venv = exists('$VIRTUAL_ENV') ? resolve($VIRTUAL_ENV) : ''
|
||||
let host_prog_var = python_bin_name.'_host_prog'
|
||||
let host_skip_var = python_bin_name.'_host_skip_check'
|
||||
let python_bin = ''
|
||||
let python_multiple = []
|
||||
|
||||
@ -230,10 +229,6 @@ function! s:check_python(version) abort
|
||||
if !empty(pythonx_errs)
|
||||
call health#report_warn(pythonx_errs)
|
||||
endif
|
||||
let old_skip = get(g:, host_skip_var, 0)
|
||||
let g:[host_skip_var] = 1
|
||||
let [python_bin_name, pythonx_errs] = provider#pythonx#Detect(a:version)
|
||||
let g:[host_skip_var] = old_skip
|
||||
endif
|
||||
|
||||
if !empty(python_bin_name)
|
||||
|
@ -47,32 +47,27 @@ function! provider#pythonx#Require(host) abort
|
||||
endfunction
|
||||
|
||||
function! provider#pythonx#Detect(major_ver) abort
|
||||
let host_var = (a:major_ver == 2) ?
|
||||
\ 'g:python_host_prog' : 'g:python3_host_prog'
|
||||
let skip_var = (a:major_ver == 2) ?
|
||||
\ 'g:python_host_skip_check' : 'g:python3_host_skip_check'
|
||||
let skip = exists(skip_var) ? {skip_var} : 0
|
||||
if exists(host_var)
|
||||
" Disable auto detection.
|
||||
let [result, err] = s:check_interpreter({host_var}, a:major_ver, skip)
|
||||
if result
|
||||
return [{host_var}, err]
|
||||
if a:major_ver == 2
|
||||
if exists('g:python_host_prog')
|
||||
return [g:python_host_prog, '']
|
||||
else
|
||||
let progs = ['python2', 'python2.7', 'python2.6', 'python']
|
||||
endif
|
||||
else
|
||||
if exists('g:python3_host_prog')
|
||||
return [g:python3_host_prog, '']
|
||||
else
|
||||
let progs = ['python3', 'python3.5', 'python3.4', 'python3.3', 'python']
|
||||
endif
|
||||
return ['', 'provider/pythonx: Could not load Python ' . a:major_ver
|
||||
\ . ' from ' . host_var . ': ' . err]
|
||||
endif
|
||||
|
||||
let prog_suffixes = (a:major_ver == 2) ?
|
||||
\ ['2', '2.7', '2.6', '']
|
||||
\ : ['3', '3.5', '3.4', '3.3', '']
|
||||
|
||||
let errors = []
|
||||
for prog in map(prog_suffixes, "'python' . v:val")
|
||||
let [result, err] = s:check_interpreter(prog, a:major_ver, skip)
|
||||
|
||||
for prog in progs
|
||||
let [result, err] = s:check_interpreter(prog, a:major_ver)
|
||||
if result
|
||||
return [prog, err]
|
||||
endif
|
||||
|
||||
" Accumulate errors in case we don't find
|
||||
" any suitable Python interpreter.
|
||||
call add(errors, err)
|
||||
@ -83,16 +78,12 @@ function! provider#pythonx#Detect(major_ver) abort
|
||||
\ . ":\n" . join(errors, "\n")]
|
||||
endfunction
|
||||
|
||||
function! s:check_interpreter(prog, major_ver, skip) abort
|
||||
function! s:check_interpreter(prog, major_ver) abort
|
||||
let prog_path = exepath(a:prog)
|
||||
if prog_path ==# ''
|
||||
return [0, a:prog . ' not found in search path or not executable.']
|
||||
endif
|
||||
|
||||
if a:skip
|
||||
return [1, '']
|
||||
endif
|
||||
|
||||
let min_version = (a:major_ver == 2) ? '2.6' : '3.3'
|
||||
|
||||
" Try to load neovim module, and output Python version.
|
||||
|
@ -48,11 +48,9 @@ Note: The `--upgrade` flag ensures you have the latest version even if
|
||||
|
||||
PYTHON PROVIDER CONFIGURATION ~
|
||||
*g:python_host_prog*
|
||||
Set `g:python_host_prog` to point Nvim to a specific Python 2 interpreter: >
|
||||
let g:python_host_prog = '/path/to/python'
|
||||
<
|
||||
*g:python3_host_prog*
|
||||
Set `g:python3_host_prog` to point Nvim to a specific Python 3 interpreter: >
|
||||
Program to use for evaluating Python code. Setting this makes startup faster. >
|
||||
let g:python_host_prog = '/path/to/python'
|
||||
let g:python3_host_prog = '/path/to/python3'
|
||||
<
|
||||
*g:loaded_python_provider*
|
||||
@ -62,16 +60,6 @@ To disable Python 2 support: >
|
||||
*g:loaded_python3_provider*
|
||||
To disable Python 3 support: >
|
||||
let g:loaded_python3_provider = 1
|
||||
<
|
||||
*g:python_host_skip_check*
|
||||
Set `g:python_host_skip_check` to disable the Python 2 interpreter check.
|
||||
Note: This requires you to install the python-neovim module properly. >
|
||||
let g:python_host_skip_check = 1
|
||||
<
|
||||
*g:python3_host_skip_check*
|
||||
Set `g:python3_host_skip_check` to disable the Python 3 interpreter check.
|
||||
Note: This requires you to install the python3-neovim module properly. >
|
||||
let g:python3_host_skip_check = 1
|
||||
|
||||
|
||||
==============================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user