| Crates.io | duat-match-pairs |
| lib.rs | duat-match-pairs |
| version | 0.2.0 |
| created_at | 2025-08-20 14:17:34.078437+00 |
| updated_at | 2025-08-20 14:17:34.078437+00 |
| description | A duat plugin to highlight matched pairs |
| homepage | |
| repository | https://github.com/AhoyISki/duat-match-pairs |
| max_upload_size | |
| id | 1803477 |
| size | 80,746 |
A simple Plugin to match pairs of parentheses
This Plugin is added on the config crate by default, there is
no need to install it. However, if you have uninstalled it and
need to reinstall, you can do the following:
cargo add duat-match-pairs@"*" --rename match-pairs
Or, if you are using a --git-deps version of duat, do this:
cargo add --git https://github.com/AhoyISki/duat-match-pairs --rename match-pairs
In order to make use of it, just add the following to your setup
function:
setup_duat!(setup);
use duat::prelude::*;
fn setup() {
plug!(match_pairs::MatchPairs::new());
}
In this plugin, there are two types of “pairs”, these are the normal pairs and the treesitter pairs. The normal pairs match based on the content of the text itself, so for example, in this situation:
let my_string = "(this is my string)";
There is a normal pair within the string of (,). However,
there is no treesitter pair in there, because a treesitter pair
only matches if the pairs are on the language’s syntax tree.
This distinction allows for some combination of pairings that can
also be used as non pairs. For example, in Rust, <,> is a pair
only on type arguments and things of the sort, in other cases, it
is just a comparison operator. That’s where the treesitter pairs
come in, as they can identify when it is an actual pair, or just
the operator.
In order to change what counts as a normal pair and what counts as a treesitter pair, you can add the following to the setup function:
setup_duat!(setup);
use duat::prelude::*;
fn setup() {
plug!(
match_pairs::MatchPairs::new()
.match_pairs([["\\(", "\\)"], ["\\{", "\\}"], ["\\[", "\\]"]])
.match_ts_pairs([["<", ">"], ["|", "|"]])
);
}
Two things to note here:
For now, normal pairs only support one character regexes.
Also for now, normal pairs use regex, while treesitter pairs use strings.