zsh: add common plugin function paths

Nixpkgs zsh plugin packages often install functions and completions below share/zsh/plugins/<name>, share/zsh/site-functions, or share/zsh/vendor-completions rather than at the package root.

Keep the existing root path and fpath entries, but add those standard subdirectories to fpath when present so plugin-provided functions and completions are discoverable without extra per-plugin configuration.

Link: https://github.com/nix-community/home-manager/discussions/8701#discussioncomment-16966141
This commit is contained in:
Austin Horstman
2026-05-18 15:15:37 -05:00
parent 04ec113f8b
commit 112a3a3783
2 changed files with 14 additions and 6 deletions

View File

@@ -30,14 +30,17 @@ in
assertFileContains home-files/.zshrc 'for plugin_dir in "''${plugin_dirs[@]}"; do'
assertFileContains home-files/.zshrc 'path+="/home/hm-user/.zsh/plugins/$plugin_dir"'
assertFileContains home-files/.zshrc 'fpath+="/home/hm-user/.zsh/plugins/$plugin_dir"'
assertFileContains home-files/.zshrc '$plugin_dir/share/zsh/plugins/$plugin_dir'
assertFileContains home-files/.zshrc '$plugin_dir/share/zsh/site-functions'
assertFileContains home-files/.zshrc '$plugin_dir/share/zsh/vendor-completions'
# Test the completion paths loop structure
assertFileContains home-files/.zshrc '# Add completion paths to fpath'
assertFileContains home-files/.zshrc 'completion_paths=('
assertFileContains home-files/.zshrc '# Add additional function paths to fpath'
assertFileContains home-files/.zshrc 'function_paths=('
assertFileContains home-files/.zshrc 'mockPlugin/share/zsh/site-functions'
assertFileContains home-files/.zshrc 'mockPlugin/share/zsh/vendor-completions'
assertFileContains home-files/.zshrc 'for completion_path in "''${completion_paths[@]}"; do'
assertFileContains home-files/.zshrc 'fpath+="/home/hm-user/.zsh/plugins/$completion_path"'
assertFileContains home-files/.zshrc 'for function_path in "''${function_paths[@]}"; do'
assertFileContains home-files/.zshrc 'fpath+="/home/hm-user/.zsh/plugins/$function_path"'
# Test the plugin loading structure
assertFileContains home-files/.zshrc '# Source plugins'
@@ -45,7 +48,6 @@ in
assertFileContains home-files/.zshrc 'mockPlugin/share/mockPlugin/mockPlugin.plugin.zsh'
assertFileContains home-files/.zshrc 'for plugin in "''${plugins[@]}"; do'
assertFileContains home-files/.zshrc '[[ -f "/home/hm-user/.zsh/plugins/$plugin" ]] && source "/home/hm-user/.zsh/plugins/$plugin"'
assertFileContains home-files/.zshrc 'done'
'';
};
}