Skip to content

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

Notifications You must be signed in to change notification settings

neoclide/vim-node-rpc

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published