Using zgenom load with just location doesn't source functions
pmarschik opened this issue ยท 5 comments
I'm trying to use zgenom to load plugins using just the [location]
parameter pointing to a plugin directory.
This will however not properly add the functions
subdirectory to fpath
.
I think the reason is that zgenom-load()
for the directory case doesn't declare local dir
.
My current workaround is to add:
# ...
elif [[ "$#" == 1 && ("${1[1]}" == '/' || "${1[1]}" == '.' ) ]]; then
location="${1}"
if [[ -d $location ]]; then
local dir="$location"
fi
else
# ...
Hey @pmarschik thanks for reporting.
Yes, that's correct. The usage of $dir
in __zgenom_source
is not ideal.
I'll fix that soon ๐
Hey @pmarschik,
I'm not really sure what a sensible default for local directories would be.
For cloned sources the functions
directory is always relative to the plugins root folder.
With your code functions
would only be checked if it's a directory - but there is no way to find the root of the "plugin".
I also don't find it intuitive that zgenom load /path/to/plugin
would detect functions
but zgenom load /path/to/plugin/init.zsh
wouldn't.
Ideally zgenom load /path/to/plugin path/to/file
would be possible. This way loading could be done exactly like it's done for external plugins.
What's your usage of local plugins? Are those files you write yourself or plugins you manage yourself?
@jandamm I use chezmoi.io to manage my dotfiles and use it to download zsh plugins and also generate (via templating) some of my own plugins.
Maybe if there is no simple way to detect from a path of it's a plug-in the solution would be to indicate that it's a plug-in via a parameter --plugin
. Or require users to make the distinction: if it's a directory it's highly likely to be plugin (and set dir
), if it's a file it's the users intent to source exactly that one file.
Thanks for your reply.
if it's a file it's the users intent to source exactly that one file.
There isn't really a benefit of using zgenom load /path/to/file.zsh
instead of source /path/to/file.zsh
.
I'll have a thought what solution I'd prefer.
I've decided to also check for functions
when a local file is used.
I'd find it confusing if the containing folder is added to fpath
but not functions
when present.