vim-node-rpc


Ⅰ. 插件描述

Make vim behavior like neovim rpc server by use node server in the middle.

Ⅱ. 基本信息

创建日期:  2018-07-18
使用用户:  5
Github星:  40
插件作者:  neoclide

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'neoclide/vim-node-rpc'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'neoclide/vim-node-rpc'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'neoclide/vim-node-rpc'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/neoclide/vim-node-rpc

Ⅳ. 文档说明

# vim-node-rpc

This module is made to make vim start a messagepack server as neovim
does, so that neovim remote plugins could work for vim.

Tested on vim 8.1.150, could works, but still W.I.P.

Install

If you're using coc.nvim, you don't need
this module any more.

How it works

group

gif

Play with it

Install nodejs and yarn

Install python-client (used for testing) by:

pip install pynvim

Start testing service by:

./start.sh

Now you can control your vim with python-client from neovim.

Have fun.

API

  • nvim#rpc#start_server() start server.
  • nvim#rpc#check_client({clientId}) check if clientId available.
  • nvim#rpc#request({clientId}, {method}, [{arguments}]) send request.
  • nvim#rpc#notify({clientId}, {method}, [{arguments}]) send notification.

The clientId would be send to client on method nvim_api_get_info as
channelId of neovim.

A client can connect to exists RPC server by listen to $NVIM_LISTEN_ADDRESS
like neovim client.

Limitation

There're some methods that no clear way to implement for vim:

  • nvim_execute_lua
  • nvim_input
  • nvim_buf_attach
  • nvim_buf_detach
  • nvim_get_hl_by_name
  • nvim_get_hl_by_id
  • nvim_buf_get_keymap
  • nvim_buf_get_commands
  • nvim_buf_add_highlight
  • nvim_buf_clear_highlight
  • nvim_replace_termcodes
  • nvim_subscribe
  • nvim_unsubscribe
  • nvim_get_color_by_name
  • nvim_get_color_map
  • nvim_get_keymap
  • nvim_get_commands
  • nvim_get_chan_info
  • nvim_list_chans
  • nvim_parse_expression
  • nvim_get_proc_children
  • nvim_get_proc

Some methods requires python support of vim to work, you should either have
has('python') or has('python3') to 1 with vim.

Performance

Here's the performance data on my mac use CPU: 2.6 GHz Intel Core i7

Request data from vim:

  • 1Mb around 13ms
  • 100kb < 5ms
  • 10kb < 1ms

Request data from server:

  • 1Mb around 53ms
  • 100kb < 7ms
  • 10kb < 2ms

LICENSE

MIT

添加新评论