mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-14 17:04:42 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
88 lines
2.6 KiB
Nix
88 lines
2.6 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
|
|
let
|
|
cfg = config.programs.zsh.autosuggestions;
|
|
in
|
|
{
|
|
imports = [
|
|
(lib.mkRenamedOptionModule
|
|
[ "programs" "zsh" "enableAutosuggestions" ]
|
|
[ "programs" "zsh" "autosuggestions" "enable" ]
|
|
)
|
|
];
|
|
|
|
options.programs.zsh.autosuggestions = {
|
|
|
|
enable = lib.mkEnableOption "zsh-autosuggestions";
|
|
|
|
highlightStyle = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "fg=8"; # https://github.com/zsh-users/zsh-autosuggestions/tree/v0.4.3#suggestion-highlight-style
|
|
description = "Highlight style for suggestions ({fore,back}ground color)";
|
|
example = "fg=cyan";
|
|
};
|
|
|
|
strategy = lib.mkOption {
|
|
type = lib.types.listOf (
|
|
lib.types.enum [
|
|
"history"
|
|
"completion"
|
|
"match_prev_cmd"
|
|
]
|
|
);
|
|
default = [ "history" ];
|
|
description = ''
|
|
`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 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`.
|
|
'';
|
|
};
|
|
|
|
async = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "Whether to fetch suggestions asynchronously";
|
|
example = false;
|
|
};
|
|
|
|
extraConfig = lib.mkOption {
|
|
type = lib.types.attrsOf lib.types.str;
|
|
default = { };
|
|
description = "Attribute set with additional configuration values";
|
|
example = lib.literalExpression ''
|
|
{
|
|
"ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" = "20";
|
|
}
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
programs.zsh.interactiveShellInit = ''
|
|
source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh
|
|
|
|
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="${cfg.highlightStyle}"
|
|
export ZSH_AUTOSUGGEST_STRATEGY=(${builtins.concatStringsSep " " cfg.strategy})
|
|
${lib.optionalString (!cfg.async) "unset ZSH_AUTOSUGGEST_USE_ASYNC"}
|
|
|
|
${builtins.concatStringsSep "\n" (
|
|
lib.mapAttrsToList (key: value: ''export ${key}="${value}"'') cfg.extraConfig
|
|
)}
|
|
'';
|
|
|
|
};
|
|
}
|