aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Hynes <nhynes@mit.edu>2015-06-24 19:18:44 -0400
committerJustin M. Keyes <justinkz@gmail.com>2015-06-25 19:01:38 -0400
commit105b8f10707580dc9f20a52c71de77d57143f64e (patch)
treec8e67289c41702df0e157e8124c1af07ca3c0fb0
parent34a5efd7a9a5c093207ab9d235719de546ff7479 (diff)
downloadrneovim-105b8f10707580dc9f20a52c71de77d57143f64e.tar.gz
rneovim-105b8f10707580dc9f20a52c71de77d57143f64e.tar.bz2
rneovim-105b8f10707580dc9f20a52c71de77d57143f64e.zip
rplugin: allow users to register hosts #2896
-rw-r--r--runtime/autoload/remote/host.vim18
-rw-r--r--test/functional/runtime/autoload/remote/define_spec.lua2
2 files changed, 9 insertions, 11 deletions
diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim
index a8b505d096..5a3097af5d 100644
--- a/runtime/autoload/remote/host.vim
+++ b/runtime/autoload/remote/host.vim
@@ -1,15 +1,13 @@
let s:hosts = {}
-let s:plugin_patterns = {
- \ 'python': '*.py',
- \ 'python3': '*.py',
- \ }
+let s:plugin_patterns = {}
let s:remote_plugins_manifest = fnamemodify($MYVIMRC, ':p:h')
\.'/.'.fnamemodify($MYVIMRC, ':t').'-rplugin~'
" Register a host by associating it with a factory(funcref)
-function! remote#host#Register(name, factory)
+function! remote#host#Register(name, pattern, factory)
let s:hosts[a:name] = {'factory': a:factory, 'channel': 0, 'initialized': 0}
+ let s:plugin_patterns[a:name] = a:pattern
if type(a:factory) == type(1) && a:factory
" Passed a channel directly
let s:hosts[a:name].channel = a:factory
@@ -71,7 +69,7 @@ endfunction
" The third item in a declaration is a boolean: non zero means the command,
" autocommand or function will be executed synchronously with rpcrequest.
function! remote#host#RegisterPlugin(host, path, specs)
- let plugins = s:PluginsForHost(a:host)
+ let plugins = remote#host#PluginsForHost(a:host)
for plugin in plugins
if plugin.path == a:path
@@ -180,7 +178,7 @@ command! UpdateRemotePlugins call s:UpdateRemotePlugins()
let s:plugins_for_host = {}
-function! s:PluginsForHost(host)
+function! remote#host#PluginsForHost(host)
if !has_key(s:plugins_for_host, a:host)
let s:plugins_for_host[a:host] = []
end
@@ -200,7 +198,7 @@ function! s:RequirePythonHost(name)
let args = ['-c', 'import neovim; neovim.start_host()']
" Collect registered Python plugins into args
- let python_plugins = s:PluginsForHost(a:name)
+ let python_plugins = remote#host#PluginsForHost(a:name)
for plugin in python_plugins
call add(args, plugin.path)
endfor
@@ -222,6 +220,6 @@ function! s:RequirePythonHost(name)
\ 'See also ~/.nvimlog.'
endfunction
-call remote#host#Register('python', function('s:RequirePythonHost'))
-call remote#host#Register('python3', function('s:RequirePythonHost'))
+call remote#host#Register('python', '*.py', function('s:RequirePythonHost'))
+call remote#host#Register('python3', '*.py', function('s:RequirePythonHost'))
" }}}
diff --git a/test/functional/runtime/autoload/remote/define_spec.lua b/test/functional/runtime/autoload/remote/define_spec.lua
index 53da47243c..9b97ed84d9 100644
--- a/test/functional/runtime/autoload/remote/define_spec.lua
+++ b/test/functional/runtime/autoload/remote/define_spec.lua
@@ -346,7 +346,7 @@ local function host()
end
local function register()
- eval('remote#host#Register("busted", '..channel()..')')
+ eval('remote#host#Register("busted", "busted", '..channel()..')')
end
command_specs_for('remote#define#CommandOnChannel', true, channel)