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

RPC-based Plugin System #998

Closed
kirawi opened this issue Nov 6, 2021 · 6 comments
Closed

RPC-based Plugin System #998

kirawi opened this issue Nov 6, 2021 · 6 comments
Labels
A-plugin Area: Plugin system C-discussion Category: Discussion or questions that doesn't represent real issues C-enhancement Category: Improvements

Comments

@kirawi
Copy link
Member

kirawi commented Nov 6, 2021

In addition to #122, it would be nice to make it possible to implement plugins through an RPC interface like in Neovim. One major benefit from this is that it would make it easier to use scripting languages like Python as the compiler wouldn't need to be compiled down to WebAssembly. Another potential use is that external programs or plugins (not sandboxed) can directly work with Helix. If we accept this as a feature we'd like for Helix to have, I think that it would be best for it to be implemented as a WebAssembly plugin.

See #387 for a real-world use case.

@kirawi kirawi added C-enhancement Category: Improvements A-plugin Area: Plugin system labels Nov 6, 2021
@kirawi kirawi added the C-discussion Category: Discussion or questions that doesn't represent real issues label Nov 6, 2021
@wingyplus
Copy link
Contributor

It looks like LSP architecture but for interacting with editor instead of per language. :)

@jesse-c
Copy link

jesse-c commented Feb 7, 2022

If it's okay, I'll add my real-world use case that I have with Neovim.

I switch from light/dark appearance in macOS depending on a few factors [1]. I've written a little binary [2] that runs and listens for appearance change events and then tells Neovim [3] to change the theme to the appropriate light/dark one.

[1] macOS default change based on sunrise/sunset, but also just depending on the weather and lighting where ever I currently am.
[2] https://github.com/jesse-c/AppearanceNotifier
[2] https://github.com/mhinz/neovim-remote

@gcoakes
Copy link
Contributor

gcoakes commented Feb 28, 2022

Can we just implement a dead simple pipe based interface which will be trivial to maintain over the long term even when a more complex plugin system gets implemented? I'm thinking something like a pipe file which is read line-wise as a command. It would go through the same code flow as manually entering a command, but the actual command would just be sourced from the pipe. helix is already dependent upon tokio already has an API for this, and it could just be tacted onto the application event loop.

Something like this seems like it would be easy to maintain. It could be kept in even after a more robust plugin system has been implemented because it's low cost. For some tasks, this might even be preferable to writing a full plugin as it is easily automated by end users. You wouldn't have to understand the inner working of helix's plugin system to automate a simple task. You just have to understand the commands available.

Something like this would reload the theme when it is written to which will improve designer experience:

while :; do
  inotifywait -e modify ~/.config/helix/themes/mytheme.toml
  find "${XDG_RUNTIME_DIR-/tmp}/helix/pipes" -mindepth 1 \
  | while read hxpipe; do
    echo 'theme mytheme' > "$hxpipe"
  done
done

@nathaniel-brough
Copy link

Just to chime in gRPC might be a good option. It can be run over various transports e.g. pipes/sockets or http. It also has client-server generators for multiple languages including rust.

@Xaeroxe
Copy link
Contributor

Xaeroxe commented Oct 17, 2022

Shameless plug, but my crate ipc-rpc seems like it might actually be a pretty good fit here. Built in serde support, and helix already uses tokio. Plus ipc-rpc is multiplatform.

@pascalkuthe
Copy link
Member

Closing, see #3806 (reply in thread)

@pascalkuthe pascalkuthe closed this as not planned Won't fix, can't repro, duplicate, stale Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-plugin Area: Plugin system C-discussion Category: Discussion or questions that doesn't represent real issues C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

7 participants