Crates.io | duat-sneak |
lib.rs | duat-sneak |
version | 0.2.0 |
created_at | 2025-06-25 20:00:53.889905+00 |
updated_at | 2025-08-20 13:49:14.949638+00 |
description | A Duat plugin for finding character sequences, inspired by vim-sneak |
homepage | |
repository | https://github.com/AhoyISki/duat-sneak |
max_upload_size | |
id | 1726356 |
size | 913,161 |
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
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
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:
n
for the next entryN
for the previous entry if mode::alt_is_reverse()
is
false
<A-n>
for the previous entry if mode::alt_is_reverse()
is true
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.
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.
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.
When plugging Sneak
this crate sets two Form
s:
"sneak.match"
, which is set to "default.info"
"sneak.label"
, which is set to "accent.info"