Expand description
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 sneakOr, 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::*;
fn setup() {
plug(duat_sneak::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::*;
fn setup() {
map::<User>("s", duat_sneak::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:nfor the next entryNfor the previous entry ifmode::alt_is_reverse()isfalse<A-n>for the previous entry ifmode::alt_is_reverse()istrue- Any other key will select and return to the default mode
-
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.
setup_duat!(setup);
use duat::prelude::*;
use duat_sneak::Sneak;
fn setup() {
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:
setup_duat!(setup);
use duat::prelude::*;
use duat_sneak::Sneak;
fn setup() {
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"