zsh: add patterns option to syntax-highlighting

This commit is contained in:
Icy-Thought 2024-02-08 15:17:24 +01:00 committed by Robert Helgesson
parent b004e47e03
commit c781b28add
No known key found for this signature in database
GPG Key ID: 96E745BD17AA17ED
2 changed files with 16 additions and 0 deletions

View File

@ -236,6 +236,16 @@ let
'';
};
patterns = mkOption {
type = types.attrsOf types.str;
default = {};
example = { "rm -rf *" = "fg=white,bold,bg=red"; };
description = ''
Custom syntax highlighting for user-defined patterns.
Reference: <https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/pattern.md>
'';
};
styles = mkOption {
type = types.attrsOf types.str;
default = {};
@ -673,6 +683,11 @@ in
(name: value: "ZSH_HIGHLIGHT_STYLES+=(${lib.escapeShellArg name} ${lib.escapeShellArg value})")
cfg.syntaxHighlighting.styles
)}
${lib.concatStringsSep "\n" (
lib.mapAttrsToList
(name: value: "ZSH_HIGHLIGHT_PATTERNS+=(${lib.escapeShellArg name} ${lib.escapeShellArg value})")
cfg.syntaxHighlighting.patterns
)}
'')
(optionalString (cfg.historySubstringSearch.enable or false)

View File

@ -11,6 +11,7 @@ with lib;
package = pkgs.hello;
highlighters = [ "brackets" "pattern" "cursor" ];
styles.comment = "fg=#6c6c6c";
patterns."rm -rf *" = "fg=white,bold,bg=red";
};
};