mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-24 09:06:17 +00:00
zsh: cleanup empty / wrong generated lines
We currently just insert a ton of empty lines when not using certain options. We also incorrectly generate some notes for options not being used.
This commit is contained in:
parent
5d51162862
commit
0e46e84279
1 changed files with 38 additions and 42 deletions
|
@ -627,16 +627,18 @@ in
|
|||
programs.zsh.initContent = lib.mkMerge [
|
||||
# zprof must be loaded before everything else, since it
|
||||
# benchmarks the shell initialization.
|
||||
(mkOrder 400 (optionalString cfg.zprof.enable ''
|
||||
(lib.mkIf cfg.zprof.enable (mkOrder 400 ''
|
||||
zmodload zsh/zprof
|
||||
''))
|
||||
|
||||
(mkOrder 550 cfg.initExtraFirst)
|
||||
(lib.mkIf (cfg.initExtraFirst != "") (mkOrder 550 cfg.initExtraFirst))
|
||||
|
||||
(mkOrder 600 "typeset -U path cdpath fpath manpath")
|
||||
|
||||
(mkOrder 650 (optionalString (cfg.cdpath != [ ]) ''
|
||||
(lib.mkIf (cfg.cdpath != [ ]) (mkOrder 650 ''
|
||||
cdpath+=(${concatStringsSep " " cfg.cdpath})
|
||||
''))
|
||||
|
||||
(mkOrder 700 ''
|
||||
for profile in ''${(z)NIX_PROFILES}; do
|
||||
fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
|
||||
|
@ -645,41 +647,38 @@ in
|
|||
HELPDIR="${cfg.package}/share/zsh/$ZSH_VERSION/help"
|
||||
'')
|
||||
|
||||
(mkOrder 750 (optionalString (cfg.defaultKeymap != null) ''
|
||||
(lib.mkIf (cfg.defaultKeymap != null) (mkOrder 750 ''
|
||||
# Use ${cfg.defaultKeymap} keymap as the default.
|
||||
${lib.getAttr cfg.defaultKeymap bindkeyCommands}
|
||||
''))
|
||||
|
||||
(mkOrder 800 localVarsStr)
|
||||
(mkOrder 850 cfg.initExtraBeforeCompInit)
|
||||
(lib.mkIf (localVarsStr != "") (mkOrder 800 localVarsStr))
|
||||
|
||||
(mkOrder 900 (lib.concatStrings (map (plugin: ''
|
||||
(lib.mkIf (cfg.initExtraBeforeCompInit != "") (mkOrder 850 cfg.initExtraBeforeCompInit))
|
||||
|
||||
(lib.mkIf (cfg.plugins != []) (mkOrder 900 (lib.concatStrings (map (plugin: ''
|
||||
path+="$HOME/${pluginsDir}/${plugin.name}"
|
||||
fpath+="$HOME/${pluginsDir}/${plugin.name}"
|
||||
'') cfg.plugins)))
|
||||
'') cfg.plugins))))
|
||||
|
||||
(mkOrder 950 ''
|
||||
# Oh-My-Zsh/Prezto calls compinit during initialization,
|
||||
# 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)
|
||||
cfg.completionInit}'')
|
||||
# NOTE: Oh-My-Zsh/Prezto calls compinit during initialization,
|
||||
# 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 1000 (optionalString cfg.autosuggestion.enable ''
|
||||
(lib.mkIf cfg.autosuggestion.enable (mkOrder 1000 ''
|
||||
source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
${optionalString (cfg.autosuggestion.strategy != [ ]) ''
|
||||
ZSH_AUTOSUGGEST_STRATEGY=(${
|
||||
concatStringsSep " " cfg.autosuggestion.strategy
|
||||
})
|
||||
''}${optionalString (cfg.autosuggestion.highlight != null) ''
|
||||
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="${cfg.autosuggestion.highlight}"
|
||||
''}
|
||||
''))
|
||||
(mkOrder 1050 (optionalString
|
||||
(cfg.autosuggestion.enable && cfg.autosuggestion.highlight != null) ''
|
||||
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="${cfg.autosuggestion.highlight}"
|
||||
''))
|
||||
|
||||
(mkOrder 1100 (optionalString cfg.oh-my-zsh.enable ''
|
||||
(lib.mkIf cfg.oh-my-zsh.enable (mkOrder 1100 ''
|
||||
# oh-my-zsh extra settings for plugins
|
||||
${cfg.oh-my-zsh.extraConfig}
|
||||
# oh-my-zsh configuration generated by NixOS
|
||||
|
@ -691,16 +690,14 @@ in
|
|||
''ZSH_THEME="${cfg.oh-my-zsh.theme}"''}
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
''))
|
||||
(mkOrder 1150 ''
|
||||
${optionalString cfg.prezto.enable (builtins.readFile
|
||||
"${cfg.prezto.package}/share/zsh-prezto/runcoms/zshrc")}
|
||||
|
||||
${lib.concatStrings (map (plugin: ''
|
||||
(mkOrder 1150 ((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
|
||||
source "$HOME/${pluginsDir}/${plugin.name}/${plugin.file}"
|
||||
fi
|
||||
'') cfg.plugins)}
|
||||
|
||||
'') cfg.plugins)) + ''
|
||||
# History options should be set in .zshrc and after oh-my-zsh sourcing.
|
||||
# See https://github.com/nix-community/home-manager/issues/177.
|
||||
HISTSIZE="${toString cfg.history.size}"
|
||||
|
@ -727,21 +724,23 @@ in
|
|||
${if cfg.history.share then "setopt" else "unsetopt"} SHARE_HISTORY
|
||||
${if cfg.history.extended then "setopt" else "unsetopt"} EXTENDED_HISTORY
|
||||
${if cfg.autocd != null then "${if cfg.autocd then "setopt" else "unsetopt"} autocd" else ""}
|
||||
'')
|
||||
''))
|
||||
|
||||
(mkOrder 1200 cfg.initExtra)
|
||||
(lib.mkIf (cfg.initExtra != "") (mkOrder 1200 cfg.initExtra))
|
||||
|
||||
# Aliases
|
||||
(mkOrder 1250 aliasesStr)
|
||||
(mkOrder 1250 (concatStringsSep "\n" (lib.mapAttrsToList
|
||||
(k: v: "alias -g -- ${lib.escapeShellArg k}=${lib.escapeShellArg v}")
|
||||
cfg.shellGlobalAliases)))
|
||||
(mkOrder 1300 ''
|
||||
(lib.mkIf (aliasesStr != "" || cfg.shellGlobalAliases != {}) (mkOrder 1250
|
||||
((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 ''
|
||||
# Named Directory Hashes
|
||||
${dirHashesStr}
|
||||
'')
|
||||
''))
|
||||
|
||||
(mkOrder 1350 (optionalString cfg.syntaxHighlighting.enable
|
||||
(lib.mkIf cfg.syntaxHighlighting.enable (mkOrder 1350
|
||||
# Load zsh-syntax-highlighting after all custom widgets have been created
|
||||
# https://github.com/zsh-users/zsh-syntax-highlighting#faq
|
||||
''
|
||||
|
@ -759,8 +758,7 @@ in
|
|||
)}
|
||||
''))
|
||||
|
||||
(mkOrder 1400 (optionalString
|
||||
(cfg.historySubstringSearch.enable or false)
|
||||
(lib.mkIf (cfg.historySubstringSearch.enable or false) (mkOrder 1400
|
||||
# Load zsh-history-substring-search after zsh-syntax-highlighting
|
||||
# https://github.com/zsh-users/zsh-history-substring-search#usage
|
||||
''
|
||||
|
@ -773,9 +771,7 @@ in
|
|||
(lib.toList cfg.historySubstringSearch.searchDownKey)}
|
||||
''))
|
||||
|
||||
(mkOrder 1450 (optionalString cfg.zprof.enable ''
|
||||
zprof
|
||||
''))
|
||||
(lib.mkIf cfg.zprof.enable (mkOrder 1450 "zprof"))
|
||||
];
|
||||
|
||||
home.file."${relToDotDir ".zshrc"}".text = cfg.initContent;
|
||||
|
|
Loading…
Add table
Reference in a new issue