aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload/provider/pythonx.vim
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2016-05-12 22:25:15 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2016-08-20 12:55:35 +0200
commit2d60a15e25f487eda1ac00a9e6cdf9a6564fb416 (patch)
tree7844b2d185b27a0303183e90792a5ef807933e88 /runtime/autoload/provider/pythonx.vim
parent215922120c43163f4e1cc00851bd1b86890d3a28 (diff)
downloadrneovim-2d60a15e25f487eda1ac00a9e6cdf9a6564fb416.tar.gz
rneovim-2d60a15e25f487eda1ac00a9e6cdf9a6564fb416.tar.bz2
rneovim-2d60a15e25f487eda1ac00a9e6cdf9a6564fb416.zip
job control: reuse common job code for rpc jobs
This makes stderr and exit callbacks work for rpc jobs
Diffstat (limited to 'runtime/autoload/provider/pythonx.vim')
-rw-r--r--runtime/autoload/provider/pythonx.vim21
1 files changed, 18 insertions, 3 deletions
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index 0ebf00112f..6d6b38978c 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -5,11 +5,24 @@ endif
let s:loaded_pythonx_provider = 1
+let s:stderr = {}
+let s:job_opts = {'rpc': v:true}
+
+" TODO(bfredl): this logic is common and should be builtin
+function! s:job_opts.on_stderr(chan_id, data, event)
+ let stderr = get(s:stderr, a:chan_id, [''])
+ let last = remove(stderr, -1)
+ let a:data[0] = last.a:data[0]
+ call extend(stderr, a:data)
+ let s:stderr[a:chan_id] = stderr
+endfunction
+
function! provider#pythonx#Require(host) abort
let ver = (a:host.orig_name ==# 'python') ? 2 : 3
" Python host arguments
- let args = ['-c', 'import sys; sys.path.remove(""); import neovim; neovim.start_host()']
+ let prog = (ver == '2' ? provider#python#Prog() : provider#python3#Prog())
+ let args = [prog, '-c', 'import sys; sys.path.remove(""); import neovim; neovim.start_host()']
" Collect registered Python plugins into args
let python_plugins = remote#host#PluginsForHost(a:host.name)
@@ -18,14 +31,16 @@ function! provider#pythonx#Require(host) abort
endfor
try
- let channel_id = rpcstart((ver ==# '2' ?
- \ provider#python#Prog() : provider#python3#Prog()), args)
+ let channel_id = jobstart(args, s:job_opts)
if rpcrequest(channel_id, 'poll') ==# 'ok'
return channel_id
endif
catch
echomsg v:throwpoint
echomsg v:exception
+ for row in get(s:stderr, channel_id, [])
+ echomsg row
+ endfor
endtry
throw remote#host#LoadErrorForHost(a:host.orig_name,
\ '$NVIM_PYTHON_LOG_FILE')