zsh-syntax-highlighting: Add more configuration options and move to module (#25153)
* programs.zsh: factor zsh-syntax-highlighting out into its own module * programs.zsh.syntax-highlighting: add `highlighters` option * programs.zsh: document BC break introduced by moving zsh-syntax-completion into its own module
This commit is contained in:
parent
5a3e454db3
commit
0a12aafde4
|
@ -104,6 +104,7 @@
|
||||||
./programs/xonsh.nix
|
./programs/xonsh.nix
|
||||||
./programs/zsh/oh-my-zsh.nix
|
./programs/zsh/oh-my-zsh.nix
|
||||||
./programs/zsh/zsh.nix
|
./programs/zsh/zsh.nix
|
||||||
|
./programs/zsh/zsh-syntax-highlighting.nix
|
||||||
./rename.nix
|
./rename.nix
|
||||||
./security/acme.nix
|
./security/acme.nix
|
||||||
./security/apparmor.nix
|
./security/apparmor.nix
|
||||||
|
|
43
nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
Normal file
43
nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.programs.zsh.syntax-highlighting;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
programs.zsh.syntax-highlighting = {
|
||||||
|
enable = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
Enable zsh-syntax-highlighting.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
highlighters = mkOption {
|
||||||
|
default = [ "main" ];
|
||||||
|
type = types.listOf(types.str);
|
||||||
|
description = ''
|
||||||
|
Specifies the highlighters to be used by zsh-syntax-highlighting.
|
||||||
|
|
||||||
|
The following defined options can be found here:
|
||||||
|
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
environment.systemPackages = with pkgs; [ zsh-syntax-highlighting ];
|
||||||
|
|
||||||
|
programs.zsh.interactiveShellInit = with pkgs; with builtins; ''
|
||||||
|
source ${zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||||
|
|
||||||
|
${optionalString (length(cfg.highlighters) > 0)
|
||||||
|
"ZSH_HIGHLIGHT_HIGHLIGHTERS=(${concatStringsSep " " cfg.highlighters})"
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
|
@ -84,14 +84,6 @@ in
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
enableSyntaxHighlighting = mkOption {
|
|
||||||
default = false;
|
|
||||||
description = ''
|
|
||||||
Enable zsh-syntax-highlighting
|
|
||||||
'';
|
|
||||||
type = types.bool;
|
|
||||||
};
|
|
||||||
|
|
||||||
enableAutosuggestions = mkOption {
|
enableAutosuggestions = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -99,7 +91,6 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -131,10 +122,6 @@ in
|
||||||
|
|
||||||
${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""}
|
${if cfg.enableCompletion then "autoload -U compinit && compinit" else ""}
|
||||||
|
|
||||||
${optionalString (cfg.enableSyntaxHighlighting)
|
|
||||||
"source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
|
||||||
}
|
|
||||||
|
|
||||||
${optionalString (cfg.enableAutosuggestions)
|
${optionalString (cfg.enableAutosuggestions)
|
||||||
"source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
|
"source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
|
||||||
}
|
}
|
||||||
|
@ -206,8 +193,7 @@ in
|
||||||
environment.etc."zinputrc".source = ./zinputrc;
|
environment.etc."zinputrc".source = ./zinputrc;
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.zsh ]
|
environment.systemPackages = [ pkgs.zsh ]
|
||||||
++ optional cfg.enableCompletion pkgs.nix-zsh-completions
|
++ optional cfg.enableCompletion pkgs.nix-zsh-completions;
|
||||||
++ optional cfg.enableSyntaxHighlighting pkgs.zsh-syntax-highlighting;
|
|
||||||
|
|
||||||
environment.pathsToLink = optional cfg.enableCompletion "/share/zsh";
|
environment.pathsToLink = optional cfg.enableCompletion "/share/zsh";
|
||||||
|
|
||||||
|
|
|
@ -204,5 +204,8 @@ with lib;
|
||||||
"Set the option `services.xserver.displayManager.sddm.package' instead.")
|
"Set the option `services.xserver.displayManager.sddm.package' instead.")
|
||||||
(mkRemovedOptionModule [ "fonts" "fontconfig" "forceAutohint" ] "")
|
(mkRemovedOptionModule [ "fonts" "fontconfig" "forceAutohint" ] "")
|
||||||
(mkRemovedOptionModule [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ] "")
|
(mkRemovedOptionModule [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ] "")
|
||||||
|
|
||||||
|
# ZSH
|
||||||
|
(mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntax-highlighting" "enable" ])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue