1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-31 04:04:32 +00:00

zsh: adjust initContent priorities (#6676)

To support easier migration of deprecating old zsh options. We can
adjust the internal priorities to fit within the `mkBefore` (500) and
default (1000). Makes it easier for `initExtraFirst` migrationg to
`mkBefore` and `initExtra` to default prio.
This commit is contained in:
Austin Horstman 2025-03-21 15:17:13 -05:00 committed by GitHub
parent 8a68f18e96
commit 296ddc6462
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 20 deletions

View file

@ -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
''

View file

@ -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"