diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 896e4fe83fa9..7c5fe3034029 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -34,6 +34,11 @@ let vicmd = "bindkey -a"; }; + highlighters = { + zsh-fast-syntax-highlighting = "source ${pkgs.zsh-fast-syntax-highlighting}/share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh"; + zsh-syntax-highlighting = "source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"; + }; + stateVersion = config.home.stateVersion; historyModule = types.submodule ({ config, ... }: { @@ -290,6 +295,17 @@ in description = "Enable zsh autosuggestions"; }; + syntaxHighlighting = { + enable = mkOption { + default = false; + description = "Enable zsh syntax highlighting"; + }; + highlighter = mkOption { + default = "zsh-syntax-highlighting"; + description = "The package name of the highlighter"; + }; + }; + history = mkOption { type = historyModule; default = {}; @@ -482,6 +498,10 @@ in "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" } + ${optionalString cfg.syntaxHighlighting.enable + highlighters."${cfg.syntaxHighlighting.highlighter}" + } + # Environment variables . "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh" ${envVarsStr}