diff --git a/Makefile b/Makefile index cc6ba1137..4efe12147 100644 --- a/Makefile +++ b/Makefile @@ -13,40 +13,11 @@ container: docker build --tag=ghcr.io/zdharma-continuum/zinit:latest --file=docker/Dockerfile . doc: clean - cd doc; zsh -l -d -f -i -c "zsd -v --scomm --cignore '(\#*FUNCTION:[[:space:]][\:\∞\.\+\@\-a-zA-Z0-9]*[\[]*|}[[:space:]]\#[[:space:]][\]]*)' $(DOC_SRC)" + cd doc; zsh -l -d -f -i -c "zsd -v --scomm --cignore '(\#*FUNCTION:[[:space:]][\:\∞\_\.\+\@\-a-zA-Z0-9]*[\[]*|}[[:space:]]\#[[:space:]][\]]*)' $(DOC_SRC)" doc/container: container ./scripts/docker-run.sh --docs --debug -# Run ctags to generate Emacs and Vim's format tag file. -tags: tags/emacs tags/vim - -tags/emacs: ## Build Emacs-style ctags file - @if type ctags >/dev/null 2>&1; then \ - if ctags --version | grep >/dev/null 2>&1 "Universal Ctags"; then \ - ctags -e -R --options=share/zsh.ctags --languages=zsh \ - --pattern-length-limit=250 --maxdepth=1; \ - else \ - ctags -e -R --languages=sh --langmap=sh:.zsh; \ - fi; \ - printf "Created the Emacs \`TAGS\` file.\\n"; \ - else \ - printf 'Error: Please install a Ctags (e.g.: either the Exuberant or Universal %b' \ - 'version) utility first.\n'; \ - fi - -tags/vim: ## Build the Vim-style ctags file - @if type ctags >/dev/null 2>&1; then \ - if ctags --version | grep >/dev/null 2>&1 "Universal Ctags"; then \ - ctags --languages=zsh --maxdepth=1 --options=share/zsh.ctags --pattern-length-limit=250 -R; \ - else \ - ctags -R --languages=sh --langmap=sh:.zsh; \ - fi; \ - printf "Created the Vim's style \`tags\` file.\\n"; \ - else \ - printf 'Error: Please install a ctags first.\n'; \ - fi - test: zunit run diff --git a/_zinit b/_zinit index 8a9a88f05..98d8514fc 100644 --- a/_zinit +++ b/_zinit @@ -36,6 +36,7 @@ __zinit_commands(){ 'env-whitelist:Specify names (also patterns) of parameters to be left unchanged during an unload' 'glance:Look at plugins source' 'help:Usage information' + 'ice:Set ice' 'load:Load plugin' 'man:Display Zinit'\''s manpage' 'module:Manage binary Zsh module shipped with Zinit' @@ -236,6 +237,11 @@ _zinit_env_whitelist(){ _zinit_glance(){ _arguments - installed '1:installed:__zinit_installed' && ret=0 } # ]]] +# FUNCTION: _zinit_ice [[[ +_zinit_ice(){ + _arguments -A \ + '(-h --help)'{-h,--help}'[Print usage]' && ret=0 +} # ]]] # FUNCTION: _zinit_list [[[ _zinit_list(){ _message 'Hit enter to list the defined key bindings replay' && ret=0 @@ -279,7 +285,7 @@ _zinit_snippet(){ _arguments -A \ '(-c --command)'{-c,--command}'[Load the snippet as a command (i.e., make executable and apend to $PATH])' \ '(-f --force)'{-f,--force}'[Force new download of the snippet file]' \ - '(-h --help)'{-h,--help}'[Show this help message]' + '(-h --help)'{-h,--help}'[Print usage]' _arguments - snippet '*::snippet:__zinit_installed_snippets' && ret=0 } # ]]] # FUNCTION: _zinit_status [[[ diff --git a/doc/zsdoc/_zinit.adoc b/doc/zsdoc/_zinit.adoc old mode 100644 new mode 100755 diff --git a/doc/zsdoc/zinit-autoload.zsh.adoc b/doc/zsdoc/zinit-autoload.zsh.adoc index f92ec7486..dc0fb429f 100644 --- a/doc/zsdoc/zinit-autoload.zsh.adoc +++ b/doc/zsdoc/zinit-autoload.zsh.adoc @@ -796,7 +796,7 @@ ____ ____ -Has 64 line(s). Doesn't call other functions. +Has 63 line(s). Doesn't call other functions. Called by: diff --git a/doc/zsdoc/zinit-install.zsh.adoc b/doc/zsdoc/zinit-install.zsh.adoc index a47515c73..f90c1d8bd 100644 --- a/doc/zsdoc/zinit-install.zsh.adoc +++ b/doc/zsdoc/zinit-install.zsh.adoc @@ -302,10 +302,10 @@ Has 195 line(s). Calls functions: |-- .zinit-download-file-stdout |   `-- zinit.zsh/+zinit-message |-- .zinit-jq-check - |   `-- zinit.zsh/+zinit-message + |   `-- zinit.zsh/+zi-log |-- .zinit-json-to-array |   `-- .zinit-jq-check - |   `-- zinit.zsh/+zinit-message + |   `-- zinit.zsh/+zi-log |-- ziextract |   `-- zinit.zsh/+zinit-message |-- zinit.zsh/+zinit-message @@ -379,10 +379,10 @@ ____ ____ -Has 8 line(s). Calls functions: +Has 3 line(s). Calls functions: .zinit-jq-check - `-- zinit.zsh/+zinit-message + `-- zinit.zsh/+zi-log Called by: @@ -405,7 +405,7 @@ Has 4 line(s). Calls functions: .zinit-json-get-value `-- .zinit-jq-check - `-- zinit.zsh/+zinit-message + `-- zinit.zsh/+zi-log Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). @@ -426,7 +426,7 @@ Has 13 line(s). Calls functions: .zinit-json-to-array `-- .zinit-jq-check - `-- zinit.zsh/+zinit-message + `-- zinit.zsh/+zi-log Uses feature(s): _eval_, _setopt_ diff --git a/doc/zsdoc/zinit.zsh.adoc b/doc/zsdoc/zinit.zsh.adoc index e880a8ae6..54e8fcab1 100644 --- a/doc/zsdoc/zinit.zsh.adoc +++ b/doc/zsdoc/zinit.zsh.adoc @@ -110,6 +110,8 @@ Has 244 line(s). Calls functions: |   |-- .zinit-get-object-path |   |   `-- .zinit-any-to-user-plugin |   |-- .zinit-ice + |   |   `-- +zi-log + |   |   `-- +zinit-message |   |-- .zinit-load-ices |   |   `-- .zinit-get-object-path |   |   `-- .zinit-any-to-user-plugin @@ -225,6 +227,7 @@ Has 1 line(s). Calls functions: Called by: + .zinit-ice zinit-additional.zsh/.zinit-debug-clear zinit-additional.zsh/.zinit-debug-report zinit-additional.zsh/.zinit-debug-revert @@ -233,6 +236,7 @@ Called by: zinit-additional.zsh/.zinit-debug-stop zinit-additional.zsh/:zinit-tmp-subst-source zinit-autoload.zsh/.zinit-unload + zinit-install.zsh/.zinit-jq-check ==== +zinit-deploy-message @@ -300,7 +304,6 @@ Called by: zinit-install.zsh/.zinit-get-latest-gh-r-url-part zinit-install.zsh/.zinit-get-package zinit-install.zsh/.zinit-install-completions - zinit-install.zsh/.zinit-jq-check zinit-install.zsh/.zinit-setup-plugin-dir zinit-install.zsh/.zinit-update-snippet zinit-install.zsh/ziextract @@ -690,9 +693,13 @@ ____ ____ -Has 13 line(s). Doesn't call other functions. +Has 32 line(s). Calls functions: -Uses feature(s): _setopt_ + .zinit-ice + `-- +zi-log + `-- +zinit-message + +Uses feature(s): _setopt_, _zmodload_, _zparseopts_ Called by: @@ -1600,10 +1607,11 @@ ____ Entrypoint function directly exposed to user, consumes subcommands with respective arguments, and completion. + ____ -Has 553 line(s). Calls functions: +Has 527 line(s). Calls functions: zinit |-- +zinit-message @@ -1618,6 +1626,8 @@ Has 553 line(s). Calls functions: |-- .zinit-get-object-path |   `-- .zinit-any-to-user-plugin |-- .zinit-ice + |   `-- +zi-log + |   `-- +zinit-message |-- .zinit-load-ices |   `-- .zinit-get-object-path |   `-- .zinit-any-to-user-plugin @@ -1776,6 +1786,8 @@ Has 1 line(s). Calls functions: |-- .zinit-get-object-path |   `-- .zinit-any-to-user-plugin |-- .zinit-ice + |   `-- +zi-log + |   `-- +zinit-message |-- .zinit-load-ices |   `-- .zinit-get-object-path |   `-- .zinit-any-to-user-plugin diff --git a/tests/commands.zunit b/tests/commands.zunit index 41041e55c..2d8570854 100644 --- a/tests/commands.zunit +++ b/tests/commands.zunit @@ -15,6 +15,19 @@ assert $output contains 'zinit delete [options] [plugins...]' assert $state equals 0 } +@test 'zinit help' { + for cmd in '-h' '--help' 'help'; do + run zinit $cmd + assert $output contains 'Usage: zinit [OPTIONS] COMMAND' + assert $state equals 0 + done +} +@test 'ice --help' { + run zinit ice --help + assert $output contains 'Usage: zinit ice [-h|--help] [args ...]' + assert $output contains 'Available ice-modifiers:' + assert $state equals 0 +} @test 'delete --all' { run zinit as'completion' is-snippet for @'https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker' assert $state equals 0 diff --git a/zinit-autoload.zsh b/zinit-autoload.zsh index c78fb59fc..78a3e54da 100644 --- a/zinit-autoload.zsh +++ b/zinit-autoload.zsh @@ -1413,53 +1413,52 @@ EOF # # User-action entry point. .zinit-help() { - builtin print -r -- "${ZINIT[col-p]}Usage${ZINIT[col-rst]}: -—— help – usage information -—— bindkeys – lists bindkeys set up by each plugin -—— cd ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – cd into plugin's directory; also support snippets, if feed with URL -—— cdclear [-q] – clear compdef replay list, -q – quiet -—— cdisable ${ZINIT[col-info]}cname${ZINIT[col-rst]} – disable completion \`cname' -—— cdlist – show compdef replay list -—— cdreplay [-q] – replay compdefs (to be done after compinit), -q – quiet -—— cenable ${ZINIT[col-info]}cname${ZINIT[col-rst]} – enable completion \`cname' -—— changes ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – view plugin's git log -—— clist|completions – list completions in use -—— compile ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – compile plugin (or all plugins if ——all passed) -—— compiled – list plugins that are compiled -—— compinit – refresh installed completions -—— create ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – create plugin (also together with Github repository) -—— creinstall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – install completions for plugin, can also receive absolute local path; -q – quiet -—— csearch – search for available completions from any plugin -—— cuninstall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – uninstall completions for plugin -—— debug – manage debug mode -—— delete – delete a plugin or snippet -—— edit ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – edit plugin's file with \$EDITOR -—— env-whitelist [-v|-h] {env..} – allows to specify names (also patterns) of variables left unchanged during an unload. -v – verbose -—— glance ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – look at plugin's source (pygmentize, {,source-}highlight) -—— ice – add ICE to next command, argument is e.g. from\"gitlab\" -—— light [-b] ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – light plugin load, without reporting/tracking (-b – do track but bindkey-calls only) -—— load ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – load plugin, can also receive absolute local path -—— loaded|list {keyword} – show what plugins are loaded (filter with \'keyword') -—— ls – list snippets in formatted and colorized manner -—— man – manual -—— module – manage binary Zsh module shipped with Zinit, see \`zinit module help' -—— recall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]}|URL – fetch saved ice modifiers and construct \`zinit ice ...' command -—— recently ${ZINIT[col-info]}[time-spec]${ZINIT[col-rst]} – show plugins that changed recently, argument is e.g. 1 month 2 days -—— report ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – show plugin's report (or all plugins' if ——all passed) -—— self-update – updates and compiles Zinit -—— snippet [-f] ${ZINIT[col-pname]}{url}${ZINIT[col-rst]} – source local or remote file (by direct URL), -f: force – don't use cache -—— srv {service-id} [cmd] – control a service, command can be: stop,start,restart,next,quit; \`next' moves the service to another Zshell -—— status ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]}|URL – Git status for plugin or svn status for snippet (or for all those if ——all passed) -—— stress ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – test plugin for compatibility with set of options -—— times [-s] [-m] [-a] – statistics on plugin load times, sorted in order of loading; -s – use seconds instead of milliseconds, -m – show plugin loading moments, -a – show both load times and loading moments -—— uncompile ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – remove compiled version of plugin (or of all plugins if ——all passed) -—— unload ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – unload plugin loaded with \`zinit load ...', -q – quiet -—— update [-q] ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]}|URL – Git update plugin or snippet (or all plugins and snippets if ——all passed); besides -q accepts also ——quiet, and also -r/--reset – this option causes to run git reset --hard / svn revert before pulling changes -—— version – display zinit version -—— zstatus – overall Zinit statu -—— add-fpath|fpath ${ZINIT[col-info]}[-f|--front]${ZINIT[col-rst]} \\ - ${ZINIT[col-pname]}plg-spec ${ZINIT[col-info]}[subdirectory]${ZINIT[col-rst]} – adds given plugin directory to \$fpath; if the second argument is given, it is appended to the directory path; if the option -f/--front is given, the directory path is prepended instead of appended to \$fpath. The ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} can be absolute path -—— run [-l] [plugin] {command} – runs the given command in the given plugin's directory; if the option -l will be given then the plugin should be skipped – the option will cause the previous plugin to be reused" + print -- "Usage: zinit [OPTIONS] COMMAND" + print -- "" + print -- "Zinit is a plugin management system for zsh." + print -- "" + print -- "Commands:" + print -- " bindkeys Lists bindkeys set up by each plugin" + print -- " cd Change directory to a plugin or snippet" + print -- " cdclear Clear compdef replay list" + print -- " cdisable Disable completion" + print -- " cdlist Show compdef replay list" + print -- " cdreplay Replay compdefs" + print -- " cenable Enable completion" + print -- " changes View plugin's git log" + print -- " compile Compile plugin" + print -- " compiled List plugins that are compiled" + print -- " compinit Refresh installed completions" + print -- " completions List completions in use" + print -- " create Create plugin (also together with Github repository)" + print -- " creinstall Install a plugin or local completion" + print -- " csearch Search for available completions from any plugin" + print -- " cuninstall Uninstall completions for plugin" + print -- " debug Manage debug mode" + print -- " delete Delete a plugin or snippet" + print -- " edit Edit plugin's file with \$EDITOR" + print -- " glance Look at plugin's source" + print -- " help Usage information" + print -- " ice Add ICE to next command" + print -- " light Light plugin load, without reporting/tracking" + print -- " load Load plugin, can also receive absolute local path" + print -- " man Manual" + print -- " module Manage binary zsh module shipped with zinit" + print -- " plugins List currently installed plugins" + print -- " recall Fetch saved ice modifiers and construct "zinit ice ..." command" + print -- " recently Show plugins that changed recently" + print -- " report Show plugin's report" + print -- " self-update Update zinit" + print -- " snippet Source local or remote file (by direct URL)" + print -- " snippets List currently installed snippets" + print -- " status Git status for plugin or svn status for snippet" + print -- " stress Test plugin for compatibility with set of options" + print -- " times Statistics on plugin load times, sorted in order of loading" + print -- " uncompile Remove compiled version of plugin" + print -- " unload Unload plugin" + print -- " update Update a plugin or snippet" + print -- " version Display zinit version" + print -- " zstatus Overall zinit status" integer idx local type key @@ -1474,9 +1473,9 @@ EOF done done -local -a ice_order -ice_order=( ${${(s.|.)ZINIT[ice-list]}:#teleid} ${(@)${(@)${(@Akons:|:u)${ZINIT_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}:#(.*|dynamic-unscope)} ) -print -- "\nAvailable ice-modifiers:\n\n${ice_order[*]}" + print -- "Run 'zinit COMMAND --help' for more information on a command." + print -- '' + print -- "For more help on how to use Zinit, head to https://github.com/zdharma_continuum/zinit'." } # ]]] # FUNCTION: .zinit-list-bindkeys [[[ diff --git a/zinit-install.zsh b/zinit-install.zsh index cde4ff7c5..14a5bb4b2 100644 --- a/zinit-install.zsh +++ b/zinit-install.zsh @@ -12,12 +12,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { # that's not the case .zinit-jq-check() { command -v jq >/dev/null && return 0 - - +zinit-message "{error}❌ ERROR: jq binary not found" \ - "{nl}{u-warn}Please install jq:{rst}" \ - "https://github.com/jqlang/jq" \ - "{nl}{u-warn}To do so with zinit, please refer to:{rst}" \ - "https://github.com/zdharma-continuum/zinit/wiki/%F0%9F%A7%8A-Recommended-ices#jq" + +zi-log '{e} Missing required dependency {cmd}jq{rst}. Please install it.' return 1 } # ]]] # FUNCTION: .zinit-json-get-value [[[ diff --git a/zinit.zsh b/zinit.zsh index 267381dde..81961bd23 100644 --- a/zinit.zsh +++ b/zinit.zsh @@ -111,7 +111,6 @@ sh|silent|\ trackbinds|\ verbose" ZINIT[cmds]="\ --help|-h|\ add-fpath|\ bindkeys|\ cclear|cd|cdclear|cdisable|cdlist|cdreplay|cenable|changes|clist|compile|compiled|compinit|completions|create|creinstall|csearch|cuninstall|\ @@ -119,7 +118,7 @@ delete|debug|\ edit|env-whitelist|\ fpath|\ glance|\ -help|\ +-h|--help|help|\ ice|\ light|load|\ man|module|\ @@ -2253,18 +2252,37 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→} # The ice-spec is valid for next command only (i.e. it "melts"), but # it can then stick to plugin and activate e.g. at update. .zinit-ice() { - builtin setopt localoptions noksharrays extendedglob warncreateglobal typesetsilent noshortloops + builtin emulate -L zsh + builtin setopt extendedglob noksharrays noshortloops typesetsilent warncreateglobal + builtin zmodload zsh/zutil 2>/dev/null || return 1 + + local opt_help + local -a cli_usage=('Usage: zinit ice [-h|--help] [args ...]') + zparseopts -D -F -K -- {h,-help}=opt_help || return 1 + if [[ -n "$opt_help" ]]; then + builtin print -l -- $cli_usage + local -a ice_order + ice_order=( ${${(s.|.)ZINIT[ice-list]}:#teleid} ${(@)${(@)${(@Akons:|:u)${ZINIT_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}:#(.*|dynamic-unscope)} ) + +zi-log "{nl}Available ice-modifiers:" + builtin print -a -C 4 -x 2 -- ${ice_order[*]} + return 0 + fi + integer retval local bit exts="${(j:|:)${(@)${(@Akons:|:)${ZINIT_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}}" for bit; do - [[ $bit = (#b)(--|)(${~ZINIT[ice-list]}${~exts})(*) ]] && \ - ZINIT_ICES[${match[2]}]+="${ZINIT_ICES[${match[2]}]:+;}${match[3]#(:|=)}" || \ - break + if [[ $bit = (#b)(--|)(${~ZINIT[ice-list]}${~exts})(*) ]]; then + ZINIT_ICES[${match[2]}]+="${ZINIT_ICES[${match[2]}]:+;}${match[3]#(:|=)}" + else + break + fi retval+=1 done + [[ ${ZINIT_ICES[as]} = program ]] && ZINIT_ICES[as]=command [[ -n ${ZINIT_ICES[on-update-of]} ]] && ZINIT_ICES[subscribe]="${ZINIT_ICES[subscribe]:-${ZINIT_ICES[on-update-of]}}" [[ -n ${ZINIT_ICES[pick]} ]] && ZINIT_ICES[pick]="${ZINIT_ICES[pick]//\$ZPFX/${ZPFX%/}}" + return retval } # ]]] # FUNCTION: .zinit-pack-ice [[[ @@ -2536,248 +2554,159 @@ $match[7]}:-${ZINIT[__last-formatter-code]}}}:+}}}//←→} # FUNCTION: zinit [[[ # Entrypoint function directly exposed to user, consumes subcommands with respective arguments, # and completion. -zinit() { +# +zinit () { local -A ICE ZINIT_ICE - ICE=( "${(kv)ZINIT_ICES[@]}" ) - ZINIT_ICE=( "${(kv)ICE[@]}" ) + ICE=("${(kv)ZINIT_ICES[@]}") + ZINIT_ICE=("${(kv)ICE[@]}") ZINIT_ICES=() - integer ___retval ___retval2 ___correct local -a match mbegin mend - local MATCH cmd ___q="\`" ___q2="'" IFS=$' \t\n\0'; integer MBEGIN MEND - - # An annexs subcommand might use the reply vars. - match=( ${ZINIT_EXTS[(I)z-annex subcommand:$1]} ) - if (( !${#match} )) { - local -a reply; local REPLY - } - + local MATCH cmd ___q="\`" ___q2="'" IFS=$' \t\n\0' + integer MBEGIN MEND + match=(${ZINIT_EXTS[(I)z-annex subcommand:$1]}) + if (( !${#match} )); then + local -a reply + local REPLY + fi [[ -o ksharrays ]] && ___correct=1 - local -A ___opt_map OPTS - ___opt_map=( - -q opt_-q,--quiet:"update:[Turn off almost-all messages from the {cmd}update{rst} operation {b-lhi}FOR the objects{rst} which don't have any {b-lhi}new version{rst} available.] *:[Turn off any (or: almost-any) messages from the operation.]" - --quiet opt_-q,--quiet - -v opt_-v,--verbose:"Turn on more messages from the operation." - --verbose opt_-v,--verbose - -r opt_-r,--reset:"Reset the repository before updating (or remove the files for single-file snippets and gh-r plugins)." - --reset opt_-r,--reset - -a opt_-a,--all:"delete:[Delete {hi}all{rst} plugins and snippets.] update:[Update {b-lhi}all{rst} plugins and snippets.]" - --all opt_-a,--all - -c opt_-c,--clean:"Delete {b-lhi}only{rst} the {b-lhi}currently-not loaded{rst} plugins and snippets." - --clean opt_-c,--clean - -y opt_-y,--yes:"Automatically confirm any yes/no prompts." - --yes opt_-y,--yes - -f opt_-f,--force:"Force new download of the snippet file." - --force opt_-f,--force - -p opt_-p,--parallel:"Turn on concurrent, multi-thread update (of all objects)." - --parallel opt_-p,--parallel - -s opt_-s,--snippets:"snippets:[Update only snippets (i.e.: skip updating plugins).] times:[Show times in seconds instead of milliseconds.]" - --snippets opt_-s,--snippets - -L opt_-l,--plugins:"Update only plugins (i.e.: skip updating snippets)." - --plugins opt_-l,--plugins - -h opt_-h,--help:"Show this help message." - --help opt_-h,--help - -u opt_-u,--urge:"Cause all the hooks like{ehi}:{rst} {ice}atpull{apo}''{rst}, {ice}cp{apo}''{rst}, etc. to execute even when there aren't any new commits {b}/{rst} any new version of the {b}{meta}gh-r{rst} file {b}/{rst} etc.{…} available for download {ehi}{lr}{rst} simulate a non-empty update." - --urge opt_-u,--urge - -n opt_-n,--no-pager:"Disable the use of the pager." - --no-pager opt_-n,--no-pager - -m opt_-m,--moments:"Show the {apo}*{b-lhi}moments{apo}*{rst} of object (i.e.: a plugin or snippet) loading time." - --moments opt_-m,--moments - -b opt_-b,--bindkeys:"Load in light mode, however do still track {cmd}bindkey{rst} calls (to allow remapping the keys bound)." - --bindkeys opt_-b,--bindkeys - -x opt_-x,--command:"Load the snippet as a {cmd}command{rst}, i.e.: add it to {var}\$PATH{rst} and set {b-lhi}+x{rst} on it." - --command opt_-x,--command - cdclear "--help|--quiet|-h|-q" - cdreplay "--help|--quiet|-h|-q" - delete "--all|--clean|--help|--quiet|--yes|-a|-c|-h|-q|-y" - env-whitelist "--help|--verbose|-h|-v" - light "--help|-b|-h" - snippet "--command|--force|--help|-f|-h|-x" - times "--help|-h|-m|-s" - unload "--help|--quiet|-h|-q" - update "--all|--help|--no-pager|--parallel|--plugins|--quiet|--reset|--snippets|--urge|--verbose|-L|-a|-h|-n|-p|-q|-r|-s|-u|-v" - version "" - ) - + ___opt_map=(-q opt_-q,--quiet:"update:[Turn off almost-all messages from the {cmd}update{rst} operation {b-lhi}FOR the objects{rst} which don't have any {b-lhi}new version{rst} available.] *:[Turn off any (or: almost-any) messages from the operation.]" --quiet opt_-q,--quiet -v opt_-v,--verbose:"Turn on more messages from the operation." --verbose opt_-v,--verbose -r opt_-r,--reset:"Reset the repository before updating (or remove the files for single-file snippets and gh-r plugins)." --reset opt_-r,--reset -a opt_-a,--all:"delete:[Delete {hi}all{rst} plugins and snippets.] update:[Update {b-lhi}all{rst} plugins and snippets.]" --all opt_-a,--all -c opt_-c,--clean:"Delete {b-lhi}only{rst} the {b-lhi}currently-not loaded{rst} plugins and snippets." --clean opt_-c,--clean -y opt_-y,--yes:"Automatically confirm any yes/no prompts." --yes opt_-y,--yes -f opt_-f,--force:"Force new download of the snippet file." --force opt_-f,--force -p opt_-p,--parallel:"Turn on concurrent, multi-thread update (of all objects)." --parallel opt_-p,--parallel -s opt_-s,--snippets:"snippets:[Update only snippets (i.e.: skip updating plugins).] times:[Show times in seconds instead of milliseconds.]" --snippets opt_-s,--snippets -L opt_-l,--plugins:"Update only plugins (i.e.: skip updating snippets)." --plugins opt_-l,--plugins -h opt_-h,--help:"Show this help message." --help opt_-h,--help -u opt_-u,--urge:"Cause all the hooks like{ehi}:{rst} {ice}atpull{apo}''{rst}, {ice}cp{apo}''{rst}, etc. to execute even when there aren't any new commits {b}/{rst} any new version of the {b}{meta}gh-r{rst} file {b}/{rst} etc.{…} available for download {ehi}{lr}{rst} simulate a non-empty update." --urge opt_-u,--urge -n opt_-n,--no-pager:"Disable the use of the pager." --no-pager opt_-n,--no-pager -m opt_-m,--moments:"Show the {apo}*{b-lhi}moments{apo}*{rst} of object (i.e.: a plugin or snippet) loading time." --moments opt_-m,--moments -b opt_-b,--bindkeys:"Load in light mode, however do still track {cmd}bindkey{rst} calls (to allow remapping the keys bound)." --bindkeys opt_-b,--bindkeys -x opt_-x,--command:"Load the snippet as a {cmd}command{rst}, i.e.: add it to {var}\$PATH{rst} and set {b-lhi}+x{rst} on it." --command opt_-x,--command cdclear "--help|--quiet|-h|-q" cdreplay "--help|--quiet|-h|-q" delete "--all|--clean|--help|--quiet|--yes|-a|-c|-h|-q|-y" env-whitelist "--help|--verbose|-h|-v" light "--help|-b|-h" snippet "--command|--force|--help|-f|-h|-x" times "--help|-h|-m|-s" unload "--help|--quiet|-h|-q" update "--all|--help|--no-pager|--parallel|--plugins|--quiet|--reset|--snippets|--urge|--verbose|-L|-a|-h|-n|-p|-q|-r|-s|-u|-v" version "") cmd="$1" - if [[ $cmd == (times|unload|env-whitelist|update|snippet|load|light|cdreplay|\ -cdclear) ]]; then + if [[ $cmd == (times|unload|env-whitelist|update|snippet|load|light|cdreplay|cdclear) ]]; then if (( $@[(I)-*] || OPTS[opt_-h,--help] )); then .zinit-parse-opts "$cmd" "$@" if (( OPTS[opt_-h,--help] )); then +zinit-prehelp-usage-message $cmd $___opt_map[$cmd] $@ - return 1; + return 1 fi fi fi - - reply=( ${ZINIT_EXTS[(I)z-annex subcommand:*]} ) - - [[ -n $1 && $1 != (${~ZINIT[cmds]}|${(~j:|:)reply[@]#z-annex subcommand:}) || $1 = (load|light|snippet) ]] && \ - { + reply=(${ZINIT_EXTS[(I)z-annex subcommand:*]}) + [[ ( -n $1 && $1 != (${~ZINIT[cmds]}|${(~j:|:)reply[@]#z-annex subcommand:}) ) || $1 = (load|light|snippet) ]] && { integer ___error - if [[ $1 = (load|light|snippet) ]] { - integer ___is_snippet - # Classic syntax -> simulate a call through the for-syntax. + if [[ $1 = (load|light|snippet) ]]; then + integer ___is_snippet () { builtin setopt localoptions extendedglob : ${@[@]//(#b)([ $'\t']##|(#s))(-b|--command|-f|--force)([ $'\t']##|(#e))/${OPTS[${match[2]}]::=1}} } "$@" builtin set -- "${@[@]:#(-b|--command|-f|--force)}" [[ $1 = light && -z ${OPTS[(I)-b]} ]] && ICE[light-mode]= - [[ $1 = snippet ]] && ICE[is-snippet]= || ___is_snippet=-1 + [[ $1 = snippet ]] && ICE[is-snippet]= || ___is_snippet=-1 shift - - ZINIT_ICES=( "${(kv)ICE[@]}" ) + ZINIT_ICES=("${(kv)ICE[@]}") ICE=() ZINIT_ICE=() 1="${1:+@}${1#@}${2:+/$2}" - (( $# > 1 )) && { shift -p $(( $# - 1 )); } + (( $# > 1 )) && { + shift -p $(( $# - 1 )) + } [[ -z $1 ]] && { - +zinit-message "Argument needed, try: {cmd}help." - return 1 + +zinit-message "Argument needed, try: {cmd}help." + return 1 } - } else { + else .zinit-ice "$@" ___retval2=$? local ___last_ice=${@[___retval2]} shift ___retval2 - if [[ $# -gt 0 && $1 != for ]] { - +zinit-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Unknown subcommand{ehi}:" \ - "{apo}\`{cmd}$1{apo}\`{rst} " + if [[ $# -gt 0 && $1 != for ]]; then + +zinit-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Unknown subcommand{ehi}:" "{apo}\`{cmd}$1{apo}\`{rst} " +zinit-prehelp-usage-message rst return 1 - } elif (( $# == 0 )) { + elif (( $# == 0 )); then ___error=1 - } else { + else shift - } - } + fi + fi integer ___had_wait local ___id ___ehid ___etid ___key local -a ___arr ZINIT[annex-exposed-processed-IDs]= - if (( $# )) { + if (( $# )); then local -a ___ices - ___ices=( "${(kv)ZINIT_ICES[@]}" ) + ___ices=("${(kv)ZINIT_ICES[@]}") ZINIT_ICES=() - while (( $# )) { + while (( $# )); do .zinit-ice "$@" ___retval2=$? local ___last_ice=${@[___retval2]} shift ___retval2 - if [[ -n $1 ]] { - ICE=( "${___ices[@]}" "${(kv)ZINIT_ICES[@]}" ) - ZINIT_ICE=( "${(kv)ICE[@]}" ) ZINIT_ICES=() + if [[ -n $1 ]]; then + ICE=("${___ices[@]}" "${(kv)ZINIT_ICES[@]}") + ZINIT_ICE=("${(kv)ICE[@]}") ZINIT_ICES=() integer ___msgs=${+ICE[debug]} (( ___msgs )) && +zinit-message "{pre}zinit-main:{faint} Processing {pname}$1{faint}{…}{rst}" - - # Delete up to the final space to get the previously-processed ID. ZINIT[annex-exposed-processed-IDs]+="${___id:+ $___id}" - - # Strip the ID-qualifier (`@') and GitHub domain from the ID. ___id="${${1#@}%%(///|//|/)}" (( ___is_snippet == -1 )) && ___id="${___id#https://github.com/}" - - # Effective handle-ID – the label under which the object - # will be identified / referred-to by Zinit. ___ehid="${ICE[id-as]:-$___id}" - - # Effective remote-ID (i.e.: URL, GitHub username/repo, - # package name, etc.). teleid'' allows "overriding" of $1. - # In case of a package using teleid'', the value here - # is being took from the given ices, before disk-ices. ___etid="${ICE[teleid]:-$___id}" - if (( ${+ICE[pack]} )); then ___had_wait=${+ICE[wait]} .zinit-load-ices "$___ehid" - # wait'' isn't possible via the disk-ices (for - # packages), only via the command's ice-spec. [[ $___had_wait -eq 0 ]] && unset 'ICE[wait]' fi - [[ ${ICE[id-as]} = (auto|) && ${+ICE[id-as]} == 1 ]] && ICE[id-as]="${___etid:t}" - - integer ___is_snippet=${${(M)___is_snippet:#-1}:-0} + integer ___is_snippet=${${(M)___is_snippet:#-1}:-0} () { builtin setopt localoptions extendedglob - if [[ $___is_snippet -ge 0 && ( -n ${ICE[is-snippet]+1} || $___etid = ((#i)(http(s|)|ftp(s|)):/|(${(~kj.|.)ZINIT_1MAP}))* ) ]] { + if [[ $___is_snippet -ge 0 && ( -n ${ICE[is-snippet]+1} || $___etid = ((#i)(http(s|)|ftp(s|)):/|(${(~kj.|.)ZINIT_1MAP}))* ) ]]; then ___is_snippet=1 - } + fi } "$@" - local ___type=${${${(M)___is_snippet:#1}:+snippet}:-plugin} - reply=( - ${(on)ZINIT_EXTS2[(I)zinit hook:before-load-pre <->]} - ${(on)ZINIT_EXTS[(I)z-annex hook:before-load-<-> <->]} - ${(on)ZINIT_EXTS2[(I)zinit hook:before-load-post <->]} - ) + reply=(${(on)ZINIT_EXTS2[(I)zinit hook:before-load-pre <->]} ${(on)ZINIT_EXTS[(I)z-annex hook:before-load-<-> <->]} ${(on)ZINIT_EXTS2[(I)zinit hook:before-load-post <->]}) for ___key in "${reply[@]}"; do - ___arr=( "${(Q)${(z@)ZINIT_EXTS[$___key]:-$ZINIT_EXTS2[$___key]}[@]}" ) - "${___arr[5]}" "$___type" "$___id" "${ICE[id_as]}" \ - "${(j: :)${(q)@[2,-1]}}" "${(j: :)${(qkv)___ices[@]}}" \ - "${${___key##(zinit|z-annex) hook:}%% <->}" load + ___arr=("${(Q)${(z@)ZINIT_EXTS[$___key]:-$ZINIT_EXTS2[$___key]}[@]}") + "${___arr[5]}" "$___type" "$___id" "${ICE[id_as]}" "${(j: :)${(q)@[2,-1]}}" "${(j: :)${(qkv)___ices[@]}}" "${${___key##(zinit|z-annex) hook:}%% <->}" load ___retval2=$? - if (( ___retval2 )) { - # An error is actually only an odd return code. + if (( ___retval2 )); then ___retval+=$(( ___retval2 & 1 ? ___retval2 : 0 )) (( ___retval2 & 1 && $# )) && shift - - # Override $@? - if (( ___retval2 & 2 )) { + if (( ___retval2 & 2 )); then local -a ___args - ___args=( "${(@Q)${(@z)ZINIT[annex-before-load:new-@]}}" ) + ___args=("${(@Q)${(@z)ZINIT[annex-before-load:new-@]}}") builtin set -- "${___args[@]}" - } - - # Override $___ices? - if (( ___retval2 & 4 )) { + fi + if (( ___retval2 & 4 )); then local -a ___new_ices - ___new_ices=( "${(Q@)${(@z)ZINIT[annex-before-load:new-global-ices]}}" ) - (( 0 == ${#___new_ices} % 2 )) && \ - ___ices=( "${___new_ices[@]}" ) || \ - { [[ ${ZINIT[MUTE_WARNINGS]} != (1|true|on|yes) ]] && \ - +zinit-message "{u-warn}Warning{b-warn}:{msg} Bad new-ices returned" \ - "from the annex{ehi}:{rst} {annex}${___arr[3]}{msg}," \ - "please file an issue report at:{url}" \ - "https://github.com/zdharma-continuum/${___arr[3]}/issues/new{msg}.{rst}" - ___ices=( ) ___retval+=7 - } - } + ___new_ices=("${(Q@)${(@z)ZINIT[annex-before-load:new-global-ices]}}") + (( 0 == ${#___new_ices} % 2 )) && ___ices=("${___new_ices[@]}") || { + [[ ${ZINIT[MUTE_WARNINGS]} != (1|true|on|yes) ]] && +zinit-message "{u-warn}Warning{b-warn}:{msg} Bad new-ices returned" "from the annex{ehi}:{rst} {annex}${___arr[3]}{msg}," "please file an issue report at:{url}" "https://github.com/zdharma-continuum/${___arr[3]}/issues/new{msg}.{rst}" + ___ices=() ___retval+=7 + } + fi continue 2 - } + fi done integer ___action_load=0 ___turbo=0 - if [[ -n ${(M)${+ICE[wait]}:#1}${ICE[load]}${ICE[unload]}${ICE[service]}${ICE[subscribe]} ]] { + if [[ -n ${(M)${+ICE[wait]}:#1}${ICE[load]}${ICE[unload]}${ICE[service]}${ICE[subscribe]} ]]; then ___turbo=1 - } - - if [[ -n ${ICE[trigger-load]} || \ - ( ${+ICE[wait]} == 1 && - ${ICE[wait]} = (\!|)(<->(a|b|c|)|) ) - ]] && (( !ZINIT[OPTIMIZE_OUT_DISK_ACCESSES] - )) { - if (( ___is_snippet > 0 )) { + fi + if [[ -n ${ICE[trigger-load]} || ( ${+ICE[wait]} == 1 && ${ICE[wait]} = (\!|)(<->(a|b|c|)|) ) ]] && (( !ZINIT[OPTIMIZE_OUT_DISK_ACCESSES] )); then + if (( ___is_snippet > 0 )); then .zinit-get-object-path snippet $___ehid - } else { + else .zinit-get-object-path plugin $___ehid + fi + (( $? )) && [[ ${zsh_eval_context[1]} = file ]] && { + ___action_load=1 } - (( $? )) && [[ ${zsh_eval_context[1]} = file ]] && { ___action_load=1; } local ___object_path="$REPLY" - } elif (( ! ___turbo )) { + elif (( ! ___turbo )); then ___action_load=1 - reply=( 1 ) - } else { - reply=( 1 ) - } - - if [[ ${reply[-1]} -eq 1 && -n ${ICE[trigger-load]} ]] { + reply=(1) + else + reply=(1) + fi + if [[ ${reply[-1]} -eq 1 && -n ${ICE[trigger-load]} ]]; then () { builtin setopt localoptions extendedglob local ___mode - (( ___is_snippet > 0 )) && ___mode=snippet || ___mode="${${${ICE[light-mode]+light}}:-load}" - for MATCH ( ${(s.;.)ICE[trigger-load]} ) { + (( ___is_snippet > 0 )) && ___mode=snippet || ___mode="${${${ICE[light-mode]+light}}:-load}" + for MATCH in ${(s.;.)ICE[trigger-load]}; do eval "${MATCH#!}() { ${${(M)MATCH#!}:+unset -f ${MATCH#!}} local a b; local -a ices @@ -2789,130 +2718,130 @@ cdclear) ]]; then ${${(M)MATCH#!}:+# Forward the call eval ${MATCH#!} \$@} }" - } + done } "$@" ___retval+=$? (( $# )) && shift continue - } - - if (( ${+ICE[if]} )) { - eval "${ICE[if]}" || { (( $# )) && shift; continue; }; - } - for REPLY ( ${(s.;.)ICE[has]} ) { - (( ${+commands[$REPLY]} )) || \ - { (( $# )) && shift; continue 2; } - } - + fi + if (( ${+ICE[if]} )); then + eval "${ICE[if]}" || { + (( $# )) && shift + continue + } + fi + for REPLY in ${(s.;.)ICE[has]}; do + (( ${+commands[$REPLY]} )) || { + (( $# )) && shift + continue 2 + } + done integer ___had_cloneonly=0 ICE[wait]="${${(M)${+ICE[wait]}:#1}:+${(M)ICE[wait]#!}${${ICE[wait]#!}:-0}}" - if (( ___action_load || !ZINIT[HAVE_SCHEDULER] )) { - if (( ___turbo && ZINIT[HAVE_SCHEDULER] )) { + if (( ___action_load || !ZINIT[HAVE_SCHEDULER] )); then + if (( ___turbo && ZINIT[HAVE_SCHEDULER] )); then ___had_cloneonly=${+ICE[cloneonly]} ICE[cloneonly]="" - } - - (( ___is_snippet )) && \ - local ___opt="${(k)OPTS[*]}" || \ - local ___opt="${${ICE[light-mode]+light}:-${OPTS[(I)-b]:+light-b}}" - + fi + (( ___is_snippet )) && local ___opt="${(k)OPTS[*]}" || local ___opt="${${ICE[light-mode]+light}:-${OPTS[(I)-b]:+light-b}}" .zinit-load-object ${${${(M)___is_snippet:#1}:+snippet}:-plugin} $___id $___opt integer ___last_retval=$? ___retval+=___last_retval - - if (( ___turbo && !___had_cloneonly && ZINIT[HAVE_SCHEDULER] )) { + if (( ___turbo && !___had_cloneonly && ZINIT[HAVE_SCHEDULER] )); then command rm -f $___object_path/._zinit/cloneonly unset 'ICE[cloneonly]' - } - } - if (( ___turbo && ZINIT[HAVE_SCHEDULER] && 0 == ___last_retval )) { + fi + fi + if (( ___turbo && ZINIT[HAVE_SCHEDULER] && 0 == ___last_retval )); then ICE[wait]="${ICE[wait]:-${ICE[service]:+0}}" if (( ___is_snippet > 0 )); then ZINIT_SICE[$___ehid]= - .zinit-submit-turbo s${ICE[service]:+1} "" \ - "$___id" "${(k)OPTS[*]}" + .zinit-submit-turbo s${ICE[service]:+1} "" "$___id" "${(k)OPTS[*]}" else ZINIT_SICE[$___ehid]= - .zinit-submit-turbo p${ICE[service]:+1} \ - "${${${ICE[light-mode]+light}}:-load}" \ - "$___id" "" + .zinit-submit-turbo p${ICE[service]:+1} "${${${ICE[light-mode]+light}}:-load}" "$___id" "" fi ___retval+=$? - } - } else { + fi + else ___error=1 - } + fi (( $# )) && shift ___is_snippet=0 - } - } else { + done + else ___error=1 - } - - if (( ___error )) { + fi + if (( ___error )); then () { builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} +zinit-message -n "{u-warn}Error{b-warn}:{rst} No plugin or snippet ID given" - if [[ -n $___last_ice ]] { - +zinit-message -n " (the last recognized ice was: {ice}"\ -"${___last_ice/(#m)(${~ZINIT[ice-list]})/"{data}$MATCH"}{apo}''{rst}).{error} + if [[ -n $___last_ice ]]; then + +zinit-message -n " (the last recognized ice was: {ice}""${___last_ice/(#m)(${~ZINIT[ice-list]})/"{data}$MATCH"}{apo}''{rst}).{error} You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice is in fact a plugin.{rst} {note}Note:{rst} The {apo}\`{ice}ice{apo}\`{rst} subcommand is now again required if not using the for-syntax" - } + fi +zinit-message "." } return 2 - } elif (( ! $# )) { - return ___retval - } + elif (( ! $# )); then + return ___retval + fi } - case "$1" in - (ice) - shift - .zinit-ice "$@" - ;; - (cdreplay) - .zinit-compdef-replay "$2"; ___retval=$? - ;; - (cdclear) - .zinit-compdef-clear "$2" - ;; - (add-fpath|fpath) - .zinit-add-fpath "${@[2-correct,-1]}" - ;; - (run) - .zinit-run "${@[2-correct,-1]}" - ;; - - (man) - man "${ZINIT[BIN_DIR]}/doc/zinit.1" - ;; - (env-whitelist) + (ice) + shift + .zinit-ice $@ + ;; + (cdreplay) + .zinit-compdef-replay "$2" + ___retval=$? + ;; + (cdclear) + .zinit-compdef-clear "$2" + ;; + (add-fpath|fpath) + .zinit-add-fpath "${@[2-correct,-1]}" + ;; + (run) + .zinit-run "${@[2-correct,-1]}" + ;; + (man) + man "${ZINIT[BIN_DIR]}/doc/zinit.1" + ;; + (env-whitelist) shift .zinit-parse-opts env-whitelist "$@" builtin set -- "${reply[@]}" - - if (( $# == 0 )) { + if (( $# == 0 )); then ZINIT[ENV-WHITELIST]= (( OPTS[opt_-v,--verbose] )) && +zinit-message "{msg2}Cleared the parameter whitelist.{rst}" - } else { + else ZINIT[ENV-WHITELIST]+="${(j: :)${(q-kv)@}} " local ___sep="$ZINIT[col-msg2], $ZINIT[col-data2]" (( OPTS[opt_-v,--verbose] )) && +zinit-message "{msg2}Extended the parameter whitelist with: {data2}${(pj:$___sep:)@}{msg2}.{rst}" - } + fi ;; - (*) - # Check if there is a z-annex registered for the subcommand. - reply=( ${ZINIT_EXTS[z-annex subcommand:${(q)1}]} ) - (( ${#reply} )) && { - reply=( "${(Q)${(z@)reply[1]}[@]}" ) - (( ${+functions[${reply[5]}]} )) && \ - { "${reply[5]}" "$@"; return $?; } || \ - { +zinit-message "({error}Couldn't find the subcommand-handler \`{obj}${reply[5]}{error}' of the z-annex \`{file}${reply[3]}{error}')"; return 1; } - } - (( ${+functions[.zinit-confirm]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-autoload.zsh" || return 1 - case "$1" in + (*) + reply=(${ZINIT_EXTS[z-annex subcommand:${(q)1}]}) + (( ${#reply} )) && { + reply=("${(Q)${(z@)reply[1]}[@]}") + (( ${+functions[${reply[5]}]} )) && { + "${reply[5]}" "$@" + return $? + } || { + +zinit-message "({error}Couldn't find the subcommand-handler \`{obj}${reply[5]}{error}' of the z-annex \`{file}${reply[3]}{error}')" + return 1 + } + } + (( ${+functions[.zinit-confirm]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-autoload.zsh" || return 1 + case "$1" in + (--help|-h|help) + .zinit-help + ;; + (version) + zi::version + ;; (zstatus) .zinit-show-zstatus ;; @@ -2929,51 +2858,68 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice (unload) (( ${+functions[.zinit-unload]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-autoload.zsh" || return 1 if [[ -z $2 && -z $3 ]]; then - builtin print "Argument needed, try: help"; ___retval=1 + builtin print "Argument needed, try: help" + ___retval=1 else - [[ $2 = -q ]] && { 5=-q; shift; } - # Unload given plugin. Cloned directory remains intact - # so as are completions. - .zinit-unload "${2%%(///|//|/)}" "${${3:#-q}%%(///|//|/)}" "${${(M)4:#-q}:-${(M)3:#-q}}"; ___retval=$? + [[ $2 = -q ]] && { + 5=-q + shift + } + .zinit-unload "${2%%(///|//|/)}" "${${3:#-q}%%(///|//|/)}" "${${(M)4:#-q}:-${(M)3:#-q}}" + ___retval=$? fi ;; - (bindkeys) + (bindkeys) .zinit-list-bindkeys ;; - (update) - if (( ${+ICE[if]} )) { - eval "${ICE[if]}" || return 1; - } - for REPLY ( ${(s.;.)ICE[has]} ) { + (update) + if (( ${+ICE[if]} )); then + eval "${ICE[if]}" || return 1 + fi + for REPLY in ${(s.;.)ICE[has]}; do (( ${+commands[$REPLY]} )) || return 1 - } + done shift .zinit-parse-opts update "$@" builtin set -- "${reply[@]}" if [[ ${OPTS[opt_-a,--all]} -eq 1 || ${OPTS[opt_-p,--parallel]} -eq 1 || ${OPTS[opt_-s,--snippets]} -eq 1 || ${OPTS[opt_-l,--plugins]} -eq 1 || -z $1$2${ICE[teleid]}${ICE[id-as]} ]]; then - [[ -z $1$2 && $(( OPTS[opt_-a,--all] + OPTS[opt_-p,--parallel] + OPTS[opt_-s,--snippets] + OPTS[opt_-l,--plugins] )) -eq 0 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; } + [[ -z $1$2 && $(( OPTS[opt_-a,--all] + OPTS[opt_-p,--parallel] + OPTS[opt_-s,--snippets] + OPTS[opt_-l,--plugins] )) -eq 0 ]] && { + builtin print -r -- "Assuming --all is passed" + sleep 3 + } (( OPTS[opt_-p,--parallel] )) && OPTS[value]=${1:-15} - .zinit-update-or-status-all update; ___retval=$? + .zinit-update-or-status-all update + ___retval=$? else local ___key ___id="${1%%(///|//|/)}${2:+/}${2%%(///|//|/)}" [[ -z ${___id//[[:space:]]/} ]] && ___id="${ICE[id-as]:-$ICE[teleid]}" - .zinit-update-or-status update "$___id" ""; ___retval=$? + .zinit-update-or-status update "$___id" "" + ___retval=$? fi ;; (status) if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then - [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; } - .zinit-update-or-status-all status; ___retval=$? + [[ -z $2 ]] && { + builtin print -r -- "Assuming --all is passed" + sleep 3 + } + .zinit-update-or-status-all status + ___retval=$? else - .zinit-update-or-status status "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$? + .zinit-update-or-status status "${2%%(///|//|/)}" "${3%%(///|//|/)}" + ___retval=$? fi ;; (report) if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then - [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 4; } + [[ -z $2 ]] && { + builtin print -r -- "Assuming --all is passed" + sleep 4 + } .zinit-show-all-reports else - .zinit-show-report "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$? + .zinit-show-report "${2%%(///|//|/)}" "${3%%(///|//|/)}" + ___retval=$? fi ;; (plugins) @@ -2982,19 +2928,18 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice (snippets) .zinit-list-snippets "$2" ;; - (completions) # Show installed, enabled or disabled, completions and detect stray and improper ones + (completions) .zinit-show-completions "$2" ;; - (cclear) # Delete stray and improper completions. + (cclear) .zinit-clear-completions ;; (cdisable) if [[ -z $2 ]]; then - builtin print "Argument needed, try: help"; ___retval=1 + builtin print "Argument needed, try: help" + ___retval=1 else local ___f="_${2#_}" - # Disable completion given by completion function name - # with or without leading _, e.g. cp, _cp. if .zinit-cdisable "$___f"; then (( ${+functions[.zinit-forget-completion]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-install.zsh" || return 1 .zinit-forget-completion "$___f" @@ -3008,11 +2953,10 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice ;; (cenable) if [[ -z $2 ]]; then - builtin print "Argument needed, try: help"; ___retval=1 + builtin print "Argument needed, try: help" + ___retval=1 else - local ___f="_${2#_}" - # Enable completion given by completion function name - # with or without leading _, e.g. cp, _cp. + local ___f="_${2#_}" if .zinit-cenable "$___f"; then (( ${+functions[.zinit-forget-completion]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-install.zsh" || return 1 .zinit-forget-completion "$___f" @@ -3026,20 +2970,24 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice ;; (creinstall) (( ${+functions[.zinit-install-completions]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-install.zsh" || return 1 - # Installs completions for plugin. Enables them all. It is a reinstallation, thus every obstacle gets overwritten or removed. - [[ $2 = -[qQ] ]] && { 5=$2; shift; } - .zinit-install-completions "${2%%(///|//|/)}" "${3%%(///|//|/)}" 1 "${(M)4:#-[qQ]}"; ___retval=$? + [[ $2 = -[qQ] ]] && { + 5=$2 + shift + } + .zinit-install-completions "${2%%(///|//|/)}" "${3%%(///|//|/)}" 1 "${(M)4:#-[qQ]}" + ___retval=$? [[ -z ${(M)4:#-[qQ]} ]] && +zinit-message "Initializing completion ({func}compinit{rst}){…}" builtin autoload -Uz compinit compinit -d ${ZINIT[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZINIT[COMPINIT_OPTS]}}" ;; (cuninstall) if [[ -z $2 && -z $3 ]]; then - builtin print "Argument needed, try: help"; ___retval=1 + builtin print "Argument needed, try: help" + ___retval=1 else (( ${+functions[.zinit-forget-completion]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-install.zsh" || return 1 - # Uninstalls completions for plugin. - .zinit-uninstall-completions "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$? + .zinit-uninstall-completions "${2%%(///|//|/)}" "${3%%(///|//|/)}" + ___retval=$? +zinit-message "Initializing completion ({func}compinit{rst}){…}" builtin autoload -Uz compinit compinit -d ${ZINIT[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZINIT[COMPINIT_OPTS]}}" @@ -3050,28 +2998,38 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice ;; (compinit) (( ${+functions[.zinit-forget-completion]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-install.zsh" || return 1 - .zinit-compinit; ___retval=$? + .zinit-compinit + ___retval=$? ;; (compile) (( ${+functions[.zinit-compile-plugin]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-install.zsh" || return 1 if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then - [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; } - .zinit-compile-uncompile-all 1; ___retval=$? + [[ -z $2 ]] && { + builtin print -r -- "Assuming --all is passed" + sleep 3 + } + .zinit-compile-uncompile-all 1 + ___retval=$? else - .zinit-compile-plugin "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$? + .zinit-compile-plugin "${2%%(///|//|/)}" "${3%%(///|//|/)}" + ___retval=$? fi ;; - (debug) - shift; + (debug) shift (( ${+functions[+zinit-debug]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-additional.zsh" +zinit-debug $@ ;; (uncompile) if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then - [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; } - .zinit-compile-uncompile-all 0; ___retval=$? + [[ -z $2 ]] && { + builtin print -r -- "Assuming --all is passed" + sleep 3 + } + .zinit-compile-uncompile-all 0 + ___retval=$? else - .zinit-uncompile-plugin "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$? + .zinit-uncompile-plugin "${2%%(///|//|/)}" "${3%%(///|//|/)}" + ___retval=$? fi ;; (compiled) @@ -3081,47 +3039,49 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice .zinit-list-compdef-replay ;; (cd|recall|edit|glance|changes|create|stress) - .zinit-"$1" "${@[2-correct,-1]%%(///|//|/)}"; ___retval=$? + .zinit-"$1" "${@[2-correct,-1]%%(///|//|/)}" + ___retval=$? ;; (recently) shift - .zinit-recently "$@"; ___retval=$? - ;; - (-h|--help|help) - .zinit-help - ;; - (version) - zi::version + .zinit-recently "$@" + ___retval=$? ;; (srv) - () { setopt localoptions extendedglob warncreateglobal - [[ ! -e ${ZINIT[SERVICES_DIR]}/"$2".fifo ]] && { builtin print "No such service: $2"; } || - { [[ $3 = (#i)(next|stop|quit|restart) ]] && - { builtin print "${(U)3}" >>! ${ZINIT[SERVICES_DIR]}/"$2".fifo || builtin print "Service $2 inactive"; ___retval=1; } || - { [[ $3 = (#i)start ]] && rm -f ${ZINIT[SERVICES_DIR]}/"$2".stop || - { builtin print "Unknown service-command: $3"; ___retval=1; } + () { + setopt localoptions extendedglob warncreateglobal + [[ ! -e ${ZINIT[SERVICES_DIR]}/"$2".fifo ]] && { + builtin print "No such service: $2" + } || { + [[ $3 = (#i)(next|stop|quit|restart) ]] && { + builtin print "${(U)3}" >>| ${ZINIT[SERVICES_DIR]}/"$2".fifo || builtin print "Service $2 inactive" + ___retval=1 + } || { + [[ $3 = (#i)start ]] && rm -f ${ZINIT[SERVICES_DIR]}/"$2".stop || { + builtin print "Unknown service-command: $3" + ___retval=1 } + } } } "$@" ;; (module) - .zinit-module "${@[2-correct,-1]}"; ___retval=$? + .zinit-module "${@[2-correct,-1]}" + ___retval=$? ;; - (*) - if [[ -z $1 ]] { - +zinit-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Missing a {cmd}subcommand " - +zinit-prehelp-usage-message rst - } else { - +zinit-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Unknown subcommand{ehi}:{rst}" \ - "{apo}\`{error}$1{apo}\`{rst} " - +zinit-prehelp-usage-message rst - } + (*) + if [[ -z $1 ]]; then + +zinit-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Missing a {cmd}subcommand " + +zinit-prehelp-usage-message rst + else + +zinit-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Unknown subcommand{ehi}:{rst}" "{apo}\`{error}$1{apo}\`{rst} " + +zinit-prehelp-usage-message rst + fi ___retval=1 ;; - esac - ;; + esac + ;; esac - return ___retval } # ]]] # FUNCTION: zicdreplay [[[