Merge pull request #25323 from Ma27/zsh/support-pattern-highlighters
programs.zsh.syntax-highlighting: support custom highlighting patterns
This commit is contained in:
commit
4c576fd946
@ -36,6 +36,24 @@ in
|
|||||||
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
|
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)
|
${optionalString (length(cfg.highlighters) > 0)
|
||||||
"ZSH_HIGHLIGHT_HIGHLIGHTERS=(${concatStringsSep " " cfg.highlighters})"
|
"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)
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user