Description
Prerequisites
- I've checked the existing issues and I'm not duplicating a report.
- I've checked the zimfw Changelog and I'm not being affected by documented changes.
- I've checked the zimfw 📢 Announcements and I'm not being affected by announced changes.
Bug description
In the current implementation if zmodule
is specified with any of the following options, --source
, --fpath
, zimfw
no longer automatically search the plugin for functions to autoload.
I feel that the more user friendly behaviour is that zimfw
searches the fpath
for functions to autoload unless --autoload
is specified by the user. The number of functions to autoload can be potentially numerous, so it is not ergonomic to expect the user to specify all functions to autoload by themselves just because a plugin has an unusual --source
or --fpath
.
Steps to reproduce
-
cd ${$(mktemp -d):A} && \ ZDOTDIR=${PWD} HOME=${PWD} ZIM_HOME=${PWD}/.zim && \ curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
-
# ${ZDOTDIR}/.zimrc zmodule romkatv/zsh-defer --fpath .
exec zsh
cat $ZIM_HOME/init.zh
# $ZIM_HOME/init.zh fpath=("${HOME}/.config/zim/modules/zsh-defer") # expected function to be autoloaded, but it is not # autoload -Uz -- zsh-defer
Current behavior
Functions to autoload are not automatically detected if custom --fpath
is specified.
Expected behavior
Expect zimfw
to automatically search fpath
to autoload functions even if custom --source
or --fpath
is specified.
zimfw info
ZIM_HOME: ~/.config/zim
zimfw config: ~/.config/zsh/.zimrc
zimfw script: ~/.config/zim/zimfw.zsh
zimfw version: 1.16.0 (built at 2024-11-25 13:50:33 UTC, previous commit is 2d5718e)
LANG: en_US.UTF-8
OSTYPE: darwin24.0
TERM: xterm-256color
TERM_PROGRAM: WezTerm
TERM_PROGRAM_VERSION: 20240203-110809-5046fc22
ZSH_VERSION: 5.9
Additional context
I think the reason for this behaviour is that automatically searching for function is done only if none of --source
, --fpath
and --autoload
is specified. I feel that autoloading function (L334) should be moved into it's own block and skipped only if --autoload
((( ! ${#zfunctions} ))
) is specified.
Lines 330 to 344 in 4f1c59a