diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2017-04-23 21:17:31 +0200 |
---|---|---|
committer | Jörg Thalheim <Mic92@users.noreply.github.com> | 2017-04-23 21:17:31 +0200 |
commit | 0a12aafde42ddecfd268a21aa6ada4c0946cd30f (patch) | |
tree | dcd58921ab0622b7f4cb7acf2bd95eb43057ab57 /nixos | |
parent | 5a3e454db37fd20f5432a64137c1025cf892eb85 (diff) | |
download | nixpkgs-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar nixpkgs-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar.gz nixpkgs-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar.bz2 nixpkgs-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar.lz nixpkgs-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar.xz nixpkgs-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar.zst nixpkgs-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.zip |
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
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/programs/zsh/zsh-syntax-highlighting.nix | 43 | ||||
-rw-r--r-- | nixos/modules/programs/zsh/zsh.nix | 16 | ||||
-rw-r--r-- | nixos/modules/rename.nix | 3 |
4 files changed, 48 insertions, 15 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 6e99ead5862..4ff069f48ab 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -104,6 +104,7 @@ ./programs/xonsh.nix ./programs/zsh/oh-my-zsh.nix ./programs/zsh/zsh.nix + ./programs/zsh/zsh-syntax-highlighting.nix ./rename.nix ./security/acme.nix ./security/apparmor.nix diff --git a/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix b/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix new file mode 100644 index 00000000000..962c1f920a8 --- /dev/null +++ b/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix @@ -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})" + } + ''; + }; + } diff --git a/nixos/modules/programs/zsh/zsh.nix b/nixos/modules/programs/zsh/zsh.nix index a39c06c0913..acb3e987aee 100644 --- a/nixos/modules/programs/zsh/zsh.nix +++ b/nixos/modules/programs/zsh/zsh.nix @@ -84,14 +84,6 @@ in type = types.bool; }; - enableSyntaxHighlighting = mkOption { - default = false; - description = '' - Enable zsh-syntax-highlighting - ''; - type = types.bool; - }; - enableAutosuggestions = mkOption { default = false; description = '' @@ -99,7 +91,6 @@ in ''; }; - }; }; @@ -131,10 +122,6 @@ in ${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) "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" } @@ -206,8 +193,7 @@ in environment.etc."zinputrc".source = ./zinputrc; environment.systemPackages = [ pkgs.zsh ] - ++ optional cfg.enableCompletion pkgs.nix-zsh-completions - ++ optional cfg.enableSyntaxHighlighting pkgs.zsh-syntax-highlighting; + ++ optional cfg.enableCompletion pkgs.nix-zsh-completions; environment.pathsToLink = optional cfg.enableCompletion "/share/zsh"; diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 0174fe544e3..8a313f6c7fc 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -204,5 +204,8 @@ with lib; "Set the option `services.xserver.displayManager.sddm.package' instead.") (mkRemovedOptionModule [ "fonts" "fontconfig" "forceAutohint" ] "") (mkRemovedOptionModule [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ] "") + + # ZSH + (mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntax-highlighting" "enable" ]) ]; } |