helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.44k stars 2.48k forks source link

Support RPC through a socket. #387

Closed jneem closed 2 years ago

jneem commented 3 years ago

vim (and neovim) allow you to send commands to the editor through a socket (see, e.g. the nvim docs). This is very useful for scripting. For example, the main thing I want it for right now is for synctex support

CBenoit commented 3 years ago

It's likely that we'll not use this approach for scripting, but a WASM plugins sytem instead. If RPC is absolutely required for a specific use case, it may be provided by a RPC plugin. I'll actually add this on my list of things to try with the plugins system.

jneem commented 3 years ago

Sure, that makes sense. Just to be clear about the use case, the workflow is:

  1. I'm working on a tex file in the editor, and I compile it to a pdf.
  2. I open the pdf in a pdf viewer.
  3. I click (or Ctrl+click, or whatever) on a part of the pdf, and as a result I expect the editor to jump to that part of the file.

The mechanism that gvim uses to do step 3 is that I configure the tex compiler to include file/line information in the pdf, and then I configure my pdf viewer to run gvim --servername GVIM --remote +%{line} %{input} when clicked. Rather than opening a new editor, this command communicates (via a socket) with an existing instance of the editor and tells it to jump to some specified line. neovim does something similar, but with a rather richer msgpack API.

I don't think having WASM plugins solves this on its own, although I guess it should be possible to write a WASM plugin that listens on a socket, as long as the plugins aren't sandboxed too tightly. (A quick google suggests that sockets aren't yet supported in WASI, but maybe that will come...)

CBenoit commented 3 years ago

Thank you for the details. I actually really like this feature and hope to achieve it with Helix in a way or another. As you mentioned, it may be limited at first, but I'm not worried support for networking will greatly improve over time. In the meantime we could even expose host functions for that. In fact, if WASI and networking is not a thing by the time I need it, I'll definitely try this.

kirawi commented 2 years ago

Subsumed by #998

petertheprocess commented 4 months ago

After crawling all the related issues and discussions, I found out it seems the RPC solution is not planned to be supported. However I really like and need this latex inverse-search use-case, is there any alternative solution to achieve that in 2024? @jneem