[Media] I've been working on a text editor that is written and configured in Rust. Is there any interest in this?

390 points AhoyISki 94 comments
[Media] I've been working on a text editor that is written and configured in Rust. Is there any interest in this?

So, I've been working on a text editor (link here) for an embarrassingly long amount of time. It is written and configured in Rust. Here's a configuration example:

setup_duat!(setup);
use duat::prelude::*;

fn setup() {
    plug!(
        treesitter::TreeSitter,
        match_pairs::MatchPairs::new(),
        kak::Kak::new()
    );

    map::<kak::Insert>("jk", "<Esc>");

    print::wrap_on_edge();

    // Modify every LineNumbers
    hook::add::<LineNumbers<Ui>>(|_, (cfg, _)| {
        cfg.align_right().align_main_left()
    });

    hook::add::<StatusLine<Ui>>(|pa, (cfg, _)| {
        cfg.fmt(status!(
            "{name_txt}{Spacer}{}[sep]|{sels_txt}[sep]|{main_txt}",
            mode_txt(pa)
        ))
    });

    form::set("sep", Form::with("#506090"));
}

This file does quite a lot of things: It adds three plugins, maps jk to Esc, changes wrapping, realigns LineNumbers, changes the StatusLine and sets a custom Form.

There are various benefits to using Rust as a config language:

  • Cargo is the plugin manager, and crates.io is the plugin repository;
  • Traits can act like a "guide" on how to extend functionality;
  • People can have a fun excuse to finally learn Rust;

I have also worked really hard to reduce many of the known drawbacks:

  • Hot reloading: This problem was solved by following advice from a fasterthanlime post about it;
  • Compile times: Duat reloads in ~2s give or take, but my computer is a fairly old model;
  • Boilerplate: Due to Rust's expressiveness, code can often end up shorter than on "simpler languages";

At the moment, there are some big parts missing (floating widgets, LSP...). Even still, Duat is already incredibly extensible. Here's a short list of some of the things that can be done:

  • Custom widgets through the Widget trait;
  • Modes that control the Widgets and can replicate any multi-cursor text editor's behavior;
  • A convenient Text struct, supporting styles, alignment, spacers, concealment and "ghost text", all with the same Tag API.
  • A really easy to use StatusLine, which can be modded and updated arbitrarily;
  • Custom hooks with the Hookable trait;

Duat is thoroughly documented, and I am currently working on an mdBook guide to gently introduce people to the API. Although at the moment that's still nowhere near complete.

So yeah, the question in the title. What are your thoughts on this project? Is there any interest in this sort of thing? Should I keep working on it? Because there is a lot of work still to be done, and I don't really know if it is worth it to be completely honest.

P.s. I don't want to steal valor, this text editor is heavily inspired by Kakoune. In fact, the modes of the kak::Kak Plugin are a (still incomplete) mimicry of those in Kakoune.