From 42847469b3f65a363dc52b66be09d0ac4edcc55c Mon Sep 17 00:00:00 2001 From: bb010g Date: Wed, 9 Jun 2021 08:15:10 -0700 Subject: [PATCH] zsh: add `completionInit` option (#2046) Factored out from original .zshrc construction. --- modules/programs/zsh.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index 5e5aeb21f..896e4fe83 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -279,6 +279,12 @@ in type = types.bool; }; + completionInit = mkOption { + default = "autoload -U compinit && compinit"; + description = "Initialization commands to run when completion is enabled."; + type = types.lines; + }; + enableAutosuggestions = mkOption { default = false; description = "Enable zsh autosuggestions"; @@ -469,7 +475,7 @@ in # calling it twice causes slight start up slowdown # as all $fpath entries will be traversed again. ${optionalString (cfg.enableCompletion && !cfg.oh-my-zsh.enable && !cfg.prezto.enable) - "autoload -U compinit && compinit" + cfg.completionInit } ${optionalString cfg.enableAutosuggestions @@ -500,7 +506,7 @@ in (builtins.readFile "${pkgs.zsh-prezto}/share/zsh-prezto/runcoms/zshrc")} ${concatStrings (map (plugin: '' - if [ -f "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" ]; then + if [[ -f "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" ]]; then source "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" fi '') cfg.plugins)}