
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
neovim-client
Advanced tools
npm install --global neovim-client
This package exports a single attach() function which takes a pair of
write/read streams and invokes a callback with a Nvim API object. This is
similar to node-msgpack5rpc, but
it provides an automatically generated API.
Additionally, a Promise-based API may be obtained using require('neovim-client/promise').
var cp = require('child_process'),
attach = require('neovim-client'),
nvim_proc = cp.spawn('nvim', ['-u', 'NONE', '-N', '--embed'], {})
attach(nvim_proc.stdin, nvim_proc.stdout, function(err, nvim) {
nvim.on('request', function(method, args, resp) {
// handle msgpack-rpc request
})
nvim.on('notification', function(method, args) {
// handle msgpack-rpc notification
})
nvim.command('vsp', function(err, res) {
nvim.getWindows(function(err, windows) {
console.log(windows.length) // 2
console.log(windows[0] instanceof nvim.Window) // true
console.log(windows[1] instanceof nvim.Window) // true
nvim.setCurrentWindow(windows[1], function(err, res) {
nvim.getCurrentWindow(function(err, win) {
console.log(win.equals(windows[1])) // true
nvim.quit()
nvim.on('disconnect', function() {
console.log("Nvim exited!")
})
})
})
})
})
})
or, using Promises:
var cp = require('child_process'),
attach = require('neovim-client/promise'),
nvim_proc = cp.spawn('nvim', ['-u', 'NONE', '-N', '--embed'], {}),
nvim
attach(nvim_proc.stdin, nvim_proc.stdout)
.then(function(_nvim) {
nvim = _nvim
return nvim.command('vsp')
})
.then(function(res) {
return nvim.getWindows()
})
.then(function(windows) {
console.log(windows.length) // 2
console.log(windows[0] instanceof nvim.Window) // true
console.log(windows[1] instanceof nvim.Window) // true
return nvim.setCurrentWindow(windows[1])
.then(function(res) {
return nvim.getCurrentWindow()
})
.then(function(win) {
console.log(win.equals(windows[1]))
nvim.on('disconnect', function() {
console.log("Nvim exited!")
})
nvim.quit()
})
})
.catch(function(err) {
console.error(err)
nvim.quit()
})
Methods are attached to buffers, windows and tabpages according to the msgpack-rpc name:
nvim.getCurrentBuffer(function(err, buf) {
console.log(buf instanceof nvim.Buffer) // true
buf.getLineSlice(0, -1, true, true, function(err, lines) {
console.log(lines) // ['']
buf.setLineSlice(0, -1, true, true, ['line1', 'line2'], function(err) {
buf.getLineSlice(0, -1, true, true, function(err, lines) {
console.log(lines) // ['line1', 'line2']
})
})
})
})
A typescript declaration file is available as documentation of the API and also for typescript users that seek to use this library. Note that the interfaces are automatically generated at a certain point in time, and may not correspond exactly to the API of your installed Nvim.
FAQs
Neovim client library
We found that neovim-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.