aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload/provider
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/autoload/provider')
-rw-r--r--runtime/autoload/provider/clipboard.vim10
-rw-r--r--runtime/autoload/provider/python.vim2
-rw-r--r--runtime/autoload/provider/python3.vim2
-rw-r--r--runtime/autoload/provider/pythonx.vim25
-rw-r--r--runtime/autoload/provider/ruby.vim50
-rw-r--r--runtime/autoload/provider/script_host.rb8
6 files changed, 70 insertions, 27 deletions
diff --git a/runtime/autoload/provider/clipboard.vim b/runtime/autoload/provider/clipboard.vim
index c7cb14ded7..0f4aa78ddd 100644
--- a/runtime/autoload/provider/clipboard.vim
+++ b/runtime/autoload/provider/clipboard.vim
@@ -58,18 +58,17 @@ elseif executable('doitclient')
let s:copy['*'] = s:copy['+']
let s:paste['*'] = s:paste['+']
else
- echom 'clipboard: No clipboard tool available. See :help nvim-clipboard'
+ echom 'clipboard: No clipboard tool available. See :help clipboard'
finish
endif
let s:clipboard = {}
function! s:clipboard.get(reg)
- let reg = a:reg == '"' ? '+' : a:reg
- if s:selections[reg].owner > 0
- return s:selections[reg].data
+ if s:selections[a:reg].owner > 0
+ return s:selections[a:reg].data
end
- return s:try_cmd(s:paste[reg])
+ return s:try_cmd(s:paste[a:reg])
endfunction
function! s:clipboard.set(lines, regtype, reg)
@@ -94,6 +93,7 @@ function! s:clipboard.set(lines, regtype, reg)
let selection.data = [a:lines, a:regtype]
let argv = split(s:copy[a:reg], " ")
let selection.detach = s:cache_enabled
+ let selection.cwd = "/"
let jobid = jobstart(argv, selection)
if jobid <= 0
echohl WarningMsg
diff --git a/runtime/autoload/provider/python.vim b/runtime/autoload/provider/python.vim
index cb9d5c5296..b99a046375 100644
--- a/runtime/autoload/provider/python.vim
+++ b/runtime/autoload/provider/python.vim
@@ -1,5 +1,5 @@
" The Python provider uses a Python host to emulate an environment for running
-" python-vim plugins. See ":help nvim-provider" for more information.
+" python-vim plugins. See ":help provider".
"
" Associating the plugin with the Python host is the first step because plugins
" will be passed as command-line arguments
diff --git a/runtime/autoload/provider/python3.vim b/runtime/autoload/provider/python3.vim
index f4a751e7a2..4f47a03a9b 100644
--- a/runtime/autoload/provider/python3.vim
+++ b/runtime/autoload/provider/python3.vim
@@ -1,5 +1,5 @@
" The Python3 provider uses a Python3 host to emulate an environment for running
-" python3 plugins. See ":help nvim-provider" for more information.
+" python3 plugins. See ":help provider".
"
" Associating the plugin with the Python3 host is the first step because
" plugins will be passed as command-line arguments
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index 05815a4896..0ebf00112f 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -18,9 +18,9 @@ function! provider#pythonx#Require(host) abort
endfor
try
- let channel_id = rpcstart((ver == '2' ?
+ let channel_id = rpcstart((ver ==# '2' ?
\ provider#python#Prog() : provider#python3#Prog()), args)
- if rpcrequest(channel_id, 'poll') == 'ok'
+ if rpcrequest(channel_id, 'poll') ==# 'ok'
return channel_id
endif
catch
@@ -70,7 +70,7 @@ endfunction
function! s:check_interpreter(prog, major_ver, skip) abort
let prog_path = exepath(a:prog)
- if prog_path == ''
+ if prog_path ==# ''
return [0, a:prog . ' not found in search path or not executable.']
endif
@@ -83,8 +83,8 @@ function! s:check_interpreter(prog, major_ver, skip) abort
" Try to load neovim module, and output Python version.
" Return codes:
" 0 Neovim module can be loaded.
- " 1 Something else went wrong.
" 2 Neovim module cannot be loaded.
+ " Otherwise something else went wrong (e.g. 1 or 127).
let prog_ver = system([ a:prog , '-c' ,
\ 'import sys; ' .
\ 'sys.path.remove(""); ' .
@@ -93,7 +93,8 @@ function! s:check_interpreter(prog, major_ver, skip) abort
\ 'exit(2*int(pkgutil.get_loader("neovim") is None))'
\ ])
- if prog_ver
+ if v:shell_error == 2 || v:shell_error == 0
+ " Check version only for expected return codes.
if prog_ver !~ '^' . a:major_ver
return [0, prog_path . ' is Python ' . prog_ver . ' and cannot provide Python '
\ . a:major_ver . '.']
@@ -103,12 +104,16 @@ function! s:check_interpreter(prog, major_ver, skip) abort
endif
endif
- if v:shell_error == 1
+ if v:shell_error == 2
+ return [0, prog_path . ' does not have the neovim module installed. '
+ \ . 'See ":help provider-python".']
+ elseif v:shell_error == 127
+ " This can happen with pyenv's shims.
+ return [0, prog_path . ' does not exist: ' . prog_ver]
+ elseif v:shell_error
return [0, 'Checking ' . prog_path . ' caused an unknown error. '
- \ . 'Please report this at github.com/neovim/neovim.']
- elseif v:shell_error == 2
- return [0, prog_path . ' does have not have the neovim module installed. '
- \ . 'See ":help nvim-python".']
+ \ . '(' . v:shell_error . ', output: ' . prog_ver . ')'
+ \ . ' Please report this at github.com/neovim/neovim.']
endif
return [1, '']
diff --git a/runtime/autoload/provider/ruby.vim b/runtime/autoload/provider/ruby.vim
index aad8c09d28..e9130b98c1 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,43 @@ 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 = 'Cannot find the neovim RubyGem. Try :CheckHealth'
+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