diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix index c834a374a..fe9bffa09 100644 --- a/modules/programs/zsh.nix +++ b/modules/programs/zsh.nix @@ -633,15 +633,15 @@ in zmodload zsh/zprof '')) - (lib.mkIf (cfg.initExtraFirst != "") (mkOrder 550 cfg.initExtraFirst)) + (lib.mkIf (cfg.initExtraFirst != "") (lib.mkBefore cfg.initExtraFirst)) - (mkOrder 600 "typeset -U path cdpath fpath manpath") + (mkOrder 510 "typeset -U path cdpath fpath manpath") - (lib.mkIf (cfg.cdpath != [ ]) (mkOrder 650 '' + (lib.mkIf (cfg.cdpath != [ ]) (mkOrder 510 '' cdpath+=(${concatStringsSep " " cfg.cdpath}) '')) - (mkOrder 700 '' + (mkOrder 520 '' for profile in ''${(z)NIX_PROFILES}; do fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions) done @@ -649,16 +649,16 @@ in HELPDIR="${cfg.package}/share/zsh/$ZSH_VERSION/help" '') - (lib.mkIf (cfg.defaultKeymap != null) (mkOrder 750 '' + (lib.mkIf (cfg.defaultKeymap != null) (mkOrder 530 '' # Use ${cfg.defaultKeymap} keymap as the default. ${lib.getAttr cfg.defaultKeymap bindkeyCommands} '')) - (lib.mkIf (localVarsStr != "") (mkOrder 800 localVarsStr)) + (lib.mkIf (localVarsStr != "") (mkOrder 540 localVarsStr)) - (lib.mkIf (cfg.initExtraBeforeCompInit != "") (mkOrder 850 cfg.initExtraBeforeCompInit)) + (lib.mkIf (cfg.initExtraBeforeCompInit != "") (mkOrder 550 cfg.initExtraBeforeCompInit)) - (lib.mkIf (cfg.plugins != []) (mkOrder 900 (lib.concatStrings (map (plugin: '' + (lib.mkIf (cfg.plugins != []) (mkOrder 560 (lib.concatStrings (map (plugin: '' path+="$HOME/${pluginsDir}/${plugin.name}" fpath+="$HOME/${pluginsDir}/${plugin.name}" '') cfg.plugins)))) @@ -667,9 +667,9 @@ in # calling it twice causes slight start up slowdown # as all $fpath entries will be traversed again. (lib.mkIf (cfg.enableCompletion && !cfg.oh-my-zsh.enable && !cfg.prezto.enable) - (mkOrder 950 cfg.completionInit)) + (mkOrder 570 cfg.completionInit)) - (lib.mkIf cfg.autosuggestion.enable (mkOrder 1000 '' + (lib.mkIf cfg.autosuggestion.enable (mkOrder 700 '' source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh ${optionalString (cfg.autosuggestion.strategy != [ ]) '' ZSH_AUTOSUGGEST_STRATEGY=(${ @@ -680,7 +680,7 @@ in ''} '')) - (lib.mkIf cfg.oh-my-zsh.enable (mkOrder 1100 '' + (lib.mkIf cfg.oh-my-zsh.enable (mkOrder 800 '' # oh-my-zsh extra settings for plugins ${cfg.oh-my-zsh.extraConfig} # oh-my-zsh configuration generated by NixOS @@ -693,7 +693,7 @@ in source $ZSH/oh-my-zsh.sh '')) - (mkOrder 1150 ((optionalString cfg.prezto.enable (builtins.readFile + (mkOrder 900 ((optionalString cfg.prezto.enable (builtins.readFile "${cfg.prezto.package}/share/zsh-prezto/runcoms/zshrc")) + (lib.concatStrings (map (plugin: '' if [[ -f "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}" ]]; then @@ -728,21 +728,21 @@ in ${if cfg.autocd != null then "${if cfg.autocd then "setopt" else "unsetopt"} autocd" else ""} '')) - (lib.mkIf (cfg.initExtra != "") (mkOrder 1200 cfg.initExtra)) + (lib.mkIf (cfg.initExtra != "") cfg.initExtra) - (lib.mkIf (aliasesStr != "" || cfg.shellGlobalAliases != {}) (mkOrder 1250 + (lib.mkIf (aliasesStr != "" || cfg.shellGlobalAliases != {}) (mkOrder 1100 ((optionalString (aliasesStr != "") aliasesStr) + (optionalString (cfg.shellGlobalAliases != {}) (concatStringsSep "\n" (lib.mapAttrsToList (k: v: "alias -g -- ${lib.escapeShellArg k}=${lib.escapeShellArg v}") cfg.shellGlobalAliases)))))) - (lib.mkIf (dirHashesStr != "") (mkOrder 1300 '' + (lib.mkIf (dirHashesStr != "") (mkOrder 1150 '' # Named Directory Hashes ${dirHashesStr} '')) - (lib.mkIf cfg.syntaxHighlighting.enable (mkOrder 1350 + (lib.mkIf cfg.syntaxHighlighting.enable (mkOrder 1200 # Load zsh-syntax-highlighting after all custom widgets have been created # https://github.com/zsh-users/zsh-syntax-highlighting#faq '' @@ -760,7 +760,7 @@ in )} '')) - (lib.mkIf (cfg.historySubstringSearch.enable or false) (mkOrder 1400 + (lib.mkIf (cfg.historySubstringSearch.enable or false) (mkOrder 1250 # Load zsh-history-substring-search after zsh-syntax-highlighting # https://github.com/zsh-users/zsh-history-substring-search#usage '' diff --git a/tests/modules/programs/zsh/zshrc-content-priorities.nix b/tests/modules/programs/zsh/zshrc-content-priorities.nix index f5479541e..76657cc89 100644 --- a/tests/modules/programs/zsh/zshrc-content-priorities.nix +++ b/tests/modules/programs/zsh/zshrc-content-priorities.nix @@ -39,9 +39,6 @@ HELPDIR="@zsh@/share/zsh/$ZSH_VERSION/help" autoload -U compinit && compinit - # Default priority - echo "Default priority content" - # History options should be set in .zshrc and after oh-my-zsh sourcing. # See https://github.com/nix-community/home-manager/issues/177. HISTSIZE="10000" @@ -62,6 +59,9 @@ unsetopt EXTENDED_HISTORY + # Default priority + echo "Default priority content" + zprof # Low priority (mkAfter) echo "Low priority content"