From c37679d37bdbecf11bbe3c5eb238d89ca4f60641 Mon Sep 17 00:00:00 2001 From: "name.tar.xz" <54463026+name-tar-xz@users.noreply.github.com> Date: Mon, 26 Jan 2026 03:12:10 +0000 Subject: [PATCH] zsh: Set highlighters instead of appending to allow disabling main This allows users to drop the main highlighter (or highlighters set by plugins sourced before eg: catppucin's zsh highlighting settings) --- modules/programs/zsh/default.nix | 4 ++-- tests/modules/programs/zsh/syntax-highlighting.nix | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 0bdb0f02..bbc3a846 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -44,7 +44,7 @@ in highlighters = mkOption { type = types.listOf types.str; - default = [ ]; + default = [ "main" ]; example = [ "brackets" ]; description = '' Highlighters to enable @@ -562,7 +562,7 @@ in # https://github.com/zsh-users/zsh-syntax-highlighting#faq '' source ${cfg.syntaxHighlighting.package}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh - ZSH_HIGHLIGHT_HIGHLIGHTERS+=(${lib.concatStringsSep " " (map lib.escapeShellArg cfg.syntaxHighlighting.highlighters)}) + ZSH_HIGHLIGHT_HIGHLIGHTERS=(${lib.concatStringsSep " " (map lib.escapeShellArg cfg.syntaxHighlighting.highlighters)}) ${lib.concatStringsSep "\n" ( lib.mapAttrsToList ( name: value: "ZSH_HIGHLIGHT_STYLES[${lib.escapeShellArg name}]=${lib.escapeShellArg value}" diff --git a/tests/modules/programs/zsh/syntax-highlighting.nix b/tests/modules/programs/zsh/syntax-highlighting.nix index d014d85a..4e7d3fde 100644 --- a/tests/modules/programs/zsh/syntax-highlighting.nix +++ b/tests/modules/programs/zsh/syntax-highlighting.nix @@ -7,6 +7,7 @@ enable = true; package = pkgs.hello; highlighters = [ + "main" "brackets" "pattern" "cursor" @@ -18,7 +19,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+=(brackets pattern cursor)" + assertFileContains home-files/.zshrc "ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)" assertFileContains home-files/.zshrc "ZSH_HIGHLIGHT_STYLES[comment]='fg=#6c6c6c'" ''; }