Ⅰ. 插件描述
simple request and notification call for (neo)vimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'iamcco/sran-nvim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'iamcco/sran-nvim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'iamcco/sran-nvim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/iamcco/sran.nvim
Ⅳ. 文档说明
<p align="center">

<p align="center">
Simple Request And Notification</p>
</p>
The easiest way to write remote plugin for (neo)vim by javascript
Using neovim's node-client you can
write remote plugin really easy through javascript. But most of time i just
want to run an async function to fetch some data or other stuff, and sran.nvim
is for the situation and also support vim by
vim-node-rpc.
Install
It works on vim >= 8.1 and neovim
" use pre build
Plug 'iamcco/sran.nvim', { 'do': { -> sran#util#install() } }
" use node.js and yarn
Plug 'iamcco/sran.nvim', { 'do': 'yarn' }Hello world
plugin structure
your-plugin-dir
-> rplugin
-> sran
-> hello-world.js // or javascript dir packagehello-world.js
module.exports = function (plugin) {
const nvim = plugin.nvim
nvim.on('notification', (method, args) => {
if (method === 'hello_world') {
setTimeout(() => {
nvim.command('echo "hello world"')
}, 2000)
}
})
}install sran.nvim and your plugin
Plug 'iamcco/sran.nvim', { 'do': { -> sran#util#install() } }
Plug 'your-account/your-plugin-name'now
:call sran#rpc#notify('hello_world')then you will see hello world message in the command line after 2 seconds.
use
requestfor sync
About
- sran.nvim will use builtin node.js binary if use pre build
builtin packages
- fast-glob
- log4js
- msgpack-lite
- neovim
- node-fetch
- tslib
- cheerio
- rxjs
- findup
so if you use these packages you don't need to install them in your plugin's local directory
javascript Plugin api
viml api
sran#rpc#notifyfor notification callsran#rpc#requestfor request call
Examples
- dict.nvim translate words through google translate api
- git-p.nvim git diff sign and blame line display
- clock.nvim big clock for neovim
Debug
let $NVIM_SRAN_LOG_FILE = expand('~/sran-nvim.log')
let $NVIM_SRAN_LOG_LEVEL = 'debug'Buy Me A Coffee ☕️
