summary refs log tree commit diff
path: root/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2017-04-29 13:15:42 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2017-05-01 20:58:56 +0200
commitf6e612bb8f75b1dc8516339a08c9edd4c05d0964 (patch)
tree33d066f23f407557b81fa743e4fc46801c481aad /nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
parent92f53af64d0be1c9a61924b45910c41da7a6d03e (diff)
downloadnixpkgs-f6e612bb8f75b1dc8516339a08c9edd4c05d0964.tar
nixpkgs-f6e612bb8f75b1dc8516339a08c9edd4c05d0964.tar.gz
nixpkgs-f6e612bb8f75b1dc8516339a08c9edd4c05d0964.tar.bz2
nixpkgs-f6e612bb8f75b1dc8516339a08c9edd4c05d0964.tar.lz
nixpkgs-f6e612bb8f75b1dc8516339a08c9edd4c05d0964.tar.xz
nixpkgs-f6e612bb8f75b1dc8516339a08c9edd4c05d0964.tar.zst
nixpkgs-f6e612bb8f75b1dc8516339a08c9edd4c05d0964.zip
programs.zsh.syntax-highlighting: support custom highlighting patterns
see https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/pattern.md
for further reference.
Diffstat (limited to 'nixos/modules/programs/zsh/zsh-syntax-highlighting.nix')
-rw-r--r--nixos/modules/programs/zsh/zsh-syntax-highlighting.nix28
1 files changed, 28 insertions, 0 deletions
diff --git a/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix b/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
index fde241ca3ce..e5246bb4260 100644
--- a/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
+++ b/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
@@ -36,6 +36,24 @@ in
             https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
           '';
         };
+
+        patterns = mkOption {
+          default = [];
+          type = types.listOf(types.listOf(types.string));
+
+          example = literalExample ''
+            [
+              ["rm -rf *" "fg=white,bold,bg=red"]
+            ]
+          '';
+
+          description = ''
+            Specifies custom patterns to be highlighted by zsh-syntax-highlighting.
+
+            Please refer to the docs for more information about the usage:
+            https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/pattern.md
+          '';
+        };
       };
     };
 
@@ -48,6 +66,16 @@ in
         ${optionalString (length(cfg.highlighters) > 0)
           "ZSH_HIGHLIGHT_HIGHLIGHTERS=(${concatStringsSep " " cfg.highlighters})"
         }
+
+        ${optionalString (length(cfg.patterns) > 0)
+          (assert(elem "pattern" cfg.highlighters); (foldl (
+            a: b:
+              assert(length(b) == 2); ''
+                ${a}
+                ZSH_HIGHLIGHT_PATTERNS+=('${elemAt b 0}' '${elemAt b 1}')
+              ''
+          ) "") cfg.patterns)
+        }
       '';
     };
   }