Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify remote plugins #567

Open
justinmk opened this issue Apr 23, 2024 · 0 comments
Open

simplify remote plugins #567

justinmk opened this issue Apr 23, 2024 · 0 comments

Comments

@justinmk
Copy link
Member

justinmk commented Apr 23, 2024

Problem

The design, and usage, of remote plugins can be simplified, as described in neovim/neovim#27949

tl;dr:

  • remove the concept of "remote plugins"
  • instead, any python module that imports pynvim can call set_handler('foo', myFunction) to handle the "foo" request from Nvim
  • "remote plugins" become plain old Lua plugins which call RPC methods on the python module

Solution

  • Apply the above proposal to pynvim.
  • Deprecate the old rplugin interface.
  • Provide a migration script or documentation for old rplugins.

Reference

Implementation in node-client: neovim/node-client#344

Related work here (this Nvim RPC application does not use rplugins, it sets up its own RPC methods which can be called from the Nvim peer): https://github.com/b0o/blender.nvim/blob/eb495c3d7217efb4bdec4e50d1f9be1372d33e2c/blender_nvim/rpc.py#L115-L127

Since I'm attaching to neovim from an external python program, not as an rplugin, pynvim doesn't start its event loop by default. So I'm spawning a new thread, and starting pynvim's event loop on it. I'm also registering request/notification handlers which I call when pynvim receives RPC messages from neovim. I'm using an "executor" to run the registered callbacks on the main thread. It's working great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant