Crate duat_base

Crate duat_base 

Source
Expand description

Standard complementary additions to Duat

This crate essentially consists of the standard bits that pretty much every config crate will want to use, but aren’t strictly speaking necessary for Duat to function. This split is mostly to improve compile times, but semantically, if a crate doesn’t need all of these extra things, it is nice to separate them out.

The crate has the following elements:

  • 7 widgets:

    • LineNumbers shows the numbers on a Buffer (for now), and you can configure their alignment, relativeness, etc.
    • The PromptLine lets you run commands and do other things, like incremental search
    • The StatusLine lets you display information that gets updated automatically, it can show information from RwDatas, mapping functions, static elements, and every bit of Duat. It’s syntax, in status! is the same as the txt! macro.
    • Notifications shows things that have been logged to the Logs of Duat, through the error!, warn! and info! macros.
    • LogBook is a log of everything that has been notified to Duat. It is usually more admissive than Notifications, and is most commonly scrolled by the Pager Mode.
    • Completions is Duat’s completion widget, it provides an extensible completions list, which allows you to format the entries and add new providers via the CompletionsProvider trait. Right now, the only CompletionsProvider is the words provider.
    • WhichKey shows what each key will do. It shows up automatically as you are typing and multi key sequences are expected (e.g. Vim’s c, d, f and others).
  • 3 modes:

    • Prompt is a multitool that can serve many purposes, through the PromptMode trait, which allows one to act on the PromptLine while abstracting over less important elements of the Widget.
    • Pager is a simple, read only Mode, designed for scrolling and searching through Widgets, most commonly the LogBook.
  • For the PromptLine, there are 4 PromptModes:

    • RunCommands will interpret and run Duat commands, with syntax highlighting for correctness, defined by the Parameter trait.
    • PipeSelections will pipe each selection on the current Buffer, replacing them with the return value from a shell command.
    • IncSearch is a specialized mode used for incremental search, which can abstract over what the search actually does with the IncSearcher trait.
  • For IncSearch, there are 4 IncSearchers:

    • SearchFwd will move each Cursor to the next match.
    • SearchRev will move each Cursor to the previous match.
    • ExtendFwd will extend each Cursor’s selections to the next match.
    • ExtendRev will extend each Cursor’s selections to the previous match.

Note that the IncSearcher trait can be used for many more interesting things, like in duat-kak for example, where its implementors allow for splitting selections, selecting everything within a range, and many more such things in the future.

And finally, there is the state module, which contains a bunch of StatusLine parts for you to customize the StatusLine with.

I would consider this crate essential for all configs of Duat out there, since it defines primitives that are not only hard to replace, but might also be very extensible by plugins in the ecosystem.

Modules§

hooks
Additional hooks for duat-base specific things
modes
Additional Modes for Duat
state
Common items in a StatusLine
widgets
Core Widgets for usage in Duat