provider.vim 588 B

12345678910111213141516171819202122
  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. try
  8. let channel_id = jobstart(a:argv, job)
  9. if channel_id > 0 && rpcrequest(channel_id, 'poll') ==# 'ok'
  10. return channel_id
  11. endif
  12. catch
  13. echomsg v:throwpoint
  14. echomsg v:exception
  15. for row in get(job, 'stderr', [])
  16. echomsg row
  17. endfor
  18. endtry
  19. throw remote#host#LoadErrorForHost(a:orig_name, a:log_env)
  20. endfunction