diff options
author | Artturi <Artturin@artturin.com> | 2022-03-08 12:01:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-08 12:01:07 +0200 |
commit | 5cd34745f0acec50115f7695c264e3067dfb27d3 (patch) | |
tree | 650b7e36d5d2083174e8445aae586440351f0342 | |
parent | 513c27a75e13b2fe861bd1421cbdce8b55dd45b6 (diff) | |
parent | 34b5dd453b13c2c09334e3def42416b5b2442a0a (diff) | |
download | nixlib-5cd34745f0acec50115f7695c264e3067dfb27d3.tar nixlib-5cd34745f0acec50115f7695c264e3067dfb27d3.tar.gz nixlib-5cd34745f0acec50115f7695c264e3067dfb27d3.tar.bz2 nixlib-5cd34745f0acec50115f7695c264e3067dfb27d3.tar.lz nixlib-5cd34745f0acec50115f7695c264e3067dfb27d3.tar.xz nixlib-5cd34745f0acec50115f7695c264e3067dfb27d3.tar.zst nixlib-5cd34745f0acec50115f7695c264e3067dfb27d3.zip |
Merge pull request #161701 from RyanGibb/zsh-autosuggest-strategy-array
-rw-r--r-- | nixos/doc/manual/from_md/release-notes/rl-2205.section.xml | 6 | ||||
-rw-r--r-- | nixos/doc/manual/release-notes/rl-2205.section.md | 2 | ||||
-rw-r--r-- | nixos/modules/programs/zsh/zsh-autosuggestions.nix | 21 |
3 files changed, 19 insertions, 10 deletions
diff --git a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml index 4f4a5a3394e6..dc7279f9d5c8 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2205.section.xml @@ -1070,6 +1070,12 @@ </listitem> <listitem> <para> + <literal>programs.zsh.autosuggestions.strategy</literal> now + takes a list of strings instead of a string. + </para> + </listitem> + <listitem> + <para> The <literal>services.unifi.openPorts</literal> option default value of <literal>true</literal> is now deprecated and will be changed to <literal>false</literal> in 22.11. Configurations diff --git a/nixos/doc/manual/release-notes/rl-2205.section.md b/nixos/doc/manual/release-notes/rl-2205.section.md index c4281561f165..fd812c540b92 100644 --- a/nixos/doc/manual/release-notes/rl-2205.section.md +++ b/nixos/doc/manual/release-notes/rl-2205.section.md @@ -392,6 +392,8 @@ In addition to numerous new and upgraded packages, this release has the followin combined `influxdb2` package is still provided in this release for backwards compatibilty, but will be removed at a later date. +- `programs.zsh.autosuggestions.strategy` now takes a list of strings instead of a string. + - The `services.unifi.openPorts` option default value of `true` is now deprecated and will be changed to `false` in 22.11. Configurations using this default will print a warning when rebuilt. diff --git a/nixos/modules/programs/zsh/zsh-autosuggestions.nix b/nixos/modules/programs/zsh/zsh-autosuggestions.nix index fee324cc7326..2e53e907d547 100644 --- a/nixos/modules/programs/zsh/zsh-autosuggestions.nix +++ b/nixos/modules/programs/zsh/zsh-autosuggestions.nix @@ -22,17 +22,18 @@ in }; strategy = mkOption { - type = types.enum [ "history" "match_prev_cmd" ]; - default = "history"; + type = types.listOf (types.enum [ "history" "completion" "match_prev_cmd" ]); + default = [ "history" ]; description = '' - Set ZSH_AUTOSUGGEST_STRATEGY to choose the strategy for generating suggestions. - There are currently two to choose from: + `ZSH_AUTOSUGGEST_STRATEGY` is an array that specifies how suggestions should be generated. + The strategies in the array are tried successively until a suggestion is found. + There are currently three built-in strategies to choose from: - * history: Chooses the most recent match. - * match_prev_cmd: Chooses the most recent match whose preceding history item matches - the most recently executed command (more info). 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. + - `history`: Chooses the most recent match from history. + - `completion`: Chooses a suggestion based on what tab-completion would suggest. (requires `zpty` module) + - `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`. ''; }; @@ -62,7 +63,7 @@ in source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="${cfg.highlightStyle}" - export ZSH_AUTOSUGGEST_STRATEGY=("${cfg.strategy}") + export ZSH_AUTOSUGGEST_STRATEGY=(${concatStringsSep " " cfg.strategy}) ${optionalString (!cfg.async) "unset ZSH_AUTOSUGGEST_USE_ASYNC"} ${concatStringsSep "\n" (mapAttrsToList (key: value: ''export ${key}="${value}"'') cfg.extraConfig)} |