1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-25 07:58:31 +02:00

zsh: allow enabling syntax highlighters (#4360)

This commit is contained in:
Gutyina Gergő 2023-11-19 19:37:32 +01:00 committed by GitHub
parent 9a4725afa6
commit 993fb02d20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -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: <https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md>
'';
};
styles = mkOption {
type = types.attrsOf types.str;
default = {};
example = { comment = "fg=black,bold"; };
description = ''
Custom styles for syntax highlighting.
See each highlighter's options: <https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md>
@ -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})")

View File

@ -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')"
'';
};