From d0cdb4101f2d004a8da95c282cd6c7631bb87b36 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Mon, 26 Jan 2026 09:26:29 -0600 Subject: [PATCH] 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 --- modules/programs/zsh/default.nix | 10 +++++++++- tests/modules/programs/zsh/syntax-highlighting.nix | 3 +-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index bbc3a846..e7f209e8 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -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: + + 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") diff --git a/tests/modules/programs/zsh/syntax-highlighting.nix b/tests/modules/programs/zsh/syntax-highlighting.nix index 4e7d3fde..89e4547a 100644 --- a/tests/modules/programs/zsh/syntax-highlighting.nix +++ b/tests/modules/programs/zsh/syntax-highlighting.nix @@ -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'" ''; }