Summary
The Z_A_USECOMP=1 shim mechanism doesn't add recache to _zinit's tab-completable subcommands. The _zinit_shim approach of chaining _zinit_recache and _zinit has a fundamental issue: _zinit_recache uses _arguments which creates a nested _arguments context when called directly from the shim (bypassing _call_function).
Root cause
_zinit's completion defines subcommands in __zinit_commands() (a hardcoded list in the _zinit file). The recache subcommand is not in this list. The shim tries to work around this by calling both _zinit_recache and _zinit, but:
_zinit_recache's _arguments -C call, when invoked directly from the shim (not via _call_function), may conflict with the outer completion context.
_zinit still doesn't list recache in its subcommands, so the base completion never offers it.
Steps to reproduce
- Load z-a-eval with
Z_A_USECOMP=1:
zinit atinit'Z_A_USECOMP=1' light-mode for NICHOLAS85/z-a-eval
- Type
zinit rec and press Tab
- No completion for
recache is offered
Expected behavior
zinit rec<TAB> should complete to zinit recache.
Suggested fix
Instead of (or in addition to) the shim mechanism, patch _zinit's __zinit_commands to include the recache subcommand. This can be done by sourcing the _zinit file (minus the final _zinit "$@" call) and injecting recache into the commands array:
# Source _zinit to define all functions (makes _zinit a real function, not autoload stub)
eval "$(head -n -1 "${ZINIT[BIN_DIR]}/_zinit")" 2>/dev/null
# Inject recache into __zinit_commands
eval "$(sed -n '/^__zinit_commands()/,/^} # \]\]\]$/p' "${ZINIT[BIN_DIR]}/_zinit" \
| sed "/recently:Show plugins that changed recently/a\\ 'recache:Regenerate eval cache (z-a-eval annex)'")"
Since _zinit becomes a real function (not an autoload stub), the autoload mechanism won't overwrite the patched __zinit_commands on first tab completion.
Environment
- Zsh 5.9+
- zinit (zdharma-continuum) latest
- z-a-eval main branch
Summary
The
Z_A_USECOMP=1shim mechanism doesn't addrecacheto_zinit's tab-completable subcommands. The_zinit_shimapproach of chaining_zinit_recacheand_zinithas a fundamental issue:_zinit_recacheuses_argumentswhich creates a nested_argumentscontext when called directly from the shim (bypassing_call_function).Root cause
_zinit's completion defines subcommands in__zinit_commands()(a hardcoded list in the_zinitfile). Therecachesubcommand is not in this list. The shim tries to work around this by calling both_zinit_recacheand_zinit, but:_zinit_recache's_arguments -Ccall, when invoked directly from the shim (not via_call_function), may conflict with the outer completion context._zinitstill doesn't listrecachein its subcommands, so the base completion never offers it.Steps to reproduce
Z_A_USECOMP=1:zinit recand press Tabrecacheis offeredExpected behavior
zinit rec<TAB>should complete tozinit recache.Suggested fix
Instead of (or in addition to) the shim mechanism, patch
_zinit's__zinit_commandsto include therecachesubcommand. This can be done by sourcing the_zinitfile (minus the final_zinit "$@"call) and injectingrecacheinto the commands array:Since
_zinitbecomes a real function (not an autoload stub), the autoload mechanism won't overwrite the patched__zinit_commandson first tab completion.Environment