mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
241956720d
Value of 1 cannot be used, because users might set that in their vimrc to _disable_ a provider, which would confuse :checkhealth and has().
46 lines
1.3 KiB
VimL
46 lines
1.3 KiB
VimL
" The Python provider uses a Python host to emulate an environment for running
|
|
" python-vim plugins. :help provider
|
|
"
|
|
" Associating the plugin with the Python host is the first step because plugins
|
|
" will be passed as command-line arguments
|
|
|
|
if exists('g:loaded_python_provider')
|
|
finish
|
|
endif
|
|
let [s:prog, s:err] = provider#pythonx#Detect(2)
|
|
let g:loaded_python_provider = empty(s:prog) ? 1 : 2
|
|
|
|
function! provider#python#Prog() abort
|
|
return s:prog
|
|
endfunction
|
|
|
|
function! provider#python#Error() abort
|
|
return s:err
|
|
endfunction
|
|
|
|
" The Python provider plugin will run in a separate instance of the Python
|
|
" host.
|
|
call remote#host#RegisterClone('legacy-python-provider', 'python')
|
|
call remote#host#RegisterPlugin('legacy-python-provider', 'script_host.py', [])
|
|
|
|
function! provider#python#Call(method, args) abort
|
|
if s:err != ''
|
|
return
|
|
endif
|
|
if !exists('s:host')
|
|
let s:rpcrequest = function('rpcrequest')
|
|
|
|
" Ensure that we can load the Python host before bootstrapping
|
|
try
|
|
let s:host = remote#host#Require('legacy-python-provider')
|
|
catch
|
|
let s:err = v:exception
|
|
echohl WarningMsg
|
|
echomsg v:exception
|
|
echohl None
|
|
return
|
|
endtry
|
|
endif
|
|
return call(s:rpcrequest, insert(insert(a:args, 'python_'.a:method), s:host))
|
|
endfunction
|