Crates.io | duat |
lib.rs | duat |
version | 0.6.1 |
created_at | 2023-10-31 04:18:35.585254+00 |
updated_at | 2025-08-20 14:22:13.238501+00 |
description | A Highly customizable text editor, configured through the use of a rust crate. |
homepage | |
repository | https://github.com/AhoyISki/duat |
max_upload_size | |
id | 1019342 |
size | 155,175 |
Duat is a text editor meant to have as much modularity as
possible, while keeping a sensible default configuration. It is
written and configured in Rust, through the use of a
configuration Rust crate, placed in ~/.config/duat/
(or wherever
$XDG_CONFIG_HOME
is set to).
When installing Duat, this crate will be automatically placed in that spot, and it will have a default example configuration.
When you first run Duat, and whenever you update the configuration, it will be compiled and reloaded automatically, so you can see the changes in almost real time. Initially, building Duat and its configuration crate might take a few minutes. And the first reload might also take a similar amount of time. But whenever you make new changes, the next reloads should take only about a second (for debug profile) and ~3 seconds (for release profile).
Note that this is an alpha project, so there may be some quirks and bugs. So if you have a problem, or something seems confusing, feel free to ask questions or raise an issue, that would be very welcome đĽ°.
To install Duat, I am assuming that you have cargo
installed on
your system, if you donât, install it. Additionally, youâre
going to need the nightly toolchain installed, since Duat requires
many nightly features:
rustup install nightly
Also, in order to run duat, you should add ~/.cargo/bin/
to your
$PATH
variable. Alternatively, you can just add
~/.cargo/bin/duat
, if you want to add just duat
to the
$PATH
. Now, you can install duat:
cargo install duat
Although, since this is an alpha, I would recommend the git version, since that is kept much more up to date:
cargo install --git https://github.com/AhoyISki/duat --force --features git-deps
And if you want to nuke your config in order to get the newest default config crate, you can do the following:
rm -rf ~/.config/duat
cargo install --git https://github.com/AhoyISki/duat --force --features git-deps
In the configuration file, there should be a setup_duat!
macro,
which takes in a function with no parameters.
This function is the setup for duat, and it can be empty, which is the equivalent of the default configuration for Duat.
Hereâs an example configuration file, which makes use of the
duat-kak
crate, which is a plugin for Duat. This plugin, like
all others, is included without the duat_
prefix, so in the
config it is just kak
.
setup_duat!(setup);
use duat::prelude::*;
use kak::Kak;
use match_pairs::MatchPairs;
use treesitter::TreeSitter;
fn setup() {
plug!(TreeSitter, MatchPairs, Kak::new());
map::<kak::Insert>("jk", "<Esc>");
print::wrap_on_edge();
hook::add::<LineNumbers<Ui>>(|pa, (line_nums, _)| {
line_nums.align_right().align_main_left()
});
hook::remove("WindowWidgets");
hook::add::<WindowCreated>(|pa, builder| {
let upper_mode = mode_name(pa).map(pa, |m| match m.split_once('<') {
Some((no_generics, _)) => no_generics.to_uppercase(),
None => m.to_uppercase(),
});
let status_line = status!("[Mode]{upper_mode}{Spacer}{file_txt} {sels_txt} {main_txt}");
builder.push(FooterWidgets::new(status_line));
});
hook::add::<ModeSwitched>(|_, (_, new)| match new {
"Insert" => cursor::set_main(CursorShape::SteadyBar),
_ => cursor::set_main(CursorShape::SteadyBlock),
});
form::set("Mode", Form::dark_magenta());
}
This configuration does the following things:
Kak
plugin, which changes the default mode, and
the TreeSitter
plugin, which adds syntax highlighting and is
also used by the Kak
plugin;Insert
mode;LineNumbers
Widget
;mode_name
), a command line, and a
notifications widget to the bottom of the screen through a
widget combo;These are some of the ways you can configure Duat. You might notice some things that can be done with these simple options:
use duat::prelude::*;
hook::add::<File>(|_, (cfg, builder)| {
builder.push(VertRule::cfg());
builder.push(LineNumbers::cfg());
builder.push(VertRule::cfg().on_the_right());
builder.push(LineNumbers::cfg().on_the_right());
cfg
});
Now, every file will open with two lines of numbers, one on each side. Would you ever want to do this? âŚNo, not really, but it shows how configurable Duat can be.
Duat also comes with a fully fledged text creation system, which significantly eases the creation of widgets:
let text = txt!("[my_form]Waow it's my form![]not anymore đ˘").build();
In this example, Iâm using the âmy_formâ form in order to style
the text, while []
reverts back to the âdefaultâ form. Double
[[
and ]]
escape the [
and ]
, just like in println!
.
The status!
macro works similarly.
Duat also has a simple command system, that lets you add commands
with arguments supported by Rustâs type system. As an example,
this command will change the numbering of a LineNumbers
widget, switching between absolute and relative numbering.
These issues asume that you are working with the --git-deps
version of duat
Try running this in ~/.config/duat
:
cargo clean && cargo update && cargo build --release
This could solve inconsistencies in the API, given that it could change without the plugins being aware of those changes.
In this case, you should open an issue with the error message that
cargo build --release
sent you.
For now, since duat is using dlopen
, itâs unfortunatelly just
going to happen from time to time. It should work correctly if you
reopen though.
This should be a problem of the past with #9, however.
This is an indication that your installed version of duat became
incompatible with that of your config. Rerun the installation
process, no need to remove ~/.config/duat
.
In that case open an issue
When you install duat, the default config crate will come with some preinstalled plugins:
duat-kak
is a plugin that changes the default mode of Duat
to one inspired by Kakouneâs âNormalâ, also bringing with it
various other modes from Kakoune.duat-catppuccin
is a just a simple colorscheme plugin, it
adds the four flavors from the catppuccin colorscheme. You can
pick between the four of them, you can apply its colors to other
Form
s and you can allow or disallow the colorscheme to set
the background color.duat-treesitter
brings tree-sitter to Duat in the form of
syntax highlighting and indentation calculation, which can be
used by Modes (such as those from duat-kak
) in order to give
better feedback when editing files.You can, of course, unplug these by not calling plug!
, or you
could remove them entirely by taking them out of the
Cargo.toml
âs dependencies section.
Duat provides a lot of features, trying to be as configurable as possible, here are some of the things that Duat is capable of:
Additionally, by choosing Rust as its configuration language, Duat also gains the following features:
These are the goals that have been accomplished or are on their way:
ď¸
NOTE: These are not set in stone, and may be done out of order.
I donât know what your personal reasoning would be, but in my case, I really like Kakouneâs editing model, but was frustrated with the lack of some features, like folding, multiple file editing, the general barebonesness of the configuration, etc.
I know that Neovim has all of these features, and Helix supposedly tries to solve some of these issues. But I donât really like either of their editing styles to be honest.
And so I thought, why not make my own text editor?
I thought, why not make a text editor that is as modular as possible, while still having a sensible default configuration? That I could modify however I wanted, and with a language that I love?
Thatâs why I decided to create Duat.
idk, cool sounding word that I got from Spelunky 2.
Also, just wanted to say that no AI was used in this project, cuz I donât like it.