aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload/provider.vim
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2018-02-16 13:53:02 -0500
committerJames McCoy <jamessan@jamessan.com>2018-02-16 14:08:12 -0500
commit3af3515e74c925c783ad5321589830ed3d54b24a (patch)
tree6ccd423804e838719d5eb5124dda27c0b0e5c745 /runtime/autoload/provider.vim
parent6fbb8d6739b353752dc405452fb41f9cdf20a0b9 (diff)
downloadrneovim-3af3515e74c925c783ad5321589830ed3d54b24a.tar.gz
rneovim-3af3515e74c925c783ad5321589830ed3d54b24a.tar.bz2
rneovim-3af3515e74c925c783ad5321589830ed3d54b24a.zip
Add provider#Poll() to handle starting and polling the provider
Diffstat (limited to 'runtime/autoload/provider.vim')
-rw-r--r--runtime/autoload/provider.vim21
1 files changed, 21 insertions, 0 deletions
diff --git a/runtime/autoload/provider.vim b/runtime/autoload/provider.vim
new file mode 100644
index 0000000000..dc24e801d0
--- /dev/null
+++ b/runtime/autoload/provider.vim
@@ -0,0 +1,21 @@
+" Common functions for providers
+
+" Start the provider and perform a 'poll' request
+"
+" Returns a valid channel on success
+function! provider#Poll(argv, orig_name, log_env) abort
+ let job = {'rpc': v:true, 'stderr_buffered': v:true}
+ try
+ let channel_id = jobstart(a:argv, job)
+ if channel_id > 0 && 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:orig_name, a:log_env)
+endfunction