diff options
author | Alex Genco <alexgenco@gmail.com> | 2016-07-02 21:45:48 -0700 |
---|---|---|
committer | Alex Genco <alexgenco@gmail.com> | 2016-07-02 21:45:48 -0700 |
commit | 0a3c0205c5b9043d371133297439a11e0186585d (patch) | |
tree | 3db1e35b8e2371289a0d37e3f1384bf6541e6780 /runtime | |
parent | f80eb768c75de2065626203de001738e1dda436e (diff) | |
download | rneovim-0a3c0205c5b9043d371133297439a11e0186585d.tar.gz rneovim-0a3c0205c5b9043d371133297439a11e0186585d.tar.bz2 rneovim-0a3c0205c5b9043d371133297439a11e0186585d.zip |
Add :ruby, :rubyfile, and :rubydo ex commands
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/provider/ruby.vim | 51 | ||||
-rw-r--r-- | runtime/autoload/provider/script_host.rb | 8 |
2 files changed, 49 insertions, 10 deletions
diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim index aad8c09d28..c57bb94e7a 100644 --- a/runtime/autoload/provider/ruby.vim +++ b/runtime/autoload/provider/ruby.vim @@ -1,12 +1,18 @@ " The Ruby provider helper -if exists('s:loaded_ruby_provider') +if exists('g:loaded_ruby_provider') finish endif +let g:loaded_ruby_provider = 1 -let s:loaded_ruby_provider = 1 +function! provider#ruby#Detect() abort + return exepath('neovim-ruby-host') +endfunction + +function! provider#ruby#Prog() + return s:prog +endfunction function! provider#ruby#Require(host) abort - " Collect registered Ruby plugins into args let args = [] let ruby_plugins = remote#host#PluginsForHost(a:host.name) @@ -16,19 +22,44 @@ function! provider#ruby#Require(host) abort try let channel_id = rpcstart(provider#ruby#Prog(), args) - - if rpcrequest(channel_id, 'poll') == 'ok' + if rpcrequest(channel_id, 'poll') ==# 'ok' return channel_id endif catch echomsg v:throwpoint echomsg v:exception endtry - - throw remote#host#LoadErrorForHost(a:host.orig_name, - \ '$NVIM_RUBY_LOG_FILE') + throw remote#host#LoadErrorForHost(a:host.orig_name, '$NVIM_RUBY_LOG_FILE') endfunction -function! provider#ruby#Prog() abort - return 'neovim-ruby-host' +function! provider#ruby#Call(method, args) + if s:err != '' + echoerr s:err + return + endif + + if !exists('s:host') + try + let s:host = remote#host#Require('legacy-ruby-provider') + catch + let s:err = v:exception + echohl WarningMsg + echomsg v:exception + echohl None + return + endtry + endif + return call('rpcrequest', insert(insert(a:args, 'ruby_'.a:method), s:host)) endfunction + +let s:err = '' +let s:prog = provider#ruby#Detect() +let s:plugin_path = expand('<sfile>:p:h') . '/script_host.rb' + +if empty(s:prog) + let s:err = 'Couldn''t find the neovim RubyGem. ' . + \ 'Install it with `gem install neovim`.' +endif + +call remote#host#RegisterClone('legacy-ruby-provider', 'ruby') +call remote#host#RegisterPlugin('legacy-ruby-provider', s:plugin_path, []) diff --git a/runtime/autoload/provider/script_host.rb b/runtime/autoload/provider/script_host.rb new file mode 100644 index 0000000000..1dade766c7 --- /dev/null +++ b/runtime/autoload/provider/script_host.rb @@ -0,0 +1,8 @@ +begin + require "neovim/ruby_provider" +rescue LoadError + warn( + "Your neovim RubyGem is missing or out of date. " + + "Install the latest version using `gem install neovim`." + ) +end |