neovim / node-client

Nvim Node.js client and plugin host
https://neovim.io/node-client/
MIT License
492 stars 53 forks source link

WIP: redesign "remote plugins", eliminate "host" concept #344

Open justinmk opened 8 months ago

justinmk commented 8 months ago

Problem:

The "remote plugin" concept is too complicated. https://github.com/neovim/neovim/issues/27949

Solution:

TODO

TEST CASE / DEMO:

Invocation

const found = findNvim({ orderBy: 'desc', minVersion: '0.9.0' })
const nvim_proc = child_process.spawn(found.matches[0].path, ['--clean', '--embed'], {});
const nvim = attach({ proc: nvim_proc });
nvim.setHandler('foo', (ev, args) => {
  nvim.logger.info('handled from remote module: "%s": args:%O', ev.name, args);
});
nvim.callFunction('rpcrequest', [(await nvim.channelId), 'foo', [42, true, 'bar']]);

Result

2024-03-26 16:47:35 INF handleRequest: foo
2024-03-26 16:47:35 DBG request received: foo
2024-03-26 16:47:35 INF handled from remote module: "foo": args:[ [ 42, true, 'bar' ] ]