···
cfg = config.programs.zsh.syntaxHighlighting;
10
-
programs.zsh.syntaxHighlighting = {
11
-
enable = mkEnableOption "zsh-syntax-highlighting";
10
+
programs.zsh.syntaxHighlighting = {
11
+
enable = mkEnableOption "zsh-syntax-highlighting";
13
-
highlighters = mkOption {
14
-
default = [ "main" ];
13
+
highlighters = mkOption {
14
+
default = [ "main" ];
16
-
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
17
-
type = types.listOf(types.enum([
16
+
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
17
+
type = types.listOf(types.enum([
27
-
Specifies the highlighters to be used by zsh-syntax-highlighting.
27
+
Specifies the highlighters to be used by zsh-syntax-highlighting.
29
-
The following defined options can be found here:
30
-
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
29
+
The following defined options can be found here:
30
+
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
34
-
patterns = mkOption {
36
-
type = types.attrsOf types.string;
34
+
patterns = mkOption {
36
+
type = types.attrsOf types.string;
38
-
example = literalExample ''
40
-
"rm -rf *" = "fg=white,bold,bg=red";
38
+
example = literalExample ''
40
+
"rm -rf *" = "fg=white,bold,bg=red";
45
-
Specifies custom patterns to be highlighted by zsh-syntax-highlighting.
45
+
Specifies custom patterns to be highlighted by zsh-syntax-highlighting.
47
-
Please refer to the docs for more information about the usage:
48
-
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/pattern.md
47
+
Please refer to the docs for more information about the usage:
48
+
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/pattern.md
54
-
config = mkIf cfg.enable {
55
-
environment.systemPackages = with pkgs; [ zsh-syntax-highlighting ];
54
+
config = mkIf cfg.enable {
55
+
environment.systemPackages = with pkgs; [ zsh-syntax-highlighting ];
57
-
programs.zsh.interactiveShellInit = with pkgs; with builtins; ''
58
-
source ${zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
60
-
${optionalString (length(cfg.highlighters) > 0)
61
-
"ZSH_HIGHLIGHT_HIGHLIGHTERS=(${concatStringsSep " " cfg.highlighters})"
59
+
assertion = length(attrNames cfg.patterns) > 0 -> elem "pattern" cfg.highlighters;
61
+
When highlighting patterns, "pattern" needs to be included in the list of highlighters.
65
-
n = attrNames cfg.patterns;
67
-
optionalString (length(n) > 0)
68
-
(assert(elem "pattern" cfg.highlighters); (foldl (
72
-
ZSH_HIGHLIGHT_PATTERNS+=('${b}' '${attrByPath [b] "" cfg.patterns}')
66
+
programs.zsh.interactiveShellInit = with pkgs;
67
+
lib.concatStringsSep "\n" ([
68
+
"source ${zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
69
+
] ++ optional (length(cfg.highlighters) > 0)
70
+
"ZSH_HIGHLIGHT_HIGHLIGHTERS=(${concatStringsSep " " cfg.highlighters})"
71
+
++ optionals (length(attrNames cfg.patterns) > 0)
74
+
"ZSH_HIGHLIGHT_PATTERNS+=('${pattern}' '${design}')"