home-manager/tests/modules/programs/zsh/plugins.nix
@zimeg d54b1a072d zsh: add plugins.*.completions paths to fpath
Autocompletion scripts and additional plugin functions are located in
specific directories that might not match the plugin source script but
need to be included in fpath before calling compinit.

An option to provide a path to these scripts is added to add the paths
to fpath before calling completionInit.
2024-05-27 00:05:20 -07:00

28 lines
821 B
Nix

{ config, lib, pkgs, ... }:
with lib;
let mockZshPluginSrc = pkgs.writeText "mockZshPluginSrc" "echo example";
in {
config = {
programs.zsh = {
enable = true;
plugins = [{
name = "mockPlugin";
file = "share/mockPlugin/mockPlugin.plugin.zsh";
src = mockZshPluginSrc;
completions =
[ "share/zsh/site-functions" "share/zsh/vendor-completions" ];
}];
};
test.stubs.zsh = { };
nmt.script = ''
assertFileRegex home-files/.zshrc '^path+="$HOME/.zsh/plugins/mockPlugin"$'
assertFileRegex home-files/.zshrc '^fpath+="$HOME/.zsh/plugins/mockPlugin"$'
assertFileRegex home-files/.zshrc '^fpath+=("$HOME/.zsh/plugins/mockPlugin/share/zsh/site-functions" "$HOME/.zsh/plugins/mockPlugin/share/zsh/vendor-completions")$'
'';
};
}