summary refs log tree commit diff
path: root/nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2017-04-23 21:17:31 +0200
committerJörg Thalheim <Mic92@users.noreply.github.com>2017-04-23 21:17:31 +0200
commit0a12aafde42ddecfd268a21aa6ada4c0946cd30f (patch)
treedcd58921ab0622b7f4cb7acf2bd95eb43057ab57 /nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
parent5a3e454db37fd20f5432a64137c1025cf892eb85 (diff)
downloadnixlib-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar
nixlib-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar.gz
nixlib-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar.bz2
nixlib-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar.lz
nixlib-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar.xz
nixlib-0a12aafde42ddecfd268a21aa6ada4c0946cd30f.tar.zst
nixlib-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/modules/programs/zsh/zsh-syntax-highlighting.nix')
-rw-r--r--nixos/modules/programs/zsh/zsh-syntax-highlighting.nix43
1 files changed, 43 insertions, 0 deletions
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 000000000000..962c1f920a86
--- /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})"
+        }
+      '';
+    };
+  }