diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2016-03-02 05:06:36 +0900 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-03-10 10:34:57 -0500 |
commit | bb020df0f52c3eec6cb84ce1a786fa3a90904815 (patch) | |
tree | 8200a9af36101fe23085e90b683bf090627512e5 /runtime/autoload/provider/pythonx.vim | |
parent | e7485ab1c969bb4077db42be92473a8923bb1e08 (diff) | |
download | rneovim-bb020df0f52c3eec6cb84ce1a786fa3a90904815.tar.gz rneovim-bb020df0f52c3eec6cb84ce1a786fa3a90904815.tar.bz2 rneovim-bb020df0f52c3eec6cb84ce1a786fa3a90904815.zip |
rplugin: Initialize remote plugins lazily. #4384
Diffstat (limited to 'runtime/autoload/provider/pythonx.vim')
-rw-r--r-- | runtime/autoload/provider/pythonx.vim | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim index 022ef19914..2a8e2d1de1 100644 --- a/runtime/autoload/provider/pythonx.vim +++ b/runtime/autoload/provider/pythonx.vim @@ -5,6 +5,37 @@ endif let s:loaded_pythonx_provider = 1 +function! provider#pythonx#Require(host) abort + let ver = (a:host.orig_name ==# 'python') ? 2 : 3 + + " Python host arguments + let args = ['-c', 'import sys; sys.path.remove(""); import neovim; neovim.start_host()'] + + " Collect registered Python plugins into args + let python_plugins = remote#host#PluginsForHost(a:host.name) + for plugin in python_plugins + call add(args, plugin.path) + endfor + + try + let channel_id = rpcstart((ver == '2' ? + \ provider#python#Prog() : provider#python3#Prog()), args) + if rpcrequest(channel_id, 'poll') == 'ok' + return channel_id + endif + catch + echomsg v:throwpoint + echomsg v:exception + endtry + throw 'Failed to load '. a:host.orig_name . ' host. '. + \ 'You can try to see what happened '. + \ 'by starting Neovim with the environment variable '. + \ '$NVIM_PYTHON_LOG_FILE set to a file and opening '. + \ 'the generated log file. Also, the host stderr will be available '. + \ 'in Neovim log, so it may contain useful information. '. + \ 'See also ~/.nvimlog.' +endfunction + function! provider#pythonx#Detect(major_ver) abort let host_var = (a:major_ver == 2) ? \ 'g:python_host_prog' : 'g:python3_host_prog' |