mirror of
https://github.com/neovim/neovim.git
synced 2025-10-26 12:27:24 +00:00
job control: reuse common job code for rpc jobs
This makes stderr and exit callbacks work for rpc jobs
This commit is contained in:
@@ -4,6 +4,17 @@ if exists('g:loaded_ruby_provider')
|
||||
endif
|
||||
let g:loaded_ruby_provider = 1
|
||||
|
||||
let s:stderr = {}
|
||||
let s:job_opts = {'rpc': v:true}
|
||||
|
||||
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#ruby#Detect() abort
|
||||
return exepath('neovim-ruby-host')
|
||||
endfunction
|
||||
@@ -13,7 +24,7 @@ function! provider#ruby#Prog()
|
||||
endfunction
|
||||
|
||||
function! provider#ruby#Require(host) abort
|
||||
let args = []
|
||||
let args = [provider#ruby#Prog()]
|
||||
let ruby_plugins = remote#host#PluginsForHost(a:host.name)
|
||||
|
||||
for plugin in ruby_plugins
|
||||
@@ -21,13 +32,16 @@ function! provider#ruby#Require(host) abort
|
||||
endfor
|
||||
|
||||
try
|
||||
let channel_id = rpcstart(provider#ruby#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_RUBY_LOG_FILE')
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user