Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable zsh global compinit #858

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions modules/programs/zsh/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }:
{ config, lib, options, pkgs, ... }:

with lib;

let
cfg = config.programs.zsh;
opt = options.programs.zsh;

zshVariables =
mapAttrsToList (n: v: ''${n}="${v}"'') cfg.variables;
Expand Down Expand Up @@ -70,6 +71,19 @@ in
description = lib.mdDoc "Enable bash completion for all interactive zsh shells.";
};

programs.zsh.enableGlobalCompInit = mkOption {
type = types.bool;
default = cfg.enableCompletion;
defaultText = literalExpression "config.${opt.enableCompletion}";
description = lib.mdDoc ''
Enable execution of compinit call for all interactive zsh shells.

This option can be disabled if the user wants to extend its
`fpath` and a custom `compinit`
call in the local config is required.
'';
};

programs.zsh.enableFzfCompletion = mkOption {
type = types.bool;
default = false;
Expand Down Expand Up @@ -175,7 +189,7 @@ in

${cfg.promptInit}

${optionalString cfg.enableCompletion "autoload -U compinit && compinit"}
${optionalString cfg.enableGlobalCompInit "autoload -U compinit && compinit"}
${optionalString cfg.enableBashCompletion "autoload -U bashcompinit && bashcompinit"}

${optionalString cfg.enableSyntaxHighlighting
Expand Down