From a3be68d105ebb640f7dc4be615f84fe00288e5d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C5=8Dshin?= Date: Fri, 19 Jan 2024 22:51:18 -0500 Subject: [PATCH] Add option to disable zsh global compinit Fixes #855. --- modules/programs/zsh/default.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 4e983e51d..615589a33 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -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; @@ -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; @@ -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