zsh: fix highlighter backwards compatibility

Use the module system to set the default at user prio so that existing
configs don't clear out `main`

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2026-01-26 09:26:29 -06:00
parent c37679d37b
commit d0cdb4101f
2 changed files with 10 additions and 3 deletions

View file

@ -44,11 +44,15 @@ in
highlighters = mkOption {
type = types.listOf types.str;
default = [ "main" ];
default = [ ];
defaultText = ''[ "main" ]'';
example = [ "brackets" ];
description = ''
Highlighters to enable
See the list of highlighters: <https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md>
Note: The "main" highlighter is always included automatically.
If you'd like to exclude it, please configure with a higher priority using `mkForce`.
'';
};
@ -476,6 +480,10 @@ in
{
home.packages = [ cfg.package ] ++ lib.optional cfg.enableCompletion pkgs.nix-zsh-completions;
# NOTE: Always include "main" highlighter with normal priority.
# Option default priority will cause `main` to get dropped by customization.
programs.zsh.syntaxHighlighting.highlighters = lib.mkIf cfg.syntaxHighlighting.enable [ "main" ];
programs.zsh.initContent = lib.mkMerge [
(mkOrder 510 "typeset -U path cdpath fpath manpath")

View file

@ -7,7 +7,6 @@
enable = true;
package = pkgs.hello;
highlighters = [
"main"
"brackets"
"pattern"
"cursor"
@ -19,7 +18,7 @@
nmt.script = ''
assertFileContains home-files/.zshrc "source ${pkgs.hello}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
assertFileContains home-files/.zshrc "ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)"
assertFileContains home-files/.zshrc "ZSH_HIGHLIGHT_HIGHLIGHTERS=(brackets pattern cursor main)"
assertFileContains home-files/.zshrc "ZSH_HIGHLIGHT_STYLES[comment]='fg=#6c6c6c'"
'';
}