Plugin integration in tui editor

Hi, i'm interested in creating new modal text editor (yes, one more). Tried helix, but i don't like that it is not as flexible/configurable as neovim let's say. And neovim has drawbacks as well.

I don't really like lua. It is simple language but i just can't get a grasp of it. And so my question:
What's my options to integrate plugins in my app?

I though about doing them in rust, but can't imagine how i embed them in app.
Also thought about dynamic libraries, but binary must be compiled/linked against them when building app, so i guess it's not possible.

My only somewhat viable idea is to create plugins as binaries. I don't think it is smart way of doing things as i don't even understand how it could work, but it is probably possible

Just curious if you tried Kakoune, since Helix apparently has a modal design similar to Kakoune, but is less configurable.

I didn't but from what i saw about it, it is not really extensible editor.

Things i don't like in neovim are: Lua, status bar and intro screen
In helix: going to new line when current line end is reached and no plugin system. Also minor but really annoying thing is line number changes from relative to absolute in insert mode. I get that i don't use line numbers in insert mode, but it just flickering every time i change modes

So here i want to create something that will fix those things

If you can learn rust I think you can learn lua, especially for just the basics of configuration (make a table, assign to a variable, call a function, etc) and the statusbar and intro screen (and everything else) is very customizable. There aren't many full featured, battle tested and polished editors. And problems can be found with all of them. Neovim and helix are both great and worth putting in the effort to make either of them work

And if you really want to write your own then maybe you check out what helix is working on for it's future plugin system. Or just fork and contribute to helix?

1 Like

There are quite a lot of options (that all let you write the core editor in Rust):

  • You could use WASM to allow plugin written in any language that can compile to wasm. This could be great for plugins that need fairly high performance. I believe extim is one option that exist for this, though I haven't tried that myself.
  • An embedded scripting might make more sense for quick and dirty user scripting that doesn't need the most performance possible. Lua (using the mlua crate) is one option, but you could use Deno to embed javascript/typescript. Or Rhai, or Rune (both of those are implemented in Rust and made to work well embedded in Rust). There are many more options.
  • You could use dynamic linking with a C API. Something like the crates stabby or abi-stable can help here as Rust doesn't have a stable ABI, but people have added that on top of Rust. A downside in this case is that if a plugin crashes or panics it takes the whole editor down with it.

Existing editors like vscode run a separate plugin host process, the main editor then talks over a fast connection with that (I haven't checked exactly what it uses, but could be things like Unix sockets, pipes or even shared memory). This way you can restart the plugin host separately from the main editor. There are several crates focused on this sort of IPC (inter process communication). Iceoryx2 and Zenoh comes to mind, though I don't know if they are ideal for this use case or too overbuilt. I'm pretty sure I have seen others, but I can't think of their names.

1 Like

The wasm and rhai options look interesting to me. I found rim. Relatively small repo to understand the basics of how to do things if anyone intersted.

I don't really understand how wasm works and how do i even use it, but will definitely give it a shot

I would suggest that learning one thing at a time is easier. So try just learning Rust first by reading the online book and doing the rustlings course. Then write with some simple cli tool go get the basics down. Then make a simple TUI or GUI text editor to learn that. Learn about rope data structures etc that is needed for this. Then start looking at stuff like syntax highlighting, plugins and so on.

Yeah. I did rustlings a while ago and it was really helpful. Also books like The book and rust for rustaceans were gamechangers
Btw first time i heard of rope data structures. Gonna look into them.

Thanks for help