Skip to content

Commit

Permalink
zsh: allow configuring syntax-highlighting package
Browse files Browse the repository at this point in the history
  • Loading branch information
ThinkChaos committed Jun 20, 2023
1 parent e715683 commit 584d3ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion modules/programs/zsh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ let
options = {
enable = mkEnableOption "zsh syntax highlighting";

package = mkPackageOption pkgs "zsh-syntax-highlighting" { };

styles = mkOption {
type = types.attrsOf types.str;
default = {};
Expand Down Expand Up @@ -608,7 +610,7 @@ in
# Load zsh-syntax-highlighting after all custom widgets have been created
# https://github.com/zsh-users/zsh-syntax-highlighting#faq
''
source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ${cfg.syntaxHighlighting.package}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
${lib.concatStringsSep "\n" (
lib.mapAttrsToList
(name: value: "ZSH_HIGHLIGHT_STYLES[${lib.escapeShellArg name}]=${lib.escapeShellArg value}")
Expand Down
3 changes: 2 additions & 1 deletion tests/modules/programs/zsh/syntax-highlighting.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ with lib;
enable = true;
syntaxHighlighting = {
enable = true;
package = pkgs.hello;
styles.comment = "fg=#6c6c6c";
};
};

test.stubs.zsh = { };

nmt.script = ''
assertFileContains home-files/.zshrc "source ${pkgs.zsh-syntax-highlighting}/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_STYLES['comment']='fg=#6c6c6c'"
'';
};
Expand Down

0 comments on commit 584d3ab

Please sign in to comment.