2015-03-20 15:55:39 -07:00
|
|
|
" The Python provider uses a Python host to emulate an environment for running
|
2017-04-17 16:57:19 -07:00
|
|
|
" python-vim plugins. :help provider
|
2014-11-17 06:48:39 -07:00
|
|
|
"
|
2015-03-20 15:55:39 -07:00
|
|
|
" Associating the plugin with the Python host is the first step because plugins
|
2014-11-17 06:48:39 -07:00
|
|
|
" will be passed as command-line arguments
|
2015-03-20 15:55:39 -07:00
|
|
|
|
2017-02-13 16:00:29 -07:00
|
|
|
if exists('g:loaded_python_provider')
|
2015-03-20 15:55:39 -07:00
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let g:loaded_python_provider = 1
|
|
|
|
|
|
|
|
let [s:prog, s:err] = provider#pythonx#Detect(2)
|
|
|
|
|
|
|
|
function! provider#python#Prog()
|
|
|
|
return s:prog
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! provider#python#Error()
|
|
|
|
return s:err
|
|
|
|
endfunction
|
|
|
|
|
2015-05-04 13:14:54 -07:00
|
|
|
if s:prog == ''
|
|
|
|
" Detection failed
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2015-03-20 15:55:39 -07:00
|
|
|
" The Python provider plugin will run in a separate instance of the Python
|
2014-11-17 06:48:39 -07:00
|
|
|
" host.
|
2014-11-21 06:07:59 -07:00
|
|
|
call remote#host#RegisterClone('legacy-python-provider', 'python')
|
2016-03-06 06:37:53 -07:00
|
|
|
call remote#host#RegisterPlugin('legacy-python-provider', 'script_host.py', [])
|
2014-11-17 06:48:39 -07:00
|
|
|
|
|
|
|
function! provider#python#Call(method, args)
|
2015-05-05 02:22:53 -07:00
|
|
|
if s:err != ''
|
|
|
|
return
|
|
|
|
endif
|
2015-03-20 15:55:39 -07:00
|
|
|
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
|
2015-05-05 02:22:53 -07:00
|
|
|
let s:err = v:exception
|
|
|
|
echohl WarningMsg
|
2015-03-20 15:55:39 -07:00
|
|
|
echomsg v:exception
|
2015-05-05 02:22:53 -07:00
|
|
|
echohl None
|
2015-11-03 08:52:26 -07:00
|
|
|
return
|
2015-03-20 15:55:39 -07:00
|
|
|
endtry
|
|
|
|
endif
|
2014-11-17 06:48:39 -07:00
|
|
|
return call(s:rpcrequest, insert(insert(a:args, 'python_'.a:method), s:host))
|
|
|
|
endfunction
|