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)
This commit is contained in:
name.tar.xz 2026-01-26 03:12:10 +00:00 committed by GitHub
parent e3dc313032
commit c37679d37b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View file

@ -44,7 +44,7 @@ in
highlighters = mkOption { highlighters = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [ "main" ];
example = [ "brackets" ]; example = [ "brackets" ];
description = '' description = ''
Highlighters to enable Highlighters to enable
@ -562,7 +562,7 @@ in
# https://github.com/zsh-users/zsh-syntax-highlighting#faq # https://github.com/zsh-users/zsh-syntax-highlighting#faq
'' ''
source ${cfg.syntaxHighlighting.package}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 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.concatStringsSep "\n" (
lib.mapAttrsToList ( lib.mapAttrsToList (
name: value: "ZSH_HIGHLIGHT_STYLES[${lib.escapeShellArg name}]=${lib.escapeShellArg value}" name: value: "ZSH_HIGHLIGHT_STYLES[${lib.escapeShellArg name}]=${lib.escapeShellArg value}"

View file

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