diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index dcff129d3..2af248918 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -252,6 +252,7 @@ in { imports = [ + (mkRenamedOptionModule [ "programs" "zsh" "enableAutosuggestions" ] [ "programs" "zsh" "autosuggestion" "enable" ]) (mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ]) (mkRenamedOptionModule [ "programs" "zsh" "zproof" ] [ "programs" "zsh" "zprof" ]) ]; @@ -352,11 +353,6 @@ in type = types.lines; }; - enableAutosuggestions = mkOption { - default = false; - description = "Enable zsh autosuggestions"; - }; - zprof.enable = mkOption { default = false; description = '' @@ -376,6 +372,24 @@ in description = "Options related to zsh-history-substring-search."; }; + autosuggestion = { + enable = mkOption { + type = types.bool; + default = false; + description = "Enable zsh autosuggestions"; + }; + + highlight = mkOption { + type = types.nullOr types.str; + default = null; + example = "fg=#ff00ff,bg=cyan,bold,underline"; + description = '' + Custom styles for autosuggestion highlighting. See + {manpage}`zshzle(1)` for syntax. + ''; + }; + }; + history = mkOption { type = historyModule; default = {}; @@ -582,13 +596,16 @@ in # as all $fpath entries will be traversed again. ${optionalString (cfg.enableCompletion && !cfg.oh-my-zsh.enable && !cfg.prezto.enable) cfg.completionInit - } + }'' - ${optionalString cfg.enableAutosuggestions - "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" - } + (optionalString cfg.autosuggestion.enable '' + source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh + '') + (optionalString (cfg.autosuggestion.enable && cfg.autosuggestion.highlight != null) '' + AUTOSUGGESTION_HIGHLIGHT_COLOR="${cfg.autosuggestion.highlight}" + '') - ${optionalString cfg.oh-my-zsh.enable '' + (optionalString cfg.oh-my-zsh.enable '' # oh-my-zsh extra settings for plugins ${cfg.oh-my-zsh.extraConfig} # oh-my-zsh configuration generated by NixOS @@ -602,8 +619,9 @@ in "ZSH_THEME=\"${cfg.oh-my-zsh.theme}\"" } source $ZSH/oh-my-zsh.sh - ''} + '') + '' ${optionalString cfg.prezto.enable (builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zshrc")}