From 45a73067ac6b5d45e4b928c53ad203b80581b27d Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Thu, 8 Aug 2019 14:57:53 +0200 Subject: [PATCH] zsh: fix completion when oh-my-zsh is enabled enableCompletion option not only calls compinit but also adds nix-zsh-completions package to home.packages which should still happen even if oh-my-zsh is enabled. The double compinit call will still be eliminated by moving guarding condition down to the compinit call itself. Fixes #771. (cherry picked from commit 7310cfc557b38b6b27beeda1455fd81d15ed7ce7) --- modules/programs/zsh.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 9fb9c1c04..605a94577 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -338,7 +338,13 @@ in fpath+="$HOME/${pluginsDir}/${plugin.name}" '') cfg.plugins)} - ${optionalString cfg.enableCompletion "autoload -U compinit && compinit"} + # Oh-My-Zsh calls compinit during initialization, + # calling it twice causes sight start up slowdown + # as all $fpath entries will be traversed again. + ${optionalString (cfg.enableCompletion && !cfg.oh-my-zsh.enable) + "autoload -U compinit && compinit" + } + ${optionalString cfg.enableAutosuggestions "source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh" } @@ -387,11 +393,6 @@ in } (mkIf cfg.oh-my-zsh.enable { - # Oh-My-Zsh calls compinit during initialization, - # calling it twice causes sight start up slowdown - # as all $fpath entries will be traversed again. - programs.zsh.enableCompletion = mkForce false; - # Make sure we create a cache directory since some plugins expect it to exist # See: https://github.com/rycee/home-manager/issues/761 home.file."${config.xdg.cacheHome}/oh-my-zsh/.keep".text = "";