···
1
+
{ config, pkgs, lib, ... }:
6
+
cfg = config.programs.zsh.autosuggestions;
9
+
options.programs.zsh.autosuggestions = {
11
+
enable = mkEnableOption "zsh-autosuggestions";
13
+
highlightStyle = mkOption {
15
+
default = "fg=8"; # https://github.com/zsh-users/zsh-autosuggestions/tree/v0.4.3#suggestion-highlight-style
16
+
description = "Highlight style for suggestions ({fore,back}ground color)";
17
+
example = "fg=cyan";
20
+
strategy = mkOption {
21
+
type = types.enum [ "default" "match_prev_cmd" ];
22
+
default = "default";
24
+
Set ZSH_AUTOSUGGEST_STRATEGY to choose the strategy for generating suggestions.
25
+
There are currently two to choose from:
27
+
* default: Chooses the most recent match.
28
+
* match_prev_cmd: Chooses the most recent match whose preceding history item matches
29
+
the most recently executed command (more info). Note that this strategy won't work as
30
+
expected with ZSH options that don't preserve the history order such as
31
+
HIST_IGNORE_ALL_DUPS or HIST_EXPIRE_DUPS_FIRST.
35
+
extraConfig = mkOption {
36
+
type = with types; attrsOf str;
38
+
description = "Attribute set with additional configuration values";
39
+
example = literalExample ''
41
+
"ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" = "20";
48
+
config = mkIf cfg.enable {
50
+
programs.zsh.interactiveShellInit = ''
51
+
source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh
53
+
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="${cfg.highlightStyle}"
54
+
export ZSH_AUTOSUGGEST_STRATEGY="${cfg.strategy}"
56
+
${concatStringsSep "\n" (mapAttrsToList (key: value: ''export ${key}="${value}"'') cfg.extraConfig)}