diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index c282c832..851fb47a 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -226,9 +226,20 @@ let package = mkPackageOption pkgs "zsh-syntax-highlighting" { }; + highlighters = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "brackets" ]; + description = '' + Highlighters to enable + See the list of highlighters: + ''; + }; + styles = mkOption { type = types.attrsOf types.str; default = {}; + example = { comment = "fg=black,bold"; }; description = '' Custom styles for syntax highlighting. See each highlighter's options: @@ -624,6 +635,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)}) ${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 73297c8c..9baf1e43 100644 --- a/tests/modules/programs/zsh/syntax-highlighting.nix +++ b/tests/modules/programs/zsh/syntax-highlighting.nix @@ -9,6 +9,7 @@ with lib; syntaxHighlighting = { enable = true; package = pkgs.hello; + highlighters = [ "brackets" "pattern" "cursor" ]; styles.comment = "fg=#6c6c6c"; }; }; @@ -17,6 +18,7 @@ with lib; 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_STYLES+=('comment' 'fg=#6c6c6c')" ''; };