plugins/utils: normalize plugin defaults

This commit is contained in:
Matt Sturgeon 2024-06-11 16:54:57 +01:00
parent b10a391bd0
commit 6ab2a39e6a
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
53 changed files with 1434 additions and 1221 deletions

View file

@ -43,64 +43,62 @@ in
Whether to consider case in search patterns.
'';
equivalenceClasses =
helpers.defaultNullOpts.mkNullable (with types; listOf (either str (listOf str))) ''[" \t\r\n"]''
''
A character will match any other in its equivalence class. The sets can
either be defined as strings or tables.
equivalenceClasses = helpers.defaultNullOpts.mkListOf' {
type = with types; either str (listOf str);
description = ''
A character will match any other in its equivalence class. The sets can
either be defined as strings or tables.
Example:
```nix
[
"\r\n"
")]}>"
"([{<"
[ "\"" "'" "`" ]
]
```
Note: Make sure to have a set containing `\n` if you want to be able to
target characters at the end of the line.
Note: Make sure to have a set containing `\n` if you want to be able to
target characters at the end of the line.
Note: Non-mutual aliases are not possible in Leap, for the same reason
that supporting |smartcase| is not possible: we would need to show two
different labels, corresponding to two different futures, at the same
time.
'';
pluginDefault = [ " \t\r\n" ];
example = [
"\r\n"
")]}>"
"([{<"
[
"\""
"'"
"`"
]
];
};
Note: Non-mutual aliases are not possible in Leap, for the same reason
that supporting |smartcase| is not possible: we would need to show two
different labels, corresponding to two different futures, at the same
time.
'';
substituteChars = helpers.defaultNullOpts.mkAttrsOf' {
type = types.str;
description = ''
The keys in this attrs will be substituted in labels and highlighted matches by the given
characters.
This way special (e.g. whitespace) characters can be made visible in matches, or even be
used as labels.
'';
pluginDefault = { };
example = {
"\r" = "¬";
};
};
substituteChars = helpers.defaultNullOpts.mkNullable (with types; attrsOf str) "{}" ''
The keys in this attrs will be substituted in labels and highlighted matches by the given
characters.
This way special (e.g. whitespace) characters can be made visible in matches, or even be
used as labels.
safeLabels = helpers.defaultNullOpts.mkListOf types.str (stringToCharacters "sfnut/SFNLHMUGT?Z") ''
When the number of matches does not exceed the number of these "safe" labels plus one, the
plugin jumps to the first match automatically after entering the pattern.
Obviously, for this purpose you should choose keys that are unlikely to be used right
after a jump!
Example: `{"\r" = "¬";}`
Setting the list to `[]` effectively disables the autojump feature.
Note: Operator-pending mode ignores this, since we need to be able to select the actual
target before executing the operation.
'';
safeLabels =
helpers.defaultNullOpts.mkNullable (with types; listOf str)
''["s" "f" "n" "u" "t" "/" "S" "F" "N" "L" "H" "M" "U" "G" "T" "?" "Z"]''
''
When the number of matches does not exceed the number of these "safe" labels plus one, the
plugin jumps to the first match automatically after entering the pattern.
Obviously, for this purpose you should choose keys that are unlikely to be used right
after a jump!
Setting the list to `[]` effectively disables the autojump feature.
Note: Operator-pending mode ignores this, since we need to be able to select the actual
target before executing the operation.
'';
labels =
helpers.defaultNullOpts.mkNullable (with types; listOf str)
''
[
"s" "f" "n" "j" "k" "l" "h" "o" "d" "w" "e" "m" "b" "u" "y" "v" "r" "g" "t" "c" "x" "/"
"z" "S" "F" "N" "J" "K" "L" "H" "O" "D" "W" "E" "M" "B" "U" "Y" "V" "R" "G" "T" "C" "X"
"?" "Z"
]
''
helpers.defaultNullOpts.mkListOf types.str
(stringToCharacters "sfnjklhodwembuyvrgtcx/zSFNJKLHODWEMBUYVRGTCX?Z")
''
Target labels to be used when there are more matches than labels in
`|leap.opts.safe_labels|` plus one.