diff options
| author | ZyX <kp-pav@yandex.ru> | 2017-11-19 22:05:22 +0300 |
|---|---|---|
| committer | ZyX <kp-pav@yandex.ru> | 2017-11-19 22:05:22 +0300 |
| commit | 03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f (patch) | |
| tree | a3a05c99fe20de98aafbdea9314aa0d76f71aee9 /runtime/autoload/provider | |
| parent | 6ea3a08fdbb276fe64dda60c5fb934360327ed39 (diff) | |
| parent | de8b1fd1dee5a91b2893fccc53cfd11631ccba38 (diff) | |
| download | rneovim-03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f.tar.gz rneovim-03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f.tar.bz2 rneovim-03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f.zip | |
Merge branch 'master' into expression-parser
Diffstat (limited to 'runtime/autoload/provider')
| -rw-r--r-- | runtime/autoload/provider/node.vim | 80 | ||||
| -rw-r--r-- | runtime/autoload/provider/ruby.vim | 2 |
2 files changed, 81 insertions, 1 deletions
diff --git a/runtime/autoload/provider/node.vim b/runtime/autoload/provider/node.vim new file mode 100644 index 0000000000..b08ad4f316 --- /dev/null +++ b/runtime/autoload/provider/node.vim @@ -0,0 +1,80 @@ +if exists('g:loaded_node_provider') + finish +endif +let g:loaded_node_provider = 1 + +let s:job_opts = {'rpc': v:true, 'on_stderr': function('provider#stderr_collector')} + +function! provider#node#Detect() abort + return has('win32') ? exepath('neovim-node-host.cmd') : exepath('neovim-node-host') +endfunction + +function! provider#node#Prog() + return s:prog +endfunction + +function! provider#node#Require(host) abort + if s:err != '' + echoerr s:err + return + endif + + if has('win32') + let args = provider#node#Prog() + else + let args = ['node'] + + if !empty($NVIM_NODE_HOST_DEBUG) + call add(args, '--inspect-brk') + endif + + call add(args , provider#node#Prog()) + endif + + try + 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 provider#get_stderr(channel_id) + echomsg row + endfor + endtry + finally + call provider#clear_stderr(channel_id) + endtry + throw remote#host#LoadErrorForHost(a:host.orig_name, '$NVIM_NODE_LOG_FILE') +endfunction + +function! provider#node#Call(method, args) + if s:err != '' + echoerr s:err + return + endif + + if !exists('s:host') + try + let s:host = remote#host#Require('node') + catch + let s:err = v:exception + echohl WarningMsg + echomsg v:exception + echohl None + return + endtry + endif + return call('rpcrequest', insert(insert(a:args, 'node_'.a:method), s:host)) +endfunction + + +let s:err = '' +let s:prog = provider#node#Detect() + +if empty(s:prog) + let s:err = 'Cannot find the "neovim" node package. Try :CheckHealth' +endif + +call remote#host#RegisterPlugin('node-provider', 'node', []) diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim index 7df3500267..518a9dc793 100644 --- a/runtime/autoload/provider/ruby.vim +++ b/runtime/autoload/provider/ruby.vim @@ -19,7 +19,7 @@ function! provider#ruby#Detect() abort if exists("g:ruby_host_prog") return g:ruby_host_prog else - return exepath('neovim-ruby-host') + return has('win32') ? exepath('neovim-ruby-host.cmd') : exepath('neovim-ruby-host') end endfunction |