Skip to content

Commit

Permalink
zsh: make autosuggest strategy accept more options
Browse files Browse the repository at this point in the history
Now accepts an empty list, which turns off the code so the user can
manually set ZSH_AUTOSUGGEST_STRATEGY anywhere they want via any of the
`*Variables` module options.
  • Loading branch information
NovaViper authored Dec 4, 2024
1 parent ad48eb2 commit 3a7fc9c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/programs/zsh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ in
- `match_prev_cmd`: Like `history`, but chooses the most recent match whose preceding history item matches
the most recently executed command. Note that this strategy won't work as expected with ZSH options that
don't preserve the history order such as `HIST_IGNORE_ALL_DUPS` or `HIST_EXPIRE_DUPS_FIRST`.
Setting the option to an empty list `[]` will make ZSH_AUTOSUGGESTION_STRATEGY not be set automatically,
allowing the variable to be declared in {option}`programs.zsh.localVariables` or {option}`programs.zsh.sessionVariables`
'';
};
};
Expand Down Expand Up @@ -641,7 +644,10 @@ in

(optionalString cfg.autosuggestion.enable ''
source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh
ZSH_AUTOSUGGEST_STRATEGY=(${concatStringsSep " " cfg.autosuggestion.strategy})
${optionalString (cfg.autosuggestion.strategy != []) ''
ZSH_AUTOSUGGEST_STRATEGY=(${concatStringsSep " " cfg.autosuggestion.strategy})
''
}
'')
(optionalString (cfg.autosuggestion.enable && cfg.autosuggestion.highlight != null) ''
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="${cfg.autosuggestion.highlight}"
Expand Down

0 comments on commit 3a7fc9c

Please sign in to comment.