From 61ba3c5e31bf5bf491046098e4d9922dd6c3c082 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sat, 25 Nov 2017 10:37:41 +0100 Subject: provider: delete vimL stderr collector, now that it exists builtin --- runtime/autoload/provider/pythonx.vim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'runtime/autoload/provider/pythonx.vim') diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index 7285ed43ea..1c77eabe23 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -5,7 +5,7 @@ endif let s:loaded_pythonx_provider = 1 -let s:job_opts = {'rpc': v:true, 'on_stderr': function('provider#stderr_collector')} +let s:job_opts = {'rpc': v:true, 'stderr_buffered': v:true} function! provider#pythonx#Require(host) abort let ver = (a:host.orig_name ==# 'python') ? 2 : 3 @@ -21,18 +21,17 @@ function! provider#pythonx#Require(host) abort endfor try - let channel_id = jobstart(args, s:job_opts) + let job = copy(s:job_opts) + let channel_id = jobstart(args, job) if rpcrequest(channel_id, 'poll') ==# 'ok' return channel_id endif catch echomsg v:throwpoint echomsg v:exception - for row in provider#get_stderr(channel_id) + for row in job.stderr echomsg row endfor - finally - call provider#clear_stderr(channel_id) endtry throw remote#host#LoadErrorForHost(a:host.orig_name, \ '$NVIM_PYTHON_LOG_FILE') -- cgit From 6fbb8d6739b353752dc405452fb41f9cdf20a0b9 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 16 Feb 2018 13:33:23 -0500 Subject: provider: Safely access job.stderr in #Require If `jobstart()` fails, then the subsequent `rpcrequest()` will throw due to an invalid channel id. This causes `job.stderr` not to exist, so we throw another exception when trying to dump the job's stderr. Error detected while processing function remote#define#AutocmdBootstrap[1]..remote#host#Require[10]..provider#pythonx#Require: line 22: E716: Key not present in Dictionary: stderr This obfuscates the actual problem. --- runtime/autoload/provider/pythonx.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/autoload/provider/pythonx.vim') diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index 1c77eabe23..f9aa09b16b 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -29,7 +29,7 @@ function! provider#pythonx#Require(host) abort catch echomsg v:throwpoint echomsg v:exception - for row in job.stderr + for row in get(job, 'stderr', []) echomsg row endfor endtry -- cgit From 3af3515e74c925c783ad5321589830ed3d54b24a Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 16 Feb 2018 13:53:02 -0500 Subject: Add provider#Poll() to handle starting and polling the provider --- runtime/autoload/provider/pythonx.vim | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'runtime/autoload/provider/pythonx.vim') diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index f9aa09b16b..b51c398410 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -5,8 +5,6 @@ endif let s:loaded_pythonx_provider = 1 -let s:job_opts = {'rpc': v:true, 'stderr_buffered': v:true} - function! provider#pythonx#Require(host) abort let ver = (a:host.orig_name ==# 'python') ? 2 : 3 @@ -20,21 +18,7 @@ function! provider#pythonx#Require(host) abort call add(args, plugin.path) endfor - try - let job = copy(s:job_opts) - let channel_id = jobstart(args, job) - if rpcrequest(channel_id, 'poll') ==# 'ok' - return channel_id - endif - catch - echomsg v:throwpoint - echomsg v:exception - for row in get(job, 'stderr', []) - echomsg row - endfor - endtry - throw remote#host#LoadErrorForHost(a:host.orig_name, - \ '$NVIM_PYTHON_LOG_FILE') + return provider#Poll(args, a:host.orig_name, '$NVIM_PYTHON_LOG_FILE') endfunction function! provider#pythonx#Detect(major_ver) abort -- cgit