Ⅰ. 插件描述
EXPERIMENTALⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'roxma/vim-hug-neovim-rpc'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'roxma/vim-hug-neovim-rpc'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'roxma/vim-hug-neovim-rpc'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/roxma/vim-hug-neovim-rpc
Ⅳ. 文档说明
# vim-hug-neovim-rpc
This is an experimental project, trying to build a compatibility layer for
neovim rpc client working on vim8.
I started this project because I want to fix the [vim8
support](https://github.com/roxma/nvim-completion-manager/issues/14) issue for
nvim-completion-manager.
Since this is a general purpose module, other plugins needing rpc support may
benefit from this project. However, there're many neovim rpc methods I haven't
implemented yet, which make this an experimental plugin. **Please fork and
open a PR if you get any idea on improving it**.
*Tip: for porting neovim rplugin to vim8, you might need
roxma/nvim-yarp*

Requirements
- vim8
If
has('pythonx')andset pyxversion=3- same requirements as
4. has('python3')
- same requirements as
Else if
has('pythonx')andset pyxversion=2- same requirements as
5. has('python')
- same requirements as
Else if
has('python3')- pynvim
Pynvim is normally installed by `:py3 import pip; pip.main(['install',
'--user', 'pynvim'])` or `python3 -m pip install pynvim`.There should be no error for at least one of
:python3 import pynvimand`:python3 import neovim`
Else if
has('python')- pynvim
Pynvim is normally installed by `:py import pip; pip.main(['install',
'--user', 'pynvim'])` or `python2 -m pip install pynvim`.There should be no error for at least one of
:python3 import pynvimand`:python3 import neovim`
set encoding=utf-8in your vimrc.
Use :echo neovim_rpc#serveraddr() to test the installation. It should print
something like 127.0.0.1:51359 or /tmp/vmrUX9X/2.
API
| Function | Similar to neovim's |
|---|---|
neovim_rpc#serveraddr() | v:servername |
neovim_rpc#jobstart(cmd,...) | jobstart({cmd}[, {opts}]) |
neovim_rpc#jobstop(jobid) | jobstop({job}) |
neovim_rpc#rpcnotify(channel,event,...) | rpcnotify({channel}, {event}[, {args}...]) |
neovim_rpc#rpcrequest(channel, event, ...) | rpcrequest({channel}, {method}[, {args}...]) |
Note that neovim_rpc#jobstart only support these options:
on_stdouton_stderron_exitdetach
Incompatibility issues
- Cannot pass
Funcrefobject to python client. Pass function name instead. - Python
Nonewill be converted to''instead ofv:nullinto vimscript.
See vim#2246 The following neovim-only API will be ignored quietly:
nvim_buf_add_highlightnvim_buf_clear_highlight
Overall Implementation
"vim-hug-neovim-rpc - Sequence Diagram"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
┌───┐ ┌──────────┐ ┌───────────┐ ┌──────┐
│VIM│ │VIM Server│ │NVIM Server│ │Client│
└─┬─┘ └────┬─────┘ └─────┬─────┘ └──┬───┘
│ Launch thread │ │ │
│───────────────────> │ │
│ │ │ │
│ Launch thread │ │
│─────────────────────────────────────────────────>│ │
│ │ │ │
│ `ch_open` connect │ │ │
│───────────────────> │ │
│ │ │ │
│ │────┐ │ │
│ │ │ Launch VimHandler thread│ │
│ │<───┘ │ │
│ │ │ │
│ │ │ Connect │
│ │ │<─────────────────────────────
│ │ │ │
│ │ ────┐
│ │ │ Launch NvimHandler thread
│ │ <───┘
│ │ │ │
│ │ │ Request (msgpack rpc) │
│ │ │<─────────────────────────────
│ │ │ │
│ │ ────┐ │
│ │ │ Request enqueue │
│ │ <───┘ │
│ │ │ │
│ │ notify (method call) │ │
│ │ <────────────────────────────│ │
│ │ │ │
│ notify (json rpc) │ │ │
│<─────────────────── │ │
│ │ │ │
────┐ │ │
│ Request dequeue │ │
<───┘ │ │
│ │ │ │
────┐ │ │ │
│ Process │ │ │
<───┘ │ │ │
│ │ │ │
│ │ Send response (msgpack rpc) │
│────────────────────────────────────────────────────────────────────────────────>
┌─┴─┐ ┌────┴─────┐ ┌─────┴─────┐ ┌──┴───┐
│VIM│ │VIM Server│ │NVIM Server│ │Client│
└───┘ └──────────┘ └───────────┘ └──────┘<!--
@startuml
title "vim-hug-neovim-rpc - Sequence Diagram"
VIM -> "VIM Server": Launch thread
VIM -> "NVIM Server": Launch thread
VIM -> "VIM Server": ch_open connect
"VIM Server" -> "VIM Server": Launch VimHandler thread
Client-> "NVIM Server": Connect
"NVIM Server" -> "NVIM Server": Launch NvimHandler thread
Client -> "NVIM Server": Request (msgpack rpc)
"NVIM Server" -> "NVIM Server": Request enqueue
"NVIM Server" -> "VIM Server": notify (method call)
"VIM Server" -> VIM: notify (json rpc)
VIM -> VIM: Request dequeue
VIM -> VIM: Process
VIM -> Client: Send response (msgpack rpc)
@enduml
-->
Debugging
Add logging settigns to your vimrc. Log files will be generated with prefix/tmp/nvim_log. An alternative is to export environment variables before
starting vim/nvim.
let $NVIM_PYTHON_LOG_FILE="/tmp/nvim_log"
let $NVIM_PYTHON_LOG_LEVEL="DEBUG"