1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

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 { styles = mkOption {
type = types.attrsOf types.str; type = types.attrsOf types.str;
default = {}; default = {};
@ -673,6 +683,11 @@ in
(name: value: "ZSH_HIGHLIGHT_STYLES+=(${lib.escapeShellArg name} ${lib.escapeShellArg value})") (name: value: "ZSH_HIGHLIGHT_STYLES+=(${lib.escapeShellArg name} ${lib.escapeShellArg value})")
cfg.syntaxHighlighting.styles 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) (optionalString (cfg.historySubstringSearch.enable or false)

View file

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