Nvim Node.js客户端插件开发辅助

Nvim 的 Node.js 客户端挺轻便的,尤其适合喜欢折腾 NeoVim 插件的前端。它直接用attach()函数把 Node 进程和 NeoVim 串起来,用起来还挺顺手的。你只要全局装个neovim包,就能跟 NeoVim 打通,挺适合搞自动化、开发辅助插件那类活儿。

跨平台支持也不错,Linux、macOS、Windows 都能跑,CI 覆盖得也比较全,开发环境切换时省心不少。attach()这个 API 设计得也蛮清晰的,不绕弯,直接传读写流就能玩。

比如你可以用child_process启动一个 NeoVim 子进程,通过attach把它接管下来,像这样:

const cp = require('child_process');
const { attach } = require('neovim');

const nvimProc = cp.spawn('nvim', ['--embed']); attach({ proc: nvimProc, onAttach: nvim => { // 可以调用 nvim API 了,比如:nvim.command('echo "Hello from Node.js"'); } });

注意要npm install -g neovim,得装成全局包,不然插件通信会出问题。如果你对 Node 版本有顾虑,可以看看这篇文章,讲得还挺清楚的。

,如果你想搞点 NeoVim 扩展,或者让你的终端编辑器多点交互体验,这工具可以一试。哦对了,用 Node 写 NeoVim 插件还挺有成就感的~

zip
node-client-master.zip 预估大小:99个文件
folder
node-client-master 文件夹
file
.gitignore 79B
file
codecov.yml 228B
file
package.json 1KB
file
.npmrc 19B
file
CHANGELOG.md 801B
file
tsconfig.json 551B
folder
packages 文件夹
folder
neovim 文件夹
file
package.json 3KB
folder
src 文件夹
folder
api 文件夹
file
Buffer.test.ts 15KB
file
Tabpage.ts 1KB
file
Base.ts 5KB
file
Window.ts 4KB
file
Neovim.ts 26KB
file
Window.test.ts 6KB
folder
helpers 文件夹
file
createChainableApi.ts 4KB
file
types.ts 195B
file
Neovim.test.ts 9KB
file
Buffer.ts 11KB
file
index.ts 183B
file
types.ts 653B
file
client.ts 7KB
file
Tabpage.test.ts 4KB
file
plugin.ts 69B
folder
attach 文件夹
file
attach.test.ts 3KB
file
attach.ts 1KB
folder
types 文件夹
file
ApiInfo.ts 606B
file
VimValue.ts 98B
file
Spec.ts 262B
folder
utils 文件夹
folder
types.d.ts 文件夹
file
devnull.ts 149B
file
devnull.test.ts 269B
file
transport.ts 4KB
file
logger.ts 594B
file
buffered.ts 1KB
folder
host 文件夹
file
index.ts 4KB
file
factory.ts 6KB
file
NvimPlugin.ts 6KB
file
NvimPlugin.test.ts 5KB
folder
plugin 文件夹
file
plugin.ts 4KB
file
plugin.test.ts 3KB
file
function.ts 1KB
file
properties.ts 268B
file
autocmd.ts 1KB
file
index.ts 227B
file
command.ts 1KB
folder
type.ts 文件夹
file
index.ts 268B
file
attach.ts 42B
folder
bin 文件夹
file
cli.js 1KB
file
generate-typescript-interfaces.js 3KB
file
CHANGELOG.md 801B
file
tsconfig.json 190B
folder
scripts 文件夹
file
nvim.js 542B
file
api.js 924B
file
findMissingApi.js 3KB
file
.babelrc.js 54B
folder
decorators 文件夹
file
package.json 601B
folder
src 文件夹
folder
plugin 文件夹
file
plugin.ts 3KB
file
function.ts 997B
file
properties.ts 268B
file
autocmd.ts 1KB
file
index.ts 179B
file
command.ts 1KB
file
types.ts 346B
file
index.ts 69B
file
CHANGELOG.md 464B
file
tsconfig.json 261B
folder
example-plugin-decorators 文件夹
file
.babelrc 92B
file
package.json 559B
folder
src 文件夹
file
index.js 1KB
file
fixture.js 29B
file
CHANGELOG.md 494B
folder
example-plugin 文件夹
file
package.json 266B
folder
rplugin 文件夹
folder
node 文件夹
folder
test 文件夹
file
index.js 1KB
file
fixture.js 29B
folder
integration-tests 文件夹
file
package.json 1KB
folder
src 文件夹
file
factory.test.ts 4KB
folder
index.ts 文件夹
file
CHANGELOG.md 478B
file
tsconfig.json 190B
folder
__tests__ 文件夹
file
integration.test.ts 3KB
file
.babelrc.js 54B
file
lerna.json 326B
folder
examples 文件夹
file
decorators.md 836B
file
class.md 402B
file
functional.md 286B
folder
rplugin 文件夹
folder
node 文件夹
folder
nvim-example 文件夹
file
package.json 233B
file
index.js 667B
file
README.md 394B
file
prototype.md 401B
file
LICENSE-MIT 1KB
file
.eslintrc.js 2KB
file
README.md 7KB
file
.eslintignore 36B
file
.babelrc.js 217B
file
azure-pipelines.yml 599B
file
.npmignore 36B
file
.prettierrc 77B
folder
.azure-templates 文件夹
file
yarn-job.yml 2KB
file
yarn.lock 371KB
...
zip 文件大小:224.88KB