provider.vim 641 B

12345678910111213141516171819202122232425
  1. " Common functions for providers
  2. " Start the provider and perform a 'poll' request
  3. "
  4. " Returns a valid channel on success
  5. function! provider#Poll(argv, orig_name, log_env, ...) abort
  6. let job = {'rpc': v:true, 'stderr_buffered': v:true}
  7. if a:0
  8. let job = extend(job, a:1)
  9. endif
  10. try
  11. let channel_id = jobstart(a:argv, job)
  12. if channel_id > 0 && rpcrequest(channel_id, 'poll') ==# 'ok'
  13. return channel_id
  14. endif
  15. catch
  16. echomsg v:throwpoint
  17. echomsg v:exception
  18. for row in get(job, 'stderr', [])
  19. echomsg row
  20. endfor
  21. endtry
  22. throw remote#host#LoadErrorForHost(a:orig_name, a:log_env)
  23. endfunction