• This repository has been archived on 23/Jul/2024
  • Stars
    star
    219
  • Rank 181,133 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

EXPERIMENTAL

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 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

screencast

Requirements

  1. vim8
  2. If has('pythonx') and set pyxversion=3
    • same requirements as 4. has('python3')
  3. Else if has('pythonx') and set pyxversion=2
    • same requirements as 5. has('python')
  4. Else if has('python3')
    • pynvim
    • Pynvim is normally installed by :py3 import pip; pip.main(['install', '--user', 'pynvim']) or python3 -m pip install pynvim. If you are a win32 user, be careful that your python install and your vim install should both the same architecture (both 64bit or both 32).
    • There should be no error for at least one of :python3 import pynvim and :python3 import neovim
  5. 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 pynvim and :python3 import neovim
  6. set encoding=utf-8 in 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_stdout
  • on_stderr
  • on_exit
  • detach

Incompatibility issues

  • Cannot pass Funcref object to python client. Pass function name instead.
  • Python None will be converted to '' instead of v:null into vimscript. See vim#2246
  • The following neovim-only API will be ignored quietly:
    • nvim_buf_add_highlight
    • nvim_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β”‚
β””β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”˜

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"

More Repositories

1

nvim-completion-manager

⚠️ PLEASE USE https://github.com/ncm2/ncm2 INSTEAD
Python
927
star
2

vim-tmux-clipboard

seamless integration for vim and tmux's clipboard
Vim Script
272
star
3

nvim-yarp

Yet Another Remote Plugin Framework for Neovim
Vim Script
228
star
4

easymake

A handy makefile for simple C/C++ applications
Makefile
136
star
5

vim-paste-easy

Automatically set paste for you
Vim Script
99
star
6

SMS-Forward

A very simple Android SMS forwardning APP. [NOT MAINTAINING]
Java
79
star
7

cpp_learn

PHP
69
star
8

LanguageServer-php-neovim

Vim Script
39
star
9

ncm-clang

DEPRECATED use https://github.com/ncm2/ncm2-pyclang instead
Python
29
star
10

envrc-rs

Auto source bash .envrc of your workspace
Rust
29
star
11

python-support.nvim

[DEPRECATED] use a single command :PythonSupportInit to initialize python support for neovim.
Vim Script
25
star
12

nvim-cm-tern

Python
24
star
13

SimpleAutoComplPop

Please use https://github.com/ncm2/ncm2 instead
Vim Script
22
star
14

nvim-cm-racer

Neovim/vim8 completion for rust
Python
17
star
15

vim-window-resize-easy

Vim Script
17
star
16

ncm-phpactor

USE https://github.com/phpactor/ncm2-phpactor FOR NCM2!
Python
13
star
17

ncm-github

[DEPRECATED] use https://github.com/ncm2/ncm2-github instead
Python
11
star
18

vim-syntax-compl-pop

Vim Script
9
star
19

vim-encode

Provides simple stirng encode/escape functionality inside vim
Vim Script
8
star
20

ncm-rct-complete

rcodetools source for nvim-completion-manager
Python
4
star
21

nvim-ascript

Vim Script
3
star
22

ncm-flow

flow completion source for nvim-completion-manager
Python
2
star
23

nvim-cm-php-language-server

Vim Script
2
star
24

aps-agent

Application Performance Statistics
C++
1
star
25

tmux-yank.el

Emacs Lisp
1
star
26

modus-themes

Forked from https://gitlab.com/protesilaos/modus-themes
Emacs Lisp
1
star
27

ncm-elm-oracle

elm-oracle source for nvim-completion-manager
Python
1
star
28

stm32f1-blinky

A Minimal Project Template for STM32F10x Development on Linux
C
1
star