Crates.io | duat |
lib.rs | duat |
version | |
source | src |
created_at | 2023-10-31 04:18:35.585254 |
updated_at | 2024-11-12 00:53:52.000181 |
description | A Highly customizable text editor, configured through the use of a rust crate. |
homepage | https://github.com/AhoyISki/duat |
repository | |
max_upload_size | |
id | 1019342 |
Cargo.toml error: | TOML parse error at line 23, column 1 | 23 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Duat is a text editor with Rust as its configuration language. It
makes use of a configuration crate in the user’s ~/.config
directory. This configuration crate works just like a regular Rust
crate, but it is dynamically loaded by Duat and executed on
startup.
When installed, Duat will be able to automatically detect changes in the user’s configuration, adapting to them automatically, with a very short delay.
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:
In order to use it, you must have cargo
installed. If you do,
run
cargo install duat
This will install the default version of Duat, which uses a
terminal user interface. It will also create a configuration
directory in $XDG_CONFIG_HOME/duat/
or ~/.config/duat/
. This
config will have some default changes, but you can modify it as
you wish. It also has some documentation explaining the basics of
Duat.
For now, it has a barebones configuration, which is based on Kakoune, so if you are familiar with that text editor, many of the cmd are going to be the same.
In the configuration file, there should be a setup_duat!
macro.
This macro takes in a function pointer and executes it as setup
for Duat.
Here’s an example configuration file, which makes use of
duat-kak
setup_duat!(setup);
use duat::prelude::*;
use duat_kak::{Insert, Normal};
fn setup() {
mode::set_default(Normal);
map::<Insert>("jk", "<Esc>");
print::wrap_on_width();
hooks::remove("FileWidgets");
hooks::add::<OnFileOpen>(|builder| {
builder.push(VertRule::cfg());
builder.push(LineNumbers::cfg());
});
hooks::remove("WindowWidgets");
hooks::add::<OnWindowOpen>(|builder| {
let status = status!(
[File] { File::name } " "
mode " " selections_fmt " " main_fmt
);
let (child, _) = builder.push(status);
builder.push_to(CmdLine::cfg().left_ratioed(3, 7), child);
});
hooks::add::<ModeSwitched>(|&(_, new)| match new {
"Insert" => cursor::set_main(CursorShape::SteadyBar),
_ => cursor::set_main(CursorShape::SteadyBlock)
});
forms::set("Mode", Form::dark_magenta());
}
This configuration does the following things:
Normal
;These are some of the ways you can configure Duat. You might notice some things that can be done with these simple options:
hooks::add::<OnFileOpen>(|builder| {
builder.push(LineNumbers::cfg());
builder.push(LineNumbers::cfg());
builder.push(LineNumbers::cfg().on_the_right());
builder.push(LineNumbers::cfg().on_the_right());
});
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 styling system, which significantly eases the creation of widgets:
let text = text!([MyForm] "Waow it's my form! " [] "not anymore 😢");
In this example, I’m using the “MyForm” form in order to style the
text, while []
reverts back to the “Default” form. The
status!
macro works similarly.
Duat also has a simple command system, that lets you add cmd with arguments supported by Rust’s type system:
let callers = ["collapse-command-line", "collapse-cmd"];
cmd::add_for::<CmdLine>(
callers,
|_command_line, area, _cursors, _flags, _args| {
area.constrain_ver(Constraint::Length(0.0))?;
Ok(None)
},
)
The 2 arguments
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 is why I decided to embark on this journey.
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.