mirror of
https://github.com/nix-community/home-manager
synced 2024-11-19 09:39:45 +01:00
zsh: allow enabling syntax highlighters (#4360)
This commit is contained in:
parent
9a4725afa6
commit
993fb02d20
2 changed files with 14 additions and 0 deletions
|
@ -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})")
|
||||
|
|
|
@ -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')"
|
||||
'';
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue