git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #25323 from Ma27/zsh/support-pattern-highlighters

programs.zsh.syntax-highlighting: support custom highlighting patterns

commit4c576fd9469201a866e06db91251e9e710bf82fe authorJörg Thalheim <Mic92@users.noreply.github.com> dateMon 1 May 2017, 22:23 (10 years ago) parentb99007df6e612b
1 file changed+28
nixos/modules/programs/zsh/zsh-syntax-highlighting.nix+28
nixos/modules/programs/zsh/zsh-syntax-highlighting.nix+28
@@ -36,6 +36,24 @@ in
3636 https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
3737 '';
3838 };
39+
40+ patterns = mkOption {
41+ default = [];
42+ type = types.listOf(types.listOf(types.string));
43+
44+ example = literalExample ''
45+ [
46+ ["rm -rf *" "fg=white,bold,bg=red"]
47+ ]
48+ '';
49+
50+ description = ''
51+ Specifies custom patterns to be highlighted by zsh-syntax-highlighting.
52+
53+ Please refer to the docs for more information about the usage:
54+ https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/pattern.md
55+ '';
56+ };
3957 };
4058 };
4159
@@ -48,6 +66,16 @@ in
4866 ${optionalString (length(cfg.highlighters) > 0)
4967 "ZSH_HIGHLIGHT_HIGHLIGHTERS=(${concatStringsSep " " cfg.highlighters})"
5068 }
69+
70+ ${optionalString (length(cfg.patterns) > 0)
71+ (assert(elem "pattern" cfg.highlighters); (foldl (
72+ a: b:
73+ assert(length(b) == 2); ''
74+ ${a}
75+ ZSH_HIGHLIGHT_PATTERNS+=('${elemAt b 0}' '${elemAt b 1}')
76+ ''
77+ ) "") cfg.patterns)
78+ }
5179 '';
5280 };
5381 }