duat-sneak

Crates.ioduat-sneak
lib.rsduat-sneak
version0.2.0
created_at2025-06-25 20:00:53.889905+00
updated_at2025-08-20 13:49:14.949638+00
descriptionA Duat plugin for finding character sequences, inspired by vim-sneak
homepage
repositoryhttps://github.com/AhoyISki/duat-sneak
max_upload_size
id1726356
size913,161
ahoyiski (AhoyISki)

documentation

README

duat-sneak License: AGPL-3.0-or-later duat-sneak on crates.io duat-sneak on docs.rs Source Code Repository

sneak demonstration

A duat Mode for searching for character sequences

This is a plugin inspired by vim-sneak, which is a kind of extension to the regular f/t key bindings in vim. This one is similar to it, but implemented for Duat instead

Installation

Just like other Duat plugins, this one can be installed by calling cargo add in the config directory:

cargo add duat-sneak@"*" --rename sneak

Or, if you are using a --git-deps version of duat, do this:

cargo add --git https://github.com/AhoyISki/duat-sneak --rename sneak

Usage

In order to make use of it, just add the following to your setup function:

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

fn setup() {
    plug!(Sneak::new());
}

With the above call, you will map the s key in User Mode to the Sneak mode, you can also do that manually:

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

fn setup() {
    map::<User>("s", Sneak::new());
}

In the Sneak mode, these are the available key sequences:

  • {char0}{char1}: Highlight any instance of the string {char0}{char1} on screen. If there is only one instance, it will be selected immediately, returning to the default mode. If there are multiple instances, one entry will be selected, and typing does the following:

  • Any other key will pick the last {char0}{char1} sequence and use that. If there was no previous sequence, just returns to the default mode.

More Options

Note: The following options can be used when plugging the mode as well.

map::<User>("s", Sneak::new().select_keys(',', ';').with_len(3));

Instead of switching with the regular keys, ; selects the previous entry and , selects the next. Additionally, this will select three characters instead of just two.

Labels

If there are too many matches, switching to a far away match could be tedious, so you can do the following instead:

map::<User>("s", Sneak::new().min_for_labels(8));

Now, if there are 8 or more matches, instead of switching to them via n and N, labels with one character will show up on each match. If you type the character in a label, all other labels will be filtered out, until there is only one label left, at which point it will be selected and you’ll return to the default mode.

Forms

When plugging Sneak this crate sets two Forms:

  • "sneak.match", which is set to "default.info"

  • "sneak.label", which is set to "accent.info"

Commit count: 17

cargo fmt