diff --git a/.github/labeler.yml b/.github/labeler.yml index 6c1a3b85d..6f817c6fe 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,4 +1,5 @@ ci/cd: ['.github/**/*'] +completion: ['_zinit'] docker: ['docker/*'] docs: ['*.md', 'doc/**/*'] scripts: ['scripts/*'] diff --git a/.github/workflows/containers.yaml b/.github/workflows/containers.yaml index d53108d41..a645e9695 100644 --- a/.github/workflows/containers.yaml +++ b/.github/workflows/containers.yaml @@ -42,7 +42,7 @@ jobs: - name: build and push id: docker_build_zsh_versions - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v4 timeout-minutes: 90 # compiling older zsh versions take a long time with: push: ${{ github.event.number == 0 }} @@ -84,7 +84,7 @@ jobs: - name: build & push new image id: docker_build_latest - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v4 if: github.ref == 'refs/heads/main' with: push: true diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 4c16b728a..a77f2dc67 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -30,7 +30,7 @@ jobs: echo "" >> $GITHUB_STEP_SUMMARY # this is a blank line if ! git --no-pager diff --exit-code; then echo "::error:: Z-shelldocs are out-of-date." >> $GITHUB_STEP_SUMMARY - echo "To regenerate, run `make doc`" >> $GITHUB_STEP_SUMMARY + echo 'To regenerate, run `make doc`' >> $GITHUB_STEP_SUMMARY exit 1 else echo "::notice:: Z-shelldocs are up-to-date." >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0b1bdc9c..d10770464 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,10 +11,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - cache-dependency-path: '**/.github/workflows/release.yml' - cache: 'npm' - check-latest: true - node-version: '16' + node-version: '18' - name: Fetch dependencies run: | diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index dd3504872..63ba24f2b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -12,23 +12,21 @@ on: branches: - main paths: - - 'tests/**' - - 'share/**' - - 'zinit*.zsh' - - '.github/workflows/tests.yaml' + - "tests/**" + - "share/**" + - "zinit*.zsh" + - ".github/workflows/tests.yaml" push: branches: - main workflow_dispatch: jobs: - zunit-tests: - runs-on: ${{ matrix.os }} strategy: matrix: - os: ['macos-latest','ubuntu-latest'] + os: ["macos-latest", "ubuntu-latest"] fail-fast: false steps: @@ -58,9 +56,15 @@ jobs: git clone --depth 1 https://github.com/zdharma-continuum/zunit; cd ./zunit zsh -c -l './build.zsh' && sudo chmod u+x ./zunit && cp ./zunit "$HOME/.local/bin/" + # - name: disable secssessment system policy security + # run: sudo spctl --master-disable + - name: "annexes" run: zunit run tests/annexes.zunit + - name: "commands" + run: zunit run tests/commands.zunit + - name: "gh-r" run: zunit run --fail-fast --verbose tests/gh-r.zunit diff --git a/CHANGELOG.md b/CHANGELOG.md index 824b23a1f..63b0d78bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,45 @@ +# [3.10.0](https://github.com/zdharma-continuum/zinit/compare/v3.9.0...v3.10.0) (2023-04-02) + + +### Bug Fixes + +* absolute path support in the symbol browser ([d29a8ba](https://github.com/zdharma-continuum/zinit/commit/d29a8ba2b757b936663c16d12e46d3638f44027a)) +* assign to functions hash to make %x work ([bd65a01](https://github.com/zdharma-continuum/zinit/commit/bd65a017345ac891b6b14eb5feb4182bc9c74ace)) +* broken symbolic link after `creinstall .` ([da0d6b7](https://github.com/zdharma-continuum/zinit/commit/da0d6b712c6466d11165ac9e27a6cd7de856e537)) +* bump node version in release workflow ([938f483](https://github.com/zdharma-continuum/zinit/commit/938f48375b20545078b63d6c1dba0a905599afe4)) +* change prefix `~zi::` to `__zi::` ([0e45493](https://github.com/zdharma-continuum/zinit/commit/0e45493e36ff350c79c164895bd4718103e2cf7a)) +* container build & shell make targets ([a72fb83](https://github.com/zdharma-continuum/zinit/commit/a72fb83f0999a7fa4a26c6e1bb71d6cab3858b4f)) +* container build & shell make targets ([14b2cda](https://github.com/zdharma-continuum/zinit/commit/14b2cda0397c343b1bfdc041cba7c4ab216e3803)) +* container build & shell make targets ([370808d](https://github.com/zdharma-continuum/zinit/commit/370808dd5186f4b9c8a214e7ef6f4350df243b5b)) +* container build & shell make targets ([47bd74f](https://github.com/zdharma-continuum/zinit/commit/47bd74f8a7c74761e9b03943d3c40fc523df585f)) +* container build & shell make targets ([f8eb967](https://github.com/zdharma-continuum/zinit/commit/f8eb967b0e98f135b43cb5065aceb8a4f058aa09)) +* container build & shell make targets ([3af321e](https://github.com/zdharma-continuum/zinit/commit/3af321e8e4975a07634df08acda383e4cf53e99c)) +* do not run `make docs` ([3802893](https://github.com/zdharma-continuum/zinit/commit/3802893c74988fc03bad086601c905a1046a9fc1)) +* failing zunit tests & bootstrap script ([d618467](https://github.com/zdharma-continuum/zinit/commit/d618467ff090a6dbfb327ca0a29141d0c9312b24)) +* file modelines ([75bb735](https://github.com/zdharma-continuum/zinit/commit/75bb73547ed24ab6d25e1aed03684caebba39f5e)) +* gh-r & bpick ice log format and content ([ad88a89](https://github.com/zdharma-continuum/zinit/commit/ad88a890ad25505acb764f9551ee00d5264daa9a)) +* gh-r parsing logic for arm64 & logging style ([7e48651](https://github.com/zdharma-continuum/zinit/commit/7e486519d7aad48a8b6009ae5075f0efec2409f9)) +* gh-r pattern for 64bit linux-gnu systems ([b5a31c0](https://github.com/zdharma-continuum/zinit/commit/b5a31c07f2bd2d823ce9e99b98228ec68db523bd)) +* lsd repo owner changed to lsd-rs organization ([#489](https://github.com/zdharma-continuum/zinit/issues/489)) ([824d9d3](https://github.com/zdharma-continuum/zinit/commit/824d9d36177dac00a81333205e2b3dfbc35cb758)) +* make gh-r release search case-insensitive ([3eb75b7](https://github.com/zdharma-continuum/zinit/commit/3eb75b7ee9db4dd01455811cf4ca4539dd07246b)) +* make target docker cmd flags ([dd04896](https://github.com/zdharma-continuum/zinit/commit/dd048964491b9a63f4622b591b9a227d5e981408)) +* pin `ggsrun` version in gh-r z-unit test ([9f67798](https://github.com/zdharma-continuum/zinit/commit/9f677989e8386469bc2d5dcb0d2cb5d62d489e34)) +* the starship example does not work properly ([4933b62](https://github.com/zdharma-continuum/zinit/commit/4933b62f400a1b6b29b82a9ff233911b336a33c5)) +* update pygmentize flags in glance subcommand ([#488](https://github.com/zdharma-continuum/zinit/issues/488)) ([b773763](https://github.com/zdharma-continuum/zinit/commit/b773763bdc37d414a5d954ccb00877374177f0ec)) +* use correct return code in zinit-confirm ([d467738](https://github.com/zdharma-continuum/zinit/commit/d467738c1b1c834e938b4b4bb6e83cab5bfdc429)) +* vim modelines & zsdoc pdf rendering ([2b460a7](https://github.com/zdharma-continuum/zinit/commit/2b460a74f236178cd8d06b55069049381d79256e)) + + +### Features + +* delete subcommand refactor ([9eee215](https://github.com/zdharma-continuum/zinit/commit/9eee215e3f8ee7d8404e4e54f8ef57a57a21fde2)), closes [#57](https://github.com/zdharma-continuum/zinit/issues/57) [#239](https://github.com/zdharma-continuum/zinit/issues/239) +* zinit completion improvements ([b8d12e5](https://github.com/zdharma-continuum/zinit/commit/b8d12e555d4cadff7769ef67c5d4c0d403f0b11e)) + + +### Reverts + +* "Merge branch 'refactor/zinit-function-names' into main" ([515688b](https://github.com/zdharma-continuum/zinit/commit/515688bc976e793422d21ba9debfdd1a982c611e)) + # [3.9.0](https://github.com/zdharma-continuum/zinit/compare/v3.8.0...v3.9.0) (2022-12-17) diff --git a/README.md b/README.md index 966dbac48..2ada429ef 100644 --- a/README.md +++ b/README.md @@ -133,8 +133,8 @@ In your `.zshrc`, add the following snippet ```zsh ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" -mkdir -p "$(dirname $ZINIT_HOME)" -git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" +[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)" +[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" source "${ZINIT_HOME}/zinit.zsh" ``` @@ -210,9 +210,12 @@ zinit ice pick"async.zsh" src"pure.zsh" # with zsh-async library that's bundled zinit light sindresorhus/pure # Load starship theme -zinit ice as"command" from"gh-r" \ # `starship` binary as command, from github release - atclone"./starship init zsh > init.zsh; ./starship completions zsh > _starship" \ # starship setup at clone(create init.zsh, completion) - atpull"%atclone" src"init.zsh" # pull behavior same as clone, source init.zsh +# line 1: `starship` binary as command, from github release +# line 2: starship setup at clone(create init.zsh, completion) +# line 3: pull behavior same as clone, source init.zsh +zinit ice as"command" from"gh-r" \ + atclone"./starship init zsh > init.zsh; ./starship completions zsh > _starship" \ + atpull"%atclone" src"init.zsh" zinit light starship/starship ``` @@ -813,7 +816,7 @@ Following commands are passed to `zinit ...` to obtain described effects. ### Completions | Command | Description | -| :------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | +| -------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | `cclear` | Clear stray and improper completions. | | `cdclear [-q]` | Clear compdef replay list. `-q` – quiet. | | `cdisable {cname}` | Disable completion `cname`. | @@ -829,7 +832,7 @@ Following commands are passed to `zinit ...` to obtain described effects. ### Tracking of the Active Session | Command | Description | -| :--------------- | ------------------------------------------------- | +| ---------------- | ------------------------------------------------- | | `dclear` | Clear report of what was going on in session. | | `dstop` | Stop investigating what's going on in session. | | `dreport` | Report what was going on in session. | @@ -838,21 +841,21 @@ Following commands are passed to `zinit ...` to obtain described effects. ### Reports and Statistics -| Command | Description | -| :--------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `ls` | List snippets in formatted and colorized manner. Requires `tree` program. | -| `bindkeys` | Lists bindkeys set up by each plugin. | -| `zstatus` | Overall Zinit status. | -| `report {plg-spec}` | Show plugin report. `--all` – do it for all plugins. | -| `status {plg-spec}` | Git status for plugin or svn status for snippet. `--all` – do it for all plugins and snippets. | -| `recently [time-spec]` | Show plugins that changed recently, argument is e.g. 1 month 2 days. | -| `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 plugin load times and loading moments | -| `loaded [keyword], list [keyword]` | Show what plugins are loaded (filter with 'keyword'). | +| Command | Description | +| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `bindkeys` | Lists bindkeys set up by each plugin. | +| `list-plugins [keyword]` | Show what plugins are loaded (filter with 'keyword'). | +| `list-snippets` | List snippets in formatted and colorized manner. Requires `tree` program. | +| `recently [time-spec]` | Show plugins that changed recently, argument is e.g. 1 month 2 days. | +| `report {plg-spec}` | Show plugin report. `--all` – do it for all plugins. | +| `status {plg-spec}` | Git status for plugin or svn status for snippet. `--all` – do it for all plugins and snippets. | +| `zstatus` | Display brief statistics for your Zinit installation. | +| `times [-a] [-m] [-s]` | Print load times for each plugin. `-s` – Times are printed in seconds. `-m` – Show plugin loading moments. `-a` - Times and loading moments are printed. | ### Compiling | Command | Description | -| :--------------------- | ------------------------------------------------------------------- | +| ---------------------- | ------------------------------------------------------------------- | | `compiled` | List plugins that are compiled. | | `compile {plg-spec}` | Compile plugin. `--all` – compile all plugins. | | `uncompile {plg-spec}` | Remove compiled version of plugin. `--all` – do it for all plugins. | @@ -860,7 +863,7 @@ Following commands are passed to `zinit ...` to obtain described effects. ### Other | Command | Description | -| :--------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `module` | Manage binary Zsh module shipped with Zinit, see `zinit module help`. | | `self-update` | Updates and compiles Zinit. | | `cd {plg-spec}` | Cd into plugin's directory. Also support snippets if fed with URL. | @@ -1040,6 +1043,7 @@ declare -A ZINIT # initial Zinit's hash definition, if configuring before loadi | ZINIT\[COMPINIT_OPTS\] | Options for `compinit` call (i.e. done by `zicompinit`), use to pass -C to speed up loading | | ZINIT\[MUTE_WARNINGS\] | If set to `1`, then mutes some of the Zinit warnings, specifically the `plugin already registered` warning | | ZINIT\[OPTIMIZE_OUT_DISK_ACCESSES\] | If set to `1`, then Zinit will skip checking if a Turbo-loaded object exists on the disk. By default Zinit skips Turbo for non-existing objects (plugins or snippets) to install them before the first prompt – without any delays, during the normal processing of `zshrc`. This option can give a performance gain of about 10 ms out of 150 ms (i.e.: Zsh will start up in 140 ms instead of 150 ms). | +| ZINIT\[NO_ALIASES\] | If set to `1`, then Zinit will not set aliases such as `zi` or `zini` | There is also `$ZPFX`, set by default to `~/.local/share/zinit/polaris` – a directory where software with `Makefile`, etc. can be pointed to, by e.g. `atclone'./configure --prefix=$ZPFX'`. diff --git a/VERSION b/VERSION index a5c4c7633..30291cba2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.9.0 +3.10.0 diff --git a/_zinit b/_zinit index ef70aaa08..dc60f433c 100644 --- a/_zinit +++ b/_zinit @@ -1,344 +1,376 @@ #compdef zinit +#autoload +# +# Zinit ZSH completion function +# Copyright (c) 2016-2020 Sebastian Gniazdowski +# Copyright (c) 2016-2023 zdharma-continuum +# Homepage: https://github.com/zdharma-continuum/zinit +# License: MIT License +# -setopt localoptions warncreateglobal typesetsilent +# FUNCTION: __zinit_commands [[[ +__zinit_commands(){ + local -a commands + commands=( + 'add-fpath:Add plugin folder to $FPATH' + 'bindkeys:List of plugin defined key bindings' + 'cclear:Clear completions list' + 'cd:Go to a plugin or snippet direcorty' + 'cdclear:Clear the compdef replay list' + 'cdisable:Disable completions' + 'cdreplay:Replay compdef list' + 'cenable:Enable completions' + 'changes:View plugins git log' + 'clist:List status of all installed completions' + 'compile:Compile plugin (or all plugins if --all passed)' + 'compiled:List of compiled plugins' + 'compinit:Refresh installed completions' + 'completions:List status of all installed completions' + 'create:Create plugin (also together with Github repository)' + 'creinstall:Install completions for plugin' + 'csearch:Search for available completions from any plugin' + 'cuninstall:Uninstall completions for plugin' + 'dclear:Clear report of what was going on in session' + 'delete:Uninstall a plugin or snippet' + 'dreport:Report what was going on in session' + 'dstart:Start tracking whats going on in session' + 'dstop:Stop tracking whats going on in session' + 'dtrace:Start tracking whats going on in session' + 'dunload:Revert changes recorded between dstart and dstop' + 'edit:Edit a plugins or snippet with \$EDITOR' + 'env-whitelist:Specify names (also patterns) of parameters to be left unchanged during an unload' + 'glance:Look at plugins source' + 'help:Usage information' + 'load:Load plugin' + 'man:Display Zinit'\''s manpage' + 'module:Manage binary Zsh module shipped with Zinit' + 'plugins:List status of all installed plugins' + 'recall:Fetch saved ice modifiers and construct ' + 'recently:Show plugins that changed recently' + 'report:Show plugins report' + 'run:Run a command inside plugins folder' + 'self-update:Fetch the newest version of Zinit from GitHub using `git`(1) and recompile' + 'snippet:Source a local or remote file' + 'snippets:List status of all installed snippets' + 'srv:Control a service, command' + 'status:Git status for plugin' + 'stress:Test plugin for compatibility with set of options' + 'times:Display brief statistics for your Zinit installation' + 'uncompile:Remove compiled plugin' + 'uninstall:Uninstall a formula or cask' + 'unload:Unload a plugin or snippet' + 'update:Upgrade outdated plugins and snippets using the same options they were originally installed with' + 'version:Print the version numbers of Zinit to standard output' + 'zstatus:Overall Zinit status' + ) + _describe -t commands 'zinit commands' commands +} # ]]] +# FUNCTION: __zinit_completion_caching_policy [[[ +__zinit_completion_caching_policy(){ + local -a tmp + (( $#tmp )) || return 0 + tmp=( $ZINIT[BIN_DIR]/*.git/index(om[1]N) ) + [[ -z $tmp || $tmp -nt $1 ]] +} # ]]] +# FUNCTION: __zinit_installed [[[ +__zinit_installed() { + _alternative \ + 'plugins:installed:__zinit_installed_plugins' \ + 'snippets:installed:__zinit_installed_snippets' +} # ]]] +# FUNCTION: __zinit_installed_plugins [[[ +__zinit_installed_plugins(){ + # [[ -prefix '-' ]] && return 0 + typeset -a list + local expl + list=( "${ZINIT[PLUGINS_DIR]}"/*(N:t) ) + list=( "${list[@]//---//}" ) + list=( "${list[@]:#_local/zinit}" ) + list=( "${list[@]:#custom}" ) + _wanted list expl 'plugins' compadd -a - list +} # ]]] +# FUNCTION: __zinit_installed_snippets [[[ +__zinit_installed_snippets(){ + # [[ -prefix '-' ]] && return 0 + typeset -a snippets + local expl snippet + snippets=( "${ZINIT[SNIPPETS_DIR]}"/**/._zinit(D/:h) ) + snippets=( ${(Q)snippets[@]#${ZINIT[SNIPPETS_DIR]}/} ) + # formulae=( ${(qq)formulae[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} ) + # formulae=( ${formulae[@]/--//} ) + # + _wanted snippets expl 'snippets' compadd -a - snippets +} # ]]] +# FUNCTION: __zinit_list_aliases [[[ +__zinit_list_aliases(){ + local -a aliases + aliases=( ls list uninstall delete ) + echo "${aliases}" +} # ]]] -local curcontext="$curcontext" state state_descr line ret=1 -local -a expl - -typeset -a commands -commands=( - zstatus:'overall Zinit status' - times:'statistics on plugin loading times' - self-update:'updates Zinit' - help:'usage information' - man:'manual' - env-whitelist:'specify names (also patterns) of parameters to be left unchanged during an unload' - load:'load plugin' - delete:'delete plugin' - unload:'unload plugin' - snippet:"source (or add to PATH with --command) local or remote file (-f: force - don't use cache)" - update:'Git update plugin (or all plugins and snippets if --all passed)' - status:'Git status for plugin (or all plugins if --all passed)' - report:'show plugin'"'"'s report (or all plugins'"'"' if --all passed)' - loaded:'show what plugins are loaded' - list:'show what plugins are loaded' - ls:'list snippets in formatted and colorized manner' - cd:"go into plugin's directory" - create:'create plugin (also together with Github repository)' - edit:"edit plugin's file with \$EDITOR" - glance:"look at plugin's source (pygmentize, {,source-}highlight)" - stress:'test plugin for compatibility with set of options' - changes:"view plugin's git log" - recently:"show plugins that changed recently, argument is e.g. 1 month 2 days" - clist:'list completions in use' - cclear:'clear stray and improper completions' - completions:'list completions in use' - cdisable:'disable completion' - cenable:'enable completion' - creinstall:'install completions for plugin' - cuninstall:'uninstall completions for plugin' - csearch:'search for available completions from any plugin' - compinit:'refresh installed completions' - dtrace:"start tracking what's going on in session" - dstart:"start tracking what's going on in session" - dstop:"stop tracking what's going on in session" - dunload:'revert changes recorded between dstart and dstop' - dreport:"report what was going on in session" - dclear:'clear report of what was going on in session' - version:'display zinit version' - compile:'compile plugin (or all plugins if --all passed)' - uncompile:'remove compiled version of plugin (or of all plugins if --all passed)' - compiled:'show which plugins are compiled' - cdlist:'show compdef replay list' - cdreplay:'replay compdefs (to be done after compinit)' - cdclear:'clear compdef replay list' - srv:'control a service, command can be: stop,start,restart,next,quit; `next'' moves the service to another Zshell' - recall:'fetch saved ice modifiers and construct `zinit ice ...'' command' - env-whitelist:'allows to specify names (also patterns) of variables left unchanged during an unload. -v - verbose' - bindkeys:'lists bindkeys set up by each plugin' - module:'manage binary Zsh module shipped with Zinit, see `zinit module help''' - run:"execute code inside plugin's folder" - {add-fpath,fpath}:'add plugin folder to $fpath' -) - -_arguments -C \ - '1: :->command'\ - '*: :->argument' \ +# FUNCTION: _zinit_add_fpath [[[ +_zinit_add_fpath(){ + _arguments -A \ + '(-h --help)'{-h,--help}'[Show this help message]' && ret=0 +} # ]]] +# FUNCTION: _zinit_bindkeys [[[ +_zinit_bindkeys(){ + _message 'Hit enter to list the defined key bindings replay' && ret=0 +} # ]]] +# FUNCTION: _zinit_cclear [[[ +_zinit_cclear(){ + _arguments -A \ + '(-h --help)'{-h,--help}'[Show this help message]' \ + '(-q --quiet)'{-q,--quiet}'[Turn off messages from the operation]' \ + && ret=0 +} # ]]] +# FUNCTION: _zinit_cd [[[ +_zinit_cd(){ + _arguments - plugin '1::plugin:__zinit_installed_plugins' && ret=0 +} # ]]] +# FUNCTION: _zinit_cdclear [[[ +_zinit_cdclear(){ + _arguments -A \ + '(-h --help)'{-h,--help}'[Show this help message]' \ + '(-q --quiet)'{-q,--quiet}'[Turn off messages from the operation]' \ + && ret=0 +} # ]]] +# FUNCTION: _zinit_cdisable [[[ +_zinit_cdisable(){ + _message 'Press enter to disable completions' && ret=0 +} # ]]] +# FUNCTION: _zinit_cdlist [[[ +_zinit_cdlist(){ + _message 'List of compdef replays' && ret=0 +} # ]]] +# FUNCTION: _zinit_cdreplay [[[ +_zinit_cdreplay(){ + _arguments -A \ + '(-h --help)'{-h,--help}'[Show this help message]' \ + '(-q --quiet)'{-q,--quiet}'[Turn off messages from the operation]' \ + && ret=0 +} # ]]] +# FUNCTION: _zinit_cenable [[[ +_zinit_cenable(){ + _message 'Hit enter to enable completions' && ret=0 +} # ]]] +# FUNCTION: _zinit_changes [[[ +_zinit_changes(){ + _message 'View git log of a plugin' && ret=0 +} # ]]] +# FUNCTION: _zinit_clist [[[ +_zinit_clist(){ + _message 'Hit enter to get list of completions' && ret=0 +} # ]]] +# FUNCTION: _zinit_compiled [[[ +_zinit_compiled(){ + _message 'Hit enter to get list of compiled plugins and snippets' +} # ]]] +# FUNCTION: _zinit_compinit [[[ +_zinit_compinit(){ + _message "Refresh completions" && ret=0 +} # ]]] +# FUNCTION: _zinit_completions [[[ +_zinit_completions(){ + _message "Display a list of completions" && ret=0 +} # ]]] +# FUNCTION: _zinit_create [[[ +_zinit_compile(){ + _arguments \ + + '(operation)' \ + '1:installed:__zinit_installed' \ + {-a,--all}'[Compile all plugins]' +} # ]]] +# FUNCTION: _zinit_create [[[ +_zinit_create(){ + _arguments \ + '1:name:[Name of plugin]' && ret=0 +} # ]]] +# FUNCTION: _zinit_creinstall [[[ +_zinit_creinstall(){ + _arguments - plugin '1::plugin:__zinit_installed_plugins' && ret=0 +} # ]]] +# FUNCTION: _zinit_csearch [[[ +_zinit_csearch(){ + ret=0 +} # ]]] +# FUNCTION: _zinit_cunistall [[[ +_zinit_cunistall(){ + _arguments - installed '*::installed:__zinit_installed' && ret=0 +} # ]]] +# FUNCTION: _zinit_dclear [[[ +_zinit_dclear(){ + ret=0 +} # ]]] +# FUNCTION: _zinit_delete [[[ +_zinit_delete(){ + _arguments \ + '--help[Show this help message]' \ + '--quiet[Turn off messages from the operation]' \ + '--yes[Automatically confirm any yes/no prompts]' \ + + '(operation)' \ + '*::installed:__zinit_installed' \ + {-a,--all}'[Delete all plugins and snippets]' \ + {-c,--clean}'[Delete only the currently-not loaded plugins and snippets]' +} # ]]] +# FUNCTION: _zinit_dreport [[[ +_zinit_dreport(){ + ret=0 +} # ]]] +# FUNCTION: _zinit_dstart [[[ +_zinit_dstart(){ + ret=0 +} # ]]] +# FUNCTION: _zinit_dstop [[[ +_zinit_dstop(){ + ret=0 +} # ]]] +# FUNCTION: _zinit_dtrace [[[ +_zinit_dtrace(){ + ret=0 +} # ]]] +# FUNCTION: _zinit_dunload [[[ +_zinit_dunload(){ + ret=0 +} # ]]] +# FUNCTION: _zinit_edit [[[ +_zinit_edit(){ + _arguments \ + - installed '*::plugin:__zinit_installed_plugins' \ + - snippet '*::snippet:__zinit_installed_snippets' && ret=0 +} # ]]] +# FUNCTION: _zinit_env_whitelist [[[ +_zinit_env_whitelist(){ + _arguments -A \ + '(-h --help)'{-h,--help}'[Show this help message]' \ + '(-v --verbose)'{-v,--verbose}'[Make some output more verbose]' \ + && ret=0 +} # ]]] +# FUNCTION: _zinit_glance [[[ +_zinit_glance(){ + _arguments - installed '1:installed:__zinit_installed' && ret=0 +} # ]]] +# FUNCTION: _zinit_list [[[ +_zinit_list(){ + _message 'Hit enter to list the defined key bindings replay' && ret=0 +} # ]]] +# FUNCTION: _zinit_loaded [[[ +_zinit_loaded(){ + _message 'Hit enter to list the defined key bindings replay' && ret=0 +} # ]]] +# FUNCTION: _zinit_man [[[ +_zinit_man(){ + _message "Hit enter to view the Zinit man page" && ret=0 +} # ]]] +# FUNCTION: _zinit_module [[[ +_zinit_module(){ + _arguments \ + - subcommand '*::subcommand:(build help info)' && ret=0 +} # ]]] +# FUNCTION: _zinit_recall [[[ +_zinit_recall(){ + _message 'Hit enter to list the defined key bindings replay' && ret=0 +} # ]]] +# FUNCTION: _zinit_recently [[[ +_zinit_recently(){ + ret=0 +} # ]]] +# FUNCTION: _zinit_report [[[ +_zinit_report(){ + _message 'Hit enter to list the defined key bindings replay' && ret=0 +} # ]]] +# FUNCTION: _zinit_run [[[ +_zinit_run(){ + _arguments \ + - installed '1:installed:__zinit_installed' \ + '2:command to run:' && ret=0 +} # ]]] +# FUNCTION: _zinit_self_update [[[ +_zinit_self_update(){ +} # ]]] +# FUNCTION: _zinit_snippet [[[ +_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]' + _arguments - snippet '*::snippet:__zinit_installed_snippets' && ret=0 +} # ]]] +# FUNCTION: _zinit_status [[[ +_zinit_status(){ + _message 'Display current status of Zinit' && ret=0 +} # ]]] +# FUNCTION: _zinit_stress [[[ +_zinit_stress(){ + _message 'Stress' && ret=0 +} # ]]] +# FUNCTION: _zinit_times [[[ +_zinit_times(){ + _arguments \ + '--help[Show this help message]' \ + + '(operation)' \ + '(-a --all)'{-a,--all}'[show both load times and loading moments]' \ + '(-m --moments)'{-m,--moments}'[Display loading moments]' \ + '(-s --seconds)'{-s,--seconds}'[Load times displayed in seconds]' \ && ret=0 +} # ]]] +# FUNCTION: _zinit_uncompile [[[ +_zinit_uncompile(){ + _arguments -A \ + '(-a --all)'{-a,--all}'[Delete all plugins and snippets]' + _arguments - installed '*::installed:__zinit_installed' && ret=0 + # - plugin '1:plugin:__zinit_installed_plugins' +} # ]]] +# FUNCTION: _zinit_unload [[[ +_zinit_unload(){ + _arguments -A \ + '(-h --help)'{-h,--help}'[Show this help message]' \ + '(-q --quiet)'{-q,--quiet}'[Turn off messages from the operation]' \ + - installed '*:installed:__zinit_installed' +} # ]]] +# FUNCTION: _zinit_update [[[ +_zinit_update(){ + _arguments \ + '--help[Show this help message]' \ + '--no-pager[Don'\''t automatically install dependencies]' \ + '--quiet[Turn off messages from the operation]' \ + '--reset[Reset repository or delete downloadremove single-file snippets and gh-r plugins)]' \ + '--urge[Cause all the hooks like: atpull'', cp'', etc. to execute even when there aren'\''t any new commits / any new version of the gh-r file / etc.… available for download↔ simulate a non-empty update]' \ + - set1 \ + '--parallel[Turn on concurrent, multi-thread update (of all objects)]' \ + '(-a --all)'{-a,--all}'[Update all plugins and snippets]' \ + - set2 \ + '1:installed:__zinit_installed' +} # ]]] +# FUNCTION: _zunit_load [[[ +_zinit_load() { + _message 'Hit enter to list the defined key bindings replay' && ret=0 +} # ]]] -case $state in - command) - _describe -t commands "Zinit command" commands && ret=0 - ;; - argument) - case $words[2] in - help) - _message "Hit enter to get usage information" && ret=0 - ;; - version) - _message "display zinit version" && ret=0 - ;; - man) - _message "Hit enter to view manual" && ret=0 - ;; - zstatus) - _message "Hit enter to get overall status information" && ret=0 - ;; - times) - _message "Hit enter to get plugin load time statistics" && ret=0 - ;; - load|light) - typeset -a plugins - plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N:t) ) - plugins=( "${plugins[@]//---//}" ) - plugins=( "${plugins[@]:#_local/zinit}" ) - plugins=( "${plugins[@]:#custom}" ) - - _alternative \ - 'plugins:-- Plugin --:compadd -a - plugins' \ - 'directories:-- Directory --:_directories' \ - && ret=0 - ;; - run|fpath|add-fpath) - typeset -a plugins - plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N:t) ) - plugins=( "${plugins[@]//---//}" ) - plugins=( "${plugins[@]:#_local/zinit}" ) - plugins=( "${plugins[@]:#custom}" ) - - local -a opts - if [[ $words[2] = run ]]; then - opts=( -l ) - else - opts=( -f --front ) - fi - - _alternative \ - 'plugins:-- Plugin --:compadd -a - plugins' \ - 'directories:-- Directory --:_directories' \ - 'opts:-- Option --:compadd -a - opts' \ - && ret=0 - ;; - compile|stress|edit|glance|recall|update|status|cd|changes|delete) - typeset -a plugins - plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N:t) ) - plugins=( "${plugins[@]//---//}" ) - plugins=( "${plugins[@]:#_local/zinit}" ) - plugins=( "${plugins[@]:#custom}" ) - - # snippets - local -a snippets snippets_alreadyld - local sni - - snippets=( "${ZINIT[SNIPPETS_DIR]}"/**/._zinit(D/:h) ) - snippets=( ${snippets[@]#${ZINIT[SNIPPETS_DIR]}/} ) - snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} ) - snippets=( ${snippets[@]/--//} ) - - for sni ( ${snippets[@]} ) { - if [[ -n ${ZINIT_SNIPPETS[$sni]} ]]; then - snippets_alreadyld+=( $sni ) - snippets=( ${snippets[@]:#$sni} ) - fi - } - - _alternative \ - 'dsnippets:-- Downloaded Snippet --:compadd -a - snippets' \ - 'lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' \ - 'plugins:-- Plugin --:compadd -a - plugins' \ - && ret=0 - ;; - unload|report) - typeset -a plugins absolute normal - plugins=( "${ZINIT_REGISTERED_PLUGINS[@]:#_local/zinit}" ) - normal=( "${plugins[@]:#%*}" ) - absolute=( "${(M)plugins[@]:#%*}" ) - absolute=( "${absolute[@]/\%\/\//%/}" ) - local hm="${HOME%/}" - absolute=( "${absolute[@]/$hm/HOME}" ) - plugins=( $normal $absolute ) - - _wanted plugins expl "-- Plugin --" \ - compadd "$@" -a - plugins \ - && ret=0 - ;; - all-reports) - _message "Hit enter to get all reports (for all loaded plugins)" && ret=0 - ;; - loaded|list) - _message "Hit enter or give part of plugin name" && ret=0 - ;; - clist|completions) - _message "Hit enter to get list of completions" && ret=0 - ;; - cclear) - _message "Hit enter to clear stray and improper completions" && ret=0 - ;; - cdisable) # Find enabled completions - typeset -a completions - completions=( "${ZINIT[COMPLETIONS_DIR]}"/_*(N:t) ) - completions=( "${completions[@]#_}" ) - _wanted plugins expl "-- Completion --" \ - compadd "$@" -a - completions \ - && ret=0 - ;; - cenable) # find disabled completions - typeset -a completions - completions=( "${ZINIT[COMPLETIONS_DIR]}"/[^_]*(N:t) ) - _wanted plugins expl "-- Completion --" \ - compadd "$@" -a - completions \ - && ret=0 - ;; - creinstall) - # complete only plugins that have any completions - # iterate each plugin to check for completions that can be installed - typeset -a plugins completions - local p c user plugin - for p in "${ZINIT[PLUGINS_DIR]}"/*; do - completions=( "$p"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|_zsh_highlight*|/zsdoc/*)(DN) ) - for c in "${completions[@]}"; do - p="${p:t}" - user="${p%%---*}" - plugin="${p#*---}" - [[ "$user" = "$plugin" && "${user}---${plugin}" != "$p" ]] && user="" - plugins+=( "${user:+$user/}$plugin" ) - break - done - done - _wanted plugins expl "-- Plugin --" \ - compadd "$@" -a - plugins \ - && ret=0 - ;; - cuninstall) - # iterate each plugin and check if it has completions that are installed - typeset -a plugins completions - local p c user plugin cfile bkpfile - for p in "${ZINIT[PLUGINS_DIR]}"/*; do - completions=( "$p"/**/_[^_.][^.]#(N) ) - for c in "${completions[@]}"; do - cfile="${c:t}" - bkpfile="${cfile#_}" - # completion installed, either enabled or disabled? - if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZINIT[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then - p="${p:t}" - user="${p%%---*}" - plugin="${p#*---}" - [[ "$user" = "$plugin" && "${user}---${plugin}" != "$p" ]] && user="" - plugins+=( "${user:+$user/}$plugin" ) - break - fi - done - done - _wanted plugins expl "-- Plugin --" \ - compadd "$@" -a - plugins \ - && ret=0 - ;; - compinit) - _message "Hit enter to refresh completion system" && ret=0 - ;; - snippet) - local -a snippets snippets_alreadyld - local sni - - snippets=( "${ZINIT[SNIPPETS_DIR]}"/**/._zinit(D/:h) ) - snippets=( ${snippets[@]#${ZINIT[SNIPPETS_DIR]}/} ) - snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} ) - snippets=( ${snippets[@]/--//} ) - - for sni ( ${snippets[@]} ) { - if [[ -n ${ZINIT_SNIPPETS[$sni]} ]]; then - snippets_alreadyld+=( $sni ) - snippets=( ${snippets[@]:#$sni} ) - fi - } - - _alternative \ - 'dsnippets:-- Downloaded Snippet --:compadd -a - snippets' \ - 'lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' \ - 'files:-- File --:_files' \ - && ret=0 - ;; - dstart|dtrace) - _message "Hit enter to start tracking this session" && ret=0 - ;; - dstop) - _message "Hit enter to stop tracking this session" && ret=0 - ;; - dunload) - _message "Hit enter to revert changes recorded between dstart and dstop" && ret=0 - ;; - dreport) - _message "Hit enter to show report of what was going on in session" && ret=0 - ;; - dclear) - _message "Hit enter to clear report of what was going on in session" && ret=0 - ;; - compile-all) - _message 'Hit enter to compile all downloaded plugins' && ret=0 - ;; - uncompile) - typeset -a plugins - plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N) ) - - typeset -a show_plugins p matches - for p in "${plugins[@]}"; do - matches=( $p/*.zwc(N) ) - if [ "$#matches" -ne "0" ]; then - p="${p:t}" - [ "$p" = "_local---zinit" ] && continue - [ "$p" = "custom" ] && continue - p="${p//---//}" - show_plugins+=( "$p" ) - fi - done - - _wanted show_plugins expl "-- Plugin --" \ - compadd "$@" -a - show_plugins \ - && ret=0 - ;; - uncompile-all) - _message 'Hit enter remove compiled versions of all downloaded plugins' && ret=0 - ;; - compiled) - _message 'Hit enter to get list of compiled plugins' && ret=0 - ;; - cdlist) - _message 'Hit enter to show compdef replay list' && ret=0 - ;; - cdreplay) - _message 'Hit enter to replay recorded compdefs' && ret=0 - ;; - cdclear) - _message 'Hit enter to clear compdef replay list' && ret=0 - ;; - recently) - typeset -a timespecs - timespecs=( - "1 month":"code modified during last month" - "1 week":"code modified during last 7 days (default)" - "3 days":"code modified during last 3 days" - ) - _describe -t timespecs "Time spec" timespecs && ret=0 - ;; - create) - _message 'Plugin spec or just enter, to create new plugin' && ret=0 - ;; - env-whitelist) - _wanted plugins expl "-- Parameter To White List During Any Plugin Unload --" _parameters \ - && ret=0 - ;; - *) - ret=1 - ;; - esac -esac +# FUNCTION: _zinit [[[ +_zinit(){ + local curcontext="$curcontext" state state_descr line expl + local tmp ret=1 + _arguments -A \ + '(-h --help)'{-h,--help}'[Show this help message]' + _arguments -C \ + "1: :->cmds" \ + "*::arg:->args" + case "$state" in + cmds) + __zinit_commands && return 0 + ;; + args) + local cmd="${line[1]}" + curcontext="${curcontext%:*}-${cmd}:${curcontext##*:}" + local completion_func="_zinit_${cmd//-/_}" + _call_function ret "${completion_func}" && return ret + _message "a completion function is not defined for command or alias: ${cmd}" + return 1 + ;; + esac +} # ]]] -return $ret +_zinit "$@" -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et +#vim: filetype=zsh foldmarker=[[[,]]] foldmethod=marker shiftwidth=2 softtabstop=2 tabstop=2: diff --git a/doc/zinit.1 b/doc/zinit.1 index 56de38df6..cf0147b27 100644 --- a/doc/zinit.1 +++ b/doc/zinit.1 @@ -1674,6 +1674,11 @@ delays, during the normal processing of \f[C]zshrc\f[R]. This option can give a performance gain of about 10 ms out of 150 ms (i.e.: Zsh will start up in 140 ms instead of 150 ms). T} +T{ +ZINIT[NO_ALIASES] +T}@T{ +If set to \f[C]1\f[R], then Zinit will not set aliases such as \f[C]zi\f[R] or \f[C]zini\f[R] +T} .TE .PP There is also \f[C]$ZPFX\f[R], set by default to diff --git a/doc/zsdoc/_zinit.adoc b/doc/zsdoc/_zinit.adoc new file mode 100644 index 000000000..68b2eb42d --- /dev/null +++ b/doc/zsdoc/_zinit.adoc @@ -0,0 +1,451 @@ +_zinit(1) +========= +:compat-mode!: + +NAME +---- +_zinit - a shell script + +SYNOPSIS +-------- +Documentation automatically generated with `zshelldoc' + +FUNCTIONS +--------- + + __zinit_commands + __zinit_completion_caching_policy + __zinit_installed + __zinit_installed_plugins + __zinit_installed_snippets + __zinit_list_aliases + _zinit + _zinit_add_fpath + _zinit_bindkeys + _zinit_cclear + _zinit_cd + _zinit_cdclear + _zinit_cdisable + _zinit_cdlist + _zinit_cdreplay + _zinit_cenable + _zinit_changes + _zinit_clist + _zinit_compile + _zinit_compiled + _zinit_compinit + _zinit_completions + _zinit_create + _zinit_creinstall + _zinit_csearch + _zinit_cunistall + _zinit_dclear + _zinit_delete + _zinit_dreport + _zinit_dstart + _zinit_dstop + _zinit_dtrace + _zinit_dunload + _zinit_edit + _zinit_env_whitelist + _zinit_glance + _zinit_list + _zinit_load + _zinit_loaded + _zinit_man + _zinit_module + _zinit_recall + _zinit_recently + _zinit_report + _zinit_run + _zinit_snippet + _zinit_status + _zinit_stress + _zinit_times + _zinit_uncompile + _zinit_unload + _zinit_update + +DETAILS +------- + +Script Body +~~~~~~~~~~~ + +Has 3 line(s). Calls functions: + + Script-Body + `-- _zinit + `-- __zinit_commands + +__zinit_commands +~~~~~~~~~~~~~~~~ + +Has 55 line(s). Doesn't call other functions. + +Called by: + + _zinit + +__zinit_completion_caching_policy +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Has 4 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +__zinit_installed +~~~~~~~~~~~~~~~~~ + +Has 3 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +__zinit_installed_plugins +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Has 8 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +__zinit_installed_snippets +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Has 6 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +__zinit_list_aliases +~~~~~~~~~~~~~~~~~~~~ + +Has 3 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit +~~~~~~ + +Has 23 line(s). Calls functions: + + _zinit + `-- __zinit_commands + +Called by: + + Script-Body + +_zinit_add_fpath +~~~~~~~~~~~~~~~~ + +Has 2 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_bindkeys +~~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_cclear +~~~~~~~~~~~~~ + +Has 4 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_cd +~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_cdclear +~~~~~~~~~~~~~~ + +Has 4 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_cdisable +~~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_cdlist +~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_cdreplay +~~~~~~~~~~~~~~~ + +Has 4 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_cenable +~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_changes +~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_clist +~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_compile +~~~~~~~~~~~~~~ + +Has 3 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_compiled +~~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_compinit +~~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_completions +~~~~~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_create +~~~~~~~~~~~~~ + +Has 2 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_creinstall +~~~~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_csearch +~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_cunistall +~~~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_dclear +~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_delete +~~~~~~~~~~~~~ + +Has 8 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_dreport +~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_dstart +~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_dstop +~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_dtrace +~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_dunload +~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_edit +~~~~~~~~~~~ + +Has 3 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_env_whitelist +~~~~~~~~~~~~~~~~~~~~ + +Has 4 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_glance +~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_list +~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_load +~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_loaded +~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_man +~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_module +~~~~~~~~~~~~~ + +Has 2 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_recall +~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_recently +~~~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_report +~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_run +~~~~~~~~~~ + +Has 3 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_snippet +~~~~~~~~~~~~~~ + +Has 5 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_status +~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_stress +~~~~~~~~~~~~~ + +Has 1 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_times +~~~~~~~~~~~~ + +Has 6 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_uncompile +~~~~~~~~~~~~~~~~ + +Has 3 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_unload +~~~~~~~~~~~~~ + +Has 4 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + +_zinit_update +~~~~~~~~~~~~~ + +Has 10 line(s). Doesn't call other functions. + +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). + diff --git a/doc/zsdoc/zinit-additional.zsh.adoc b/doc/zsdoc/zinit-additional.zsh.adoc index 6c19c6bff..7c81f5346 100644 --- a/doc/zsdoc/zinit-additional.zsh.adoc +++ b/doc/zsdoc/zinit-additional.zsh.adoc @@ -1,18 +1,11 @@ -zinit-additional.zsh(1) -======================= -:compat-mode!: NAME ----- + zinit-additional.zsh - a shell script -SYNOPSIS --------- Documentation automatically generated with `zshelldoc' -FUNCTIONS ---------- - +== FUNCTIONS .zinit-clear-debug-report .zinit-debug-start .zinit-debug-stop @@ -21,20 +14,18 @@ FUNCTIONS .zinit-wrap-track-functions :zinit-tmp-subst-source -DETAILS -------- +=== DETAILS -Script Body -~~~~~~~~~~~ +==== Script Body Has 1 line(s). No functions are called (may set up e.g. a hook, a Zle widget bound to a key, etc.). -.zinit-clear-debug-report -~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-clear-debug-report ____ Forgets dtrace repport gathered up to this moment. + ____ Has 1 line(s). Calls functions: @@ -47,12 +38,12 @@ Called by: zinit-autoload.zsh/.zinit-unload zinit.zsh/zinit -.zinit-debug-start -~~~~~~~~~~~~~~~~~~ +==== .zinit-debug-start ____ Starts Dtrace, i.e. session tracking for changes in Zsh state. + ____ Has 9 line(s). Calls functions: @@ -66,12 +57,12 @@ Called by: zinit.zsh/zinit -.zinit-debug-stop -~~~~~~~~~~~~~~~~~ +==== .zinit-debug-stop ____ Stops Dtrace (i.e., session tracking for changes in Zsh state). + ____ Has 3 line(s). Calls functions: @@ -84,12 +75,12 @@ Called by: zinit.zsh/zinit -.zinit-debug-unload -~~~~~~~~~~~~~~~~~~~ +==== .zinit-debug-unload ____ Reverts changes detected by dtrace run. + ____ Has 6 line(s). Calls functions: @@ -104,8 +95,7 @@ Called by: zinit.zsh/zinit -.zinit-service -~~~~~~~~~~~~~~ +==== .zinit-service ____ @@ -114,6 +104,7 @@ ____ $1 - type "p" or "s" (plugin or snippet) $2 - mode - for plugin (light or load) $3 - id - URL or plugin ID or alias name (from id-as'') + ____ Has 37 line(s). Calls functions: @@ -126,8 +117,7 @@ Uses feature(s): _kill_, _read_, _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-wrap-track-functions -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-wrap-track-functions Has 19 line(s). Doesn't call other functions. @@ -135,8 +125,7 @@ Uses feature(s): _eval_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -:zinit-tmp-subst-source -~~~~~~~~~~~~~~~~~~~~~~~ +==== :zinit-tmp-subst-source Has 25 line(s). Calls functions: diff --git a/doc/zsdoc/zinit-autoload.zsh.adoc b/doc/zsdoc/zinit-autoload.zsh.adoc index 7dab4c446..77b57cdf4 100644 --- a/doc/zsdoc/zinit-autoload.zsh.adoc +++ b/doc/zsdoc/zinit-autoload.zsh.adoc @@ -1,18 +1,11 @@ -zinit-autoload.zsh(1) -===================== -:compat-mode!: NAME ----- + zinit-autoload.zsh - a shell script -SYNOPSIS --------- Documentation automatically generated with `zshelldoc' -FUNCTIONS ---------- - +== FUNCTIONS .zinit-any-to-uspl2 .zinit-at-eval .zinit-build-module @@ -48,10 +41,12 @@ FUNCTIONS .zinit-help .zinit-list-bindkeys .zinit-list-compdef-replay - .zinit-ls + .zinit-list-plugins + .zinit-list-snippets .zinit-module .zinit-pager .zinit-prepare-readlink + .zinit-prompt .zinit-recall .zinit-recently .zinit-restore-extendedglob @@ -62,7 +57,6 @@ FUNCTIONS .zinit-show-all-reports .zinit-show-completions .zinit-show-debug-report - .zinit-show-registered-plugins .zinit-show-report .zinit-show-times .zinit-show-zstatus @@ -78,18 +72,15 @@ FUNCTIONS .zinit-wait-for-update-jobs zi::version -DETAILS -------- +=== DETAILS -Script Body -~~~~~~~~~~~ +==== Script Body Has 5 line(s). No functions are called (may set up e.g. a hook, a Zle widget bound to a key, etc.). Uses feature(s): _source_ -.zinit-any-to-uspl2 -~~~~~~~~~~~~~~~~~~~ +==== .zinit-any-to-uspl2 ____ @@ -98,6 +89,7 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - (optional) plugin (only when $1 - i.e. user - given) + ____ Has 2 line(s). Calls functions: @@ -110,8 +102,7 @@ Called by: .zinit-clear-report-for .zinit-exists-message -.zinit-at-eval -~~~~~~~~~~~~~~ +==== .zinit-at-eval Has 5 line(s). Calls functions: @@ -122,18 +113,19 @@ Uses feature(s): _eval_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-build-module -~~~~~~~~~~~~~~~~~~~ +==== .zinit-build-module ____ Performs ./configure && make on the module and displays information how to load the module in .zshrc. + ____ Has 39 line(s). Calls functions: .zinit-build-module + |-- .zinit-module `-- zinit.zsh/+zinit-message Uses feature(s): _setopt_, _trap_ @@ -142,8 +134,7 @@ Called by: .zinit-module -.zinit-cd -~~~~~~~~~ +==== .zinit-cd ____ @@ -153,19 +144,21 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 15 line(s). Calls functions: .zinit-cd + |-- .zinit-get-path + |   `-- zinit.zsh/.zinit-get-object-path `-- zinit.zsh/+zinit-message Uses feature(s): _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-cdisable -~~~~~~~~~~~~~~~ +==== .zinit-cdisable ____ @@ -174,18 +167,23 @@ ____ User-action entry point. $1 - e.g. "_mkdir" or "mkdir" + ____ Has 30 line(s). Calls functions: .zinit-cdisable + |-- .zinit-check-comp-consistency + |-- .zinit-get-completion-owner-uspl2col + |   |-- .zinit-get-completion-owner + |   `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + `-- .zinit-prepare-readlink Called by: zinit.zsh/zinit -.zinit-cenable -~~~~~~~~~~~~~~ +==== .zinit-cenable ____ @@ -194,18 +192,23 @@ ____ User-action entry point. $1 - e.g. "_mkdir" or "mkdir" + ____ Has 31 line(s). Calls functions: .zinit-cenable + |-- .zinit-check-comp-consistency + |-- .zinit-get-completion-owner-uspl2col + |   |-- .zinit-get-completion-owner + |   `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + `-- .zinit-prepare-readlink Called by: zinit.zsh/zinit -.zinit-changes -~~~~~~~~~~~~~~ +==== .zinit-changes ____ @@ -215,6 +218,7 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 9 line(s). Calls functions: @@ -225,8 +229,7 @@ Has 9 line(s). Calls functions: Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-check-comp-consistency -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-check-comp-consistency ____ @@ -238,6 +241,7 @@ ____ $1 - path to completion within plugin's directory $2 - path to backup file within plugin's directory + ____ Has 11 line(s). Doesn't call other functions. @@ -247,8 +251,7 @@ Called by: .zinit-cdisable .zinit-cenable -.zinit-check-which-completions-are-enabled -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-check-which-completions-are-enabled ____ @@ -261,6 +264,7 @@ ____ - i.e. disabled $1, ... - path to completion within plugin's directory + ____ Has 11 line(s). Doesn't call other functions. @@ -269,8 +273,7 @@ Called by: .zinit-show-report -.zinit-check-which-completions-are-installed -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-check-which-completions-are-installed ____ @@ -280,6 +283,7 @@ ____ in reply. $1, ... - path to completion within plugin's directory + ____ Has 12 line(s). Doesn't call other functions. @@ -288,8 +292,7 @@ Called by: .zinit-show-report -.zinit-clear-completions -~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-clear-completions ____ @@ -299,11 +302,14 @@ ____ installed and enabled. User-action entry point. + ____ Has 37 line(s). Calls functions: .zinit-clear-completions + |-- .zinit-get-completion-owner + |-- .zinit-prepare-readlink `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 Uses feature(s): _setopt_ @@ -313,8 +319,7 @@ Called by: zinit.zsh/.zinit-prepare-home zinit.zsh/zinit -.zinit-clear-report-for -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-clear-report-for ____ @@ -323,30 +328,36 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - (optional) plugin (only when $1 - i.e. user - given) + ____ Has 23 line(s). Calls functions: .zinit-clear-report-for + `-- .zinit-any-to-uspl2 + `-- zinit.zsh/.zinit-any-to-user-plugin Called by: .zinit-unload zinit-additional.zsh/.zinit-clear-debug-report -.zinit-compile-uncompile-all -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-compile-uncompile-all ____ Compiles or uncompiles all existing (on disk) plugins. User-action entry point. + ____ Has 23 line(s). Calls functions: .zinit-compile-uncompile-all + |-- .zinit-uncompile-plugin + |   |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |   `-- zinit.zsh/.zinit-any-to-user-plugin |-- zinit-install.zsh/.zinit-compile-plugin |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 `-- zinit.zsh/.zinit-any-to-user-plugin @@ -357,14 +368,14 @@ Called by: zinit.zsh/zinit -.zinit-compiled -~~~~~~~~~~~~~~~ +==== .zinit-compiled ____ Displays list of plugins that are compiled. User-action entry point. + ____ Has 26 line(s). Calls functions: @@ -379,8 +390,7 @@ Called by: zinit.zsh/zinit -.zinit-confirm -~~~~~~~~~~~~~~ +==== .zinit-confirm ____ @@ -389,18 +399,19 @@ ____ $1 - question $2 - expression + ____ -Has 22 line(s). Doesn't call other functions. +Has 17 line(s). Calls functions: -Uses feature(s): _eval_, _read_ + .zinit-confirm + `-- zinit.zsh/+zinit-message -Called by: +Uses feature(s): _eval_, _read_ - .zinit-delete +Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-create -~~~~~~~~~~~~~ +==== .zinit-create ____ @@ -410,9 +421,10 @@ ____ $1 - (optional) plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - (optional) plugin (only when $1 - i.e. user - given) + ____ -Has 103 line(s). Calls functions: +Has 102 line(s). Calls functions: .zinit-create |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 @@ -423,33 +435,34 @@ Uses feature(s): _autoload_, _setopt_, _vared_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-delete -~~~~~~~~~~~~~ +==== .zinit-delete ____ - Deletes plugin's or snippet's directory (in Zinit's home directory). - - User-action entry point. + Deletes a plugin or snippet and related files and hooks. - $1 - snippet URL or plugin spec (4 formats: user---plugin, user/plugin, user, plugin) - $2 - plugin (only when $1 - i.e. user - given) + $1 - snippet url or plugin + ____ -Has 99 line(s). Calls functions: +Has 111 line(s). Calls functions: .zinit-delete + |-- .zinit-prompt + |-- .zinit-run-delete-hooks + |   `-- zinit-side.zsh/.zinit-countdown |-- zinit-side.zsh/.zinit-compute-ice - |-- zinit.zsh/+zinit-prehelp-usage-message + |-- zinit.zsh/+zinit-message |-- zinit.zsh/.zinit-any-to-user-plugin - `-- zinit.zsh/.zinit-parse-opts + `-- zinit.zsh/zinit -Uses feature(s): _setopt_ +Uses feature(s): _setopt_, _zmodload_, _zparseopts_ -Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). +Called by: + + zinit.zsh/zinit -.zinit-diff-env-compute -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-diff-env-compute ____ @@ -457,6 +470,7 @@ ____ added by plugin. Uses data gathered earlier by .zinit-diff-env(). $1 - user/plugin + ____ Has 30 line(s). Doesn't call other functions. @@ -468,8 +482,7 @@ Called by: .zinit-show-report .zinit-unload -.zinit-diff-functions-compute -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-diff-functions-compute ____ @@ -477,6 +490,7 @@ ____ Uses data gathered earlier by .zinit-diff-functions(). $1 - user/plugin + ____ Has 19 line(s). Doesn't call other functions. @@ -488,8 +502,7 @@ Called by: .zinit-show-report .zinit-unload -.zinit-diff-options-compute -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-diff-options-compute ____ @@ -497,6 +510,7 @@ ____ Uses data gathered earlier by .zinit-diff-options(). $1 - user/plugin + ____ Has 17 line(s). Doesn't call other functions. @@ -508,8 +522,7 @@ Called by: .zinit-show-report .zinit-unload -.zinit-diff-parameter-compute -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-diff-parameter-compute ____ @@ -518,6 +531,7 @@ ____ data gathered earlier by .zinit-diff-parameter(). $1 - user/plugin + ____ Has 28 line(s). Doesn't call other functions. @@ -529,8 +543,7 @@ Called by: .zinit-show-report .zinit-unload -.zinit-edit -~~~~~~~~~~~ +==== .zinit-edit ____ @@ -541,6 +554,7 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 22 line(s). Calls functions: @@ -550,8 +564,7 @@ Has 22 line(s). Calls functions: Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-exists-message -~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-exists-message ____ @@ -560,11 +573,14 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - (optional) plugin (only when $1 - i.e. user - given) + ____ Has 7 line(s). Calls functions: .zinit-exists-message + |-- .zinit-any-to-uspl2 + |   `-- zinit.zsh/.zinit-any-to-user-plugin `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 Called by: @@ -572,8 +588,7 @@ Called by: .zinit-show-report .zinit-unload -.zinit-find-completions-of-plugin -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-find-completions-of-plugin ____ @@ -582,6 +597,7 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 6 line(s). Calls functions: @@ -595,8 +611,7 @@ Called by: .zinit-show-report -.zinit-format-env -~~~~~~~~~~~~~~~~~ +==== .zinit-format-env ____ @@ -605,6 +620,7 @@ ____ $1 - user/plugin (i.e. uspl2 format of plugin-spec) $2 - if 1, then examine PATH, if 2, then examine FPATH + ____ Has 16 line(s). Doesn't call other functions. @@ -613,8 +629,7 @@ Called by: .zinit-show-report -.zinit-format-functions -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-format-functions ____ @@ -622,6 +637,7 @@ ____ by given plugin. $1 - user/plugin (i.e. uspl2 format of plugin-spec) + ____ Has 36 line(s). Doesn't call other functions. @@ -630,8 +646,7 @@ Called by: .zinit-show-report -.zinit-format-options -~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-format-options ____ @@ -639,18 +654,20 @@ ____ plugin "$1" was loaded. $1 - user/plugin (i.e. uspl2 format of plugin-spec) + ____ Has 21 line(s). Calls functions: .zinit-format-options + |-- .zinit-restore-extendedglob + `-- .zinit-save-set-extendedglob Called by: .zinit-show-report -.zinit-format-parameter -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-format-parameter ____ @@ -658,6 +675,7 @@ ____ changed when the given plugin was loaded. $1 - user/plugin (i.e. uspl2 format of plugin-spec) + ____ Has 35 line(s). Doesn't call other functions. @@ -668,8 +686,7 @@ Called by: .zinit-show-report -.zinit-get-completion-owner -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-get-completion-owner ____ @@ -685,6 +702,7 @@ ____ $1 - absolute path to completion file (in COMPLETIONS_DIR) $2 - readlink command (":" or "readlink") + ____ Has 22 line(s). Doesn't call other functions. @@ -697,8 +715,7 @@ Called by: .zinit-get-completion-owner-uspl2col .zinit-show-completions -.zinit-get-completion-owner-uspl2col -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-get-completion-owner-uspl2col ____ @@ -707,11 +724,13 @@ ____ $1 - absolute path to completion file (in COMPLETIONS_DIR) $2 - readlink command (":" or "readlink") + ____ Has 2 line(s). Calls functions: .zinit-get-completion-owner-uspl2col + |-- .zinit-get-completion-owner `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 Called by: @@ -719,8 +738,7 @@ Called by: .zinit-cdisable .zinit-cenable -.zinit-get-path -~~~~~~~~~~~~~~~ +==== .zinit-get-path ____ @@ -728,6 +746,7 @@ ____ (like "user/plugin" or "user" "plugin"), an absolute path ("%" "/home/..." and also "%SNIPPETS/..." etc.), or a plugin nickname (i.e. id-as'' ice-mod), or a snippet nickname. + ____ Has 8 line(s). Calls functions: @@ -742,8 +761,7 @@ Called by: .zinit-cd .zinit-uninstall-completions -.zinit-glance -~~~~~~~~~~~~~ +==== .zinit-glance ____ @@ -754,25 +772,28 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 39 line(s). Calls functions: .zinit-glance + |-- .zinit-pager |-- zinit-side.zsh/.zinit-exists-physically-message |-- zinit-side.zsh/.zinit-first + |-- zinit.zsh/+zinit-message `-- zinit.zsh/.zinit-any-to-user-plugin Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-help -~~~~~~~~~~~ +==== .zinit-help ____ Shows usage information. User-action entry point. + ____ Has 67 line(s). Doesn't call other functions. @@ -781,8 +802,7 @@ Called by: zinit.zsh/zinit -.zinit-list-bindkeys -~~~~~~~~~~~~~~~~~~~~ +==== .zinit-list-bindkeys Has 44 line(s). Calls functions: @@ -793,8 +813,7 @@ Called by: zinit.zsh/zinit -.zinit-list-compdef-replay -~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-list-compdef-replay ____ @@ -803,6 +822,7 @@ ____ already ran. Zinit solves this by recording compdefs. User-action entry point. + ____ Has 5 line(s). Doesn't call other functions. @@ -811,8 +831,26 @@ Called by: zinit.zsh/zinit -.zinit-ls -~~~~~~~~~ +==== .zinit-list-plugins + +____ + + Lists loaded plugins (subcommands list, lodaded) + +____ + +Has 21 line(s). Calls functions: + + .zinit-list-plugins + `-- zinit.zsh/+zinit-message + +Uses feature(s): _setopt_ + +Called by: + + zinit.zsh/zinit + +==== .zinit-list-snippets Has 20 line(s). Doesn't call other functions. @@ -822,19 +860,21 @@ Called by: zinit.zsh/zinit -.zinit-module -~~~~~~~~~~~~~ +==== .zinit-module ____ Function that has sub-commands passed as long-options (with two dashes, --). It's an attempt to plugin only this one function into `zinit' function defined in zinit.zsh, to not make this file longer than it's needed. + ____ Has 24 line(s). Calls functions: .zinit-module + `-- .zinit-build-module + `-- zinit.zsh/+zinit-message Called by: @@ -842,12 +882,12 @@ Called by: zinit.zsh/Script-Body zinit.zsh/zinit -.zinit-pager -~~~~~~~~~~~~ +==== .zinit-pager ____ BusyBox less lacks the -X and -i options, so it can use more + ____ Has 14 line(s). Doesn't call other functions. @@ -860,14 +900,14 @@ Called by: .zinit-self-update .zinit-update-or-status -.zinit-prepare-readlink -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-prepare-readlink ____ Prepares readlink command, used for establishing completion's owner. $REPLY = ":" or "readlink" + ____ Has 4 line(s). Doesn't call other functions. @@ -881,8 +921,27 @@ Called by: .zinit-clear-completions .zinit-show-completions -.zinit-recall -~~~~~~~~~~~~~ +==== .zinit-prompt + +____ + + Prompt user to confirm + + $1 - prompt + + $REPLY - 0 or 1 + +____ + +Has 4 line(s). Doesn't call other functions. + +Uses feature(s): _read_ + +Called by: + + .zinit-delete + +==== .zinit-recall Has 38 line(s). Calls functions: @@ -894,8 +953,7 @@ Uses feature(s): _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-recently -~~~~~~~~~~~~~~~ +==== .zinit-recently ____ @@ -904,6 +962,7 @@ ____ User-action entry point. $1 - time spec, e.g. "1 week" + ____ Has 28 line(s). Calls functions: @@ -917,12 +976,12 @@ Called by: zinit.zsh/zinit -.zinit-restore-extendedglob -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-restore-extendedglob ____ Restores extendedglob-option from state saved earlier. + ____ Has 1 line(s). Doesn't call other functions. @@ -934,8 +993,7 @@ Called by: .zinit-format-options .zinit-unload -.zinit-run-delete-hooks -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-run-delete-hooks Has 17 line(s). Calls functions: @@ -944,15 +1002,17 @@ Has 17 line(s). Calls functions: Uses feature(s): _eval_ -Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). +Called by: -.zinit-save-set-extendedglob -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + .zinit-delete + +==== .zinit-save-set-extendedglob ____ Enables extendedglob-option first saving if it was already enabled, for restoration of this state later. + ____ Has 2 line(s). Doesn't call other functions. @@ -964,8 +1024,7 @@ Called by: .zinit-format-options .zinit-unload -.zinit-search-completions -~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-search-completions ____ @@ -974,6 +1033,7 @@ ____ showing what's available in general (for installation). User-action entry point. + ____ Has 43 line(s). Calls functions: @@ -987,17 +1047,18 @@ Called by: zinit.zsh/zinit -.zinit-self-update -~~~~~~~~~~~~~~~~~~ +==== .zinit-self-update ____ Updates Zinit code (does a git pull) + ____ Has 42 line(s). Calls functions: .zinit-self-update + |-- .zinit-pager |-- zinit.zsh/+zinit-message `-- zinit.zsh/.zinit-get-mtime-into @@ -1008,26 +1069,45 @@ Called by: .zinit-update-or-status-all zinit.zsh/zinit -.zinit-show-all-reports -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-show-all-reports ____ Displays reports of all loaded plugins. User-action entry point. + ____ Has 5 line(s). Calls functions: .zinit-show-all-reports + `-- .zinit-show-report + |-- .zinit-check-which-completions-are-enabled + |-- .zinit-check-which-completions-are-installed + |-- .zinit-diff-env-compute + |-- .zinit-diff-functions-compute + |-- .zinit-diff-options-compute + |-- .zinit-diff-parameter-compute + |-- .zinit-exists-message + |   |-- .zinit-any-to-uspl2 + |   |   `-- zinit.zsh/.zinit-any-to-user-plugin + |   `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |-- .zinit-find-completions-of-plugin + |   `-- zinit.zsh/.zinit-any-to-user-plugin + |-- .zinit-format-env + |-- .zinit-format-functions + |-- .zinit-format-options + |   |-- .zinit-restore-extendedglob + |   `-- .zinit-save-set-extendedglob + |-- .zinit-format-parameter + `-- zinit.zsh/.zinit-any-to-user-plugin Called by: zinit.zsh/zinit -.zinit-show-completions -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-show-completions ____ @@ -1038,11 +1118,14 @@ ____ installed and enabled. User-action entry point. + ____ Has 72 line(s). Calls functions: .zinit-show-completions + |-- .zinit-get-completion-owner + |-- .zinit-prepare-readlink `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 Uses feature(s): _setopt_ @@ -1051,45 +1134,45 @@ Called by: zinit.zsh/zinit -.zinit-show-debug-report -~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-show-debug-report ____ Displays dtrace report (data recorded in interactive session). User-action entry point. + ____ Has 1 line(s). Calls functions: .zinit-show-debug-report + `-- .zinit-show-report + |-- .zinit-check-which-completions-are-enabled + |-- .zinit-check-which-completions-are-installed + |-- .zinit-diff-env-compute + |-- .zinit-diff-functions-compute + |-- .zinit-diff-options-compute + |-- .zinit-diff-parameter-compute + |-- .zinit-exists-message + |   |-- .zinit-any-to-uspl2 + |   |   `-- zinit.zsh/.zinit-any-to-user-plugin + |   `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |-- .zinit-find-completions-of-plugin + |   `-- zinit.zsh/.zinit-any-to-user-plugin + |-- .zinit-format-env + |-- .zinit-format-functions + |-- .zinit-format-options + |   |-- .zinit-restore-extendedglob + |   `-- .zinit-save-set-extendedglob + |-- .zinit-format-parameter + `-- zinit.zsh/.zinit-any-to-user-plugin Called by: zinit.zsh/zinit -.zinit-show-registered-plugins -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -____ - - Lists loaded plugins (subcommands list, lodaded) -____ - -Has 22 line(s). Calls functions: - - .zinit-show-registered-plugins - `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 - -Uses feature(s): _setopt_ - -Called by: - - zinit.zsh/zinit - -.zinit-show-report -~~~~~~~~~~~~~~~~~~ +==== .zinit-show-report ____ @@ -1097,11 +1180,30 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 71 line(s). Calls functions: .zinit-show-report + |-- .zinit-check-which-completions-are-enabled + |-- .zinit-check-which-completions-are-installed + |-- .zinit-diff-env-compute + |-- .zinit-diff-functions-compute + |-- .zinit-diff-options-compute + |-- .zinit-diff-parameter-compute + |-- .zinit-exists-message + |   |-- .zinit-any-to-uspl2 + |   |   `-- zinit.zsh/.zinit-any-to-user-plugin + |   `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |-- .zinit-find-completions-of-plugin + |   `-- zinit.zsh/.zinit-any-to-user-plugin + |-- .zinit-format-env + |-- .zinit-format-functions + |-- .zinit-format-options + |   |-- .zinit-restore-extendedglob + |   `-- .zinit-save-set-extendedglob + |-- .zinit-format-parameter `-- zinit.zsh/.zinit-any-to-user-plugin Uses feature(s): _setopt_ @@ -1112,14 +1214,14 @@ Called by: .zinit-show-debug-report zinit.zsh/zinit -.zinit-show-times -~~~~~~~~~~~~~~~~~ +==== .zinit-show-times ____ Shows loading times of all loaded plugins. User-action entry point. + ____ Has 65 line(s). Calls functions: @@ -1133,8 +1235,7 @@ Called by: zinit.zsh/zinit -.zinit-show-zstatus -~~~~~~~~~~~~~~~~~~~ +==== .zinit-show-zstatus ____ @@ -1142,6 +1243,7 @@ ____ of available completions, etc. User-action entry point. + ____ Has 47 line(s). Calls functions: @@ -1155,8 +1257,7 @@ Called by: zinit.zsh/zinit -.zinit-stress -~~~~~~~~~~~~~ +==== .zinit-stress ____ @@ -1170,6 +1271,7 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 38 line(s). Calls functions: @@ -1183,8 +1285,7 @@ Uses feature(s): _setopt_, _zcompile_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-uncompile-plugin -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-uncompile-plugin ____ @@ -1194,6 +1295,7 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 22 line(s). Calls functions: @@ -1209,8 +1311,7 @@ Called by: .zinit-compile-uncompile-all zinit.zsh/zinit -.zinit-uninstall-completions -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-uninstall-completions ____ @@ -1219,11 +1320,14 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 46 line(s). Calls functions: .zinit-uninstall-completions + |-- .zinit-get-path + |   `-- zinit.zsh/.zinit-get-object-path |-- zinit-install.zsh/.zinit-compinit |-- zinit-install.zsh/.zinit-forget-completion `-- zinit.zsh/+zinit-message @@ -1234,8 +1338,7 @@ Called by: zinit.zsh/zinit -.zinit-unload -~~~~~~~~~~~~~ +==== .zinit-unload ____ @@ -1253,11 +1356,27 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 386 line(s). Calls functions: .zinit-unload + |-- .zinit-clear-report-for + |   `-- .zinit-any-to-uspl2 + |   `-- zinit.zsh/.zinit-any-to-user-plugin + |-- .zinit-diff-env-compute + |-- .zinit-diff-functions-compute + |-- .zinit-diff-options-compute + |-- .zinit-diff-parameter-compute + |-- .zinit-exists-message + |   |-- .zinit-any-to-uspl2 + |   |   `-- zinit.zsh/.zinit-any-to-user-plugin + |   `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |-- .zinit-restore-extendedglob + |-- .zinit-save-set-extendedglob + |-- .zinit-unregister-plugin + |   `-- zinit.zsh/.zinit-any-to-user-plugin |-- zinit-additional.zsh/.zinit-clear-debug-report |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 `-- zinit.zsh/.zinit-any-to-user-plugin @@ -1270,13 +1389,13 @@ Called by: zinit.zsh/.zinit-run-task zinit.zsh/zinit -.zinit-unregister-plugin -~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-unregister-plugin ____ Removes the plugin from ZINIT_REGISTERED_PLUGINS array and from the zsh_loaded_plugins array (managed according to the plugin standard) + ____ Has 6 line(s). Calls functions: @@ -1288,12 +1407,32 @@ Called by: .zinit-unload -.zinit-update-all-parallel -~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-update-all-parallel Has 84 line(s). Calls functions: .zinit-update-all-parallel + |-- .zinit-update-or-status + |   |-- .zinit-pager + |   |-- .zinit-update-or-status-snippet + |   |   |-- zinit-install.zsh/.zinit-update-snippet + |   |   `-- zinit-side.zsh/.zinit-compute-ice + |   |-- zinit-install.zsh/.zinit-get-latest-gh-r-url-part + |   |-- zinit-install.zsh/.zinit-setup-plugin-dir + |   |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |   |-- zinit-side.zsh/.zinit-compute-ice + |   |-- zinit-side.zsh/.zinit-exists-physically + |   |-- zinit-side.zsh/.zinit-exists-physically-message + |   |-- zinit-side.zsh/.zinit-store-ices + |   |-- zinit-side.zsh/.zinit-two-paths + |   |-- zinit.zsh/+zinit-message + |   |-- zinit.zsh/.zinit-any-to-user-plugin + |   `-- zinit.zsh/.zinit-set-m-func + |-- .zinit-update-or-status-snippet + |   |-- zinit-install.zsh/.zinit-update-snippet + |   `-- zinit-side.zsh/.zinit-compute-ice + |-- .zinit-wait-for-update-jobs + |   `-- zinit.zsh/+zinit-message |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 |-- zinit.zsh/+zinit-message `-- zinit.zsh/.zinit-any-to-user-plugin @@ -1304,8 +1443,7 @@ Called by: .zinit-update-or-status-all -.zinit-update-or-status -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-update-or-status ____ @@ -1316,11 +1454,16 @@ ____ $1 - "status" for status, other for update $2 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin) $3 - plugin (only when $1 - i.e. user - given) + ____ Has 325 line(s). Calls functions: .zinit-update-or-status + |-- .zinit-pager + |-- .zinit-update-or-status-snippet + |   |-- zinit-install.zsh/.zinit-update-snippet + |   `-- zinit-side.zsh/.zinit-compute-ice |-- zinit-install.zsh/.zinit-get-latest-gh-r-url-part |-- zinit-install.zsh/.zinit-setup-plugin-dir |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 @@ -1341,8 +1484,7 @@ Called by: .zinit-update-or-status-all zinit.zsh/zinit -.zinit-update-or-status-all -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-update-or-status-all ____ @@ -1351,11 +1493,60 @@ ____ on disk). Also updates (i.e. redownloads) snippets. User-action entry point. + ____ Has 133 line(s). Calls functions: .zinit-update-or-status-all + |-- .zinit-self-update + |   |-- .zinit-pager + |   |-- zinit.zsh/+zinit-message + |   `-- zinit.zsh/.zinit-get-mtime-into + |-- .zinit-update-all-parallel + |   |-- .zinit-update-or-status + |   |   |-- .zinit-pager + |   |   |-- .zinit-update-or-status-snippet + |   |   |   |-- zinit-install.zsh/.zinit-update-snippet + |   |   |   `-- zinit-side.zsh/.zinit-compute-ice + |   |   |-- zinit-install.zsh/.zinit-get-latest-gh-r-url-part + |   |   |-- zinit-install.zsh/.zinit-setup-plugin-dir + |   |   |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |   |   |-- zinit-side.zsh/.zinit-compute-ice + |   |   |-- zinit-side.zsh/.zinit-exists-physically + |   |   |-- zinit-side.zsh/.zinit-exists-physically-message + |   |   |-- zinit-side.zsh/.zinit-store-ices + |   |   |-- zinit-side.zsh/.zinit-two-paths + |   |   |-- zinit.zsh/+zinit-message + |   |   |-- zinit.zsh/.zinit-any-to-user-plugin + |   |   `-- zinit.zsh/.zinit-set-m-func + |   |-- .zinit-update-or-status-snippet + |   |   |-- zinit-install.zsh/.zinit-update-snippet + |   |   `-- zinit-side.zsh/.zinit-compute-ice + |   |-- .zinit-wait-for-update-jobs + |   |   `-- zinit.zsh/+zinit-message + |   |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |   |-- zinit.zsh/+zinit-message + |   `-- zinit.zsh/.zinit-any-to-user-plugin + |-- .zinit-update-or-status + |   |-- .zinit-pager + |   |-- .zinit-update-or-status-snippet + |   |   |-- zinit-install.zsh/.zinit-update-snippet + |   |   `-- zinit-side.zsh/.zinit-compute-ice + |   |-- zinit-install.zsh/.zinit-get-latest-gh-r-url-part + |   |-- zinit-install.zsh/.zinit-setup-plugin-dir + |   |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |   |-- zinit-side.zsh/.zinit-compute-ice + |   |-- zinit-side.zsh/.zinit-exists-physically + |   |-- zinit-side.zsh/.zinit-exists-physically-message + |   |-- zinit-side.zsh/.zinit-store-ices + |   |-- zinit-side.zsh/.zinit-two-paths + |   |-- zinit.zsh/+zinit-message + |   |-- zinit.zsh/.zinit-any-to-user-plugin + |   `-- zinit.zsh/.zinit-set-m-func + |-- .zinit-update-or-status-snippet + |   |-- zinit-install.zsh/.zinit-update-snippet + |   `-- zinit-side.zsh/.zinit-compute-ice |-- zinit-install.zsh/.zinit-compinit |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 |-- zinit.zsh/+zinit-message @@ -1368,8 +1559,7 @@ Called by: zinit.zsh/zinit -.zinit-update-or-status-snippet -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-update-or-status-snippet ____ @@ -1378,6 +1568,7 @@ ____ $1 - "status" or "update" $2 - snippet URL + ____ Has 34 line(s). Calls functions: @@ -1394,8 +1585,7 @@ Called by: .zinit-update-or-status-all .zinit-update-or-status -.zinit-wait-for-update-jobs -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-wait-for-update-jobs Has 18 line(s). Calls functions: @@ -1408,14 +1598,14 @@ Called by: .zinit-update-all-parallel -zi::version -~~~~~~~~~~~ +==== zi::version ____ Shows usage information. User-action entry point. + ____ Has 2 line(s). Calls functions: diff --git a/doc/zsdoc/zinit-install.zsh.adoc b/doc/zsdoc/zinit-install.zsh.adoc index fd0530bd7..b6258b234 100644 --- a/doc/zsdoc/zinit-install.zsh.adoc +++ b/doc/zsdoc/zinit-install.zsh.adoc @@ -1,18 +1,11 @@ -zinit-install.zsh(1) -==================== -:compat-mode!: NAME ----- + zinit-install.zsh - a shell script -SYNOPSIS --------- Documentation automatically generated with `zshelldoc' -FUNCTIONS ---------- - +== FUNCTIONS .zi::get-architecture .zinit-at-eval .zinit-compile-plugin @@ -56,18 +49,15 @@ FUNCTIONS ∞zinit-reset-hook AUTOLOAD compinit -DETAILS -------- +=== DETAILS -Script Body -~~~~~~~~~~~ +==== Script Body Has 6 line(s). No functions are called (may set up e.g. a hook, a Zle widget bound to a key, etc.). Uses feature(s): _source_ -.zi::get-architecture -~~~~~~~~~~~~~~~~~~~~~ +==== .zi::get-architecture Has 43 line(s). Calls functions: @@ -78,8 +68,7 @@ Uses feature(s): _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-at-eval -~~~~~~~~~~~~~~ +==== .zinit-at-eval Has 9 line(s). Calls functions: @@ -93,8 +82,7 @@ Called by: ∞zinit-atpull-e-hook ∞zinit-atpull-hook -.zinit-compile-plugin -~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-compile-plugin ____ @@ -103,6 +91,7 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 87 line(s). Calls functions: @@ -120,8 +109,7 @@ Called by: zinit-autoload.zsh/.zinit-compile-uncompile-all zinit.zsh/zinit -.zinit-compinit -~~~~~~~~~~~~~~~ +==== .zinit-compinit ____ @@ -131,11 +119,13 @@ ____ Zinit's completions. No arguments. + ____ Has 26 line(s). Calls functions: .zinit-compinit + |-- .zinit-forget-completion |-- compinit `-- zinit.zsh/+zinit-message @@ -149,13 +139,13 @@ Called by: zinit.zsh/.zinit-prepare-home zinit.zsh/zinit -.zinit-configure-run-autoconf -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-configure-run-autoconf ____ Called if # passed to configure ice or no ./configure found Runs autoconf, autoreconf, and autogen.sh + ____ Has 64 line(s). Calls functions: @@ -167,13 +157,13 @@ Called by: ∞zinit-configure-base-hook -.zinit-download-file-stdout -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-download-file-stdout ____ Downloads file to stdout. Supports following backend commands: curl, wget, lftp, lynx. Used by snippet loading. + ____ Has 53 line(s). Calls functions: @@ -190,8 +180,7 @@ Called by: .zinit-get-package .zinit-setup-plugin-dir -.zinit-download-snippet -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-download-snippet ____ @@ -201,11 +190,26 @@ ____ Github supports Subversion protocol and allows to clone subdirectories. This is used to provide a layer of support for Oh-My-Zsh and Prezto. + ____ Has 377 line(s). Calls functions: .zinit-download-snippet + |-- .zinit-download-file-stdout + |   `-- zinit.zsh/+zinit-message + |-- .zinit-get-url-mtime + |-- .zinit-install-completions + |   |-- .zinit-compinit + |   |   |-- .zinit-forget-completion + |   |   |-- compinit + |   |   `-- zinit.zsh/+zinit-message + |   |-- .zinit-forget-completion + |   |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |   |-- zinit-side.zsh/.zinit-exists-physically-message + |   |-- zinit.zsh/+zinit-message + |   `-- zinit.zsh/.zinit-any-to-user-plugin + |-- .zinit-mirror-using-svn |-- zinit-side.zsh/.zinit-store-ices |-- zinit.zsh/+zinit-message `-- zinit.zsh/is-at-least @@ -217,8 +221,7 @@ Called by: .zinit-update-snippet zinit.zsh/.zinit-load-snippet -.zinit-extract -~~~~~~~~~~~~~~ +==== .zinit-extract Has 30 line(s). Calls functions: @@ -233,8 +236,7 @@ Called by: ∞zinit-extract-hook -.zinit-forget-completion -~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-forget-completion ____ @@ -242,6 +244,7 @@ ____ completion stops being visible to Zsh. $1 - completion function name, e.g. "_cp"; can also be "cp" + ____ Has 20 line(s). Doesn't call other functions. @@ -255,12 +258,13 @@ Called by: zinit-autoload.zsh/.zinit-uninstall-completions zinit.zsh/zinit -.zinit-get-cygwin-package -~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-get-cygwin-package Has 70 line(s). Calls functions: .zinit-get-cygwin-package + |-- .zinit-download-file-stdout + |   `-- zinit.zsh/+zinit-message `-- zinit.zsh/+zinit-message Uses feature(s): _setopt_ @@ -269,13 +273,13 @@ Called by: .zinit-setup-plugin-dir -.zinit-get-latest-gh-r-url-part -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-get-latest-gh-r-url-part ____ Gets version string of latest release of given Github package. Connects to Github releases page. + ____ Has 52 line(s). Calls functions: @@ -290,12 +294,18 @@ Called by: .zinit-setup-plugin-dir zinit-autoload.zsh/.zinit-update-or-status -.zinit-get-package -~~~~~~~~~~~~~~~~~~ +==== .zinit-get-package Has 195 line(s). Calls functions: .zinit-get-package + |-- .zinit-download-file-stdout + |   `-- zinit.zsh/+zinit-message + |-- .zinit-jq-check + |   `-- zinit.zsh/+zinit-message + |-- .zinit-json-to-array + |   `-- .zinit-jq-check + |   `-- zinit.zsh/+zinit-message |-- ziextract |   `-- zinit.zsh/+zinit-message |-- zinit.zsh/+zinit-message @@ -307,15 +317,13 @@ Called by: zinit.zsh/.zinit-load -_Environment variables used:_ zinit.zsh -> ZPFX - -.zinit-get-url-mtime -~~~~~~~~~~~~~~~~~~~~ +==== .zinit-get-url-mtime ____ For the given URL returns the date in the Last-Modified header as a time stamp + ____ Has 35 line(s). Doesn't call other functions. @@ -326,8 +334,7 @@ Called by: .zinit-download-snippet -.zinit-install-completions -~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-install-completions ____ @@ -339,11 +346,17 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin if $1 (i.e., user) given $3 - if 1, then reinstall, otherwise only install completions that are not present + ____ Has 61 line(s). Calls functions: .zinit-install-completions + |-- .zinit-compinit + |   |-- .zinit-forget-completion + |   |-- compinit + |   `-- zinit.zsh/+zinit-message + |-- .zinit-forget-completion |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 |-- zinit-side.zsh/.zinit-exists-physically-message |-- zinit.zsh/+zinit-message @@ -357,13 +370,13 @@ Called by: .zinit-setup-plugin-dir zinit.zsh/zinit -.zinit-jq-check -~~~~~~~~~~~~~~~ +==== .zinit-jq-check ____ Check if jq is available and outputs an error message with instructions if that's not the case + ____ Has 8 line(s). Calls functions: @@ -377,8 +390,7 @@ Called by: .zinit-json-get-value .zinit-json-to-array -.zinit-json-get-value -~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-json-get-value ____ @@ -386,16 +398,18 @@ ____ $1: JSON structure $2: jq path + ____ Has 4 line(s). Calls functions: .zinit-json-get-value + `-- .zinit-jq-check + `-- zinit.zsh/+zinit-message Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-json-to-array -~~~~~~~~~~~~~~~~~~~~ +==== .zinit-json-to-array ____ @@ -405,11 +419,14 @@ ____ $1: JSON structure $2: jq path $3: name of the associative array to store the key/value pairs in + ____ Has 13 line(s). Calls functions: .zinit-json-to-array + `-- .zinit-jq-check + `-- zinit.zsh/+zinit-message Uses feature(s): _eval_, _setopt_ @@ -417,8 +434,7 @@ Called by: .zinit-get-package -.zinit-mirror-using-svn -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-mirror-using-svn ____ @@ -431,6 +447,7 @@ ____ $1 - URL $2 - mode, "" - normal, "-u" - update, "-t" - test $3 - subdirectory (not path) with working copy, needed for -t and -u + ____ Has 29 line(s). Doesn't call other functions. @@ -441,8 +458,7 @@ Called by: .zinit-download-snippet -.zinit-setup-plugin-dir -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-setup-plugin-dir ____ @@ -452,11 +468,30 @@ ____ $1 - user $2 - plugin + ____ -Has 215 line(s). Calls functions: +Has 214 line(s). Calls functions: .zinit-setup-plugin-dir + |-- .zinit-download-file-stdout + |   `-- zinit.zsh/+zinit-message + |-- .zinit-get-cygwin-package + |   |-- .zinit-download-file-stdout + |   |   `-- zinit.zsh/+zinit-message + |   `-- zinit.zsh/+zinit-message + |-- .zinit-get-latest-gh-r-url-part + |   `-- zinit.zsh/+zinit-message + |-- .zinit-install-completions + |   |-- .zinit-compinit + |   |   |-- .zinit-forget-completion + |   |   |-- compinit + |   |   `-- zinit.zsh/+zinit-message + |   |-- .zinit-forget-completion + |   |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |   |-- zinit-side.zsh/.zinit-exists-physically-message + |   |-- zinit.zsh/+zinit-message + |   `-- zinit.zsh/.zinit-any-to-user-plugin |-- ziextract |   `-- zinit.zsh/+zinit-message |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 @@ -471,12 +506,12 @@ Called by: zinit-autoload.zsh/.zinit-update-or-status zinit.zsh/.zinit-load -.zinit-single-line -~~~~~~~~~~~~~~~~~~ +==== .zinit-single-line ____ Display cURL progress bar on a single line + ____ Has 20 line(s). Doesn't call other functions. @@ -485,12 +520,29 @@ Uses feature(s): _read_, _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-update-snippet -~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-update-snippet Has 76 line(s). Calls functions: .zinit-update-snippet + |-- .zinit-download-snippet + |   |-- .zinit-download-file-stdout + |   |   `-- zinit.zsh/+zinit-message + |   |-- .zinit-get-url-mtime + |   |-- .zinit-install-completions + |   |   |-- .zinit-compinit + |   |   |   |-- .zinit-forget-completion + |   |   |   |-- compinit + |   |   |   `-- zinit.zsh/+zinit-message + |   |   |-- .zinit-forget-completion + |   |   |-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + |   |   |-- zinit-side.zsh/.zinit-exists-physically-message + |   |   |-- zinit.zsh/+zinit-message + |   |   `-- zinit.zsh/.zinit-any-to-user-plugin + |   |-- .zinit-mirror-using-svn + |   |-- zinit-side.zsh/.zinit-store-ices + |   |-- zinit.zsh/+zinit-message + |   `-- zinit.zsh/is-at-least |-- zinit.zsh/+zinit-message |-- zinit.zsh/.zinit-get-object-path `-- zinit.zsh/.zinit-pack-ice @@ -501,8 +553,7 @@ Called by: zinit-autoload.zsh/.zinit-update-or-status-snippet -zicp -~~~~ +==== zicp Has 30 line(s). Doesn't call other functions. @@ -512,10 +563,7 @@ Called by: zimv -_Environment variables used:_ zinit.zsh -> ZPFX - -ziextract -~~~~~~~~~ +==== ziextract ____ @@ -526,6 +574,7 @@ ____ $1 - url $2 - file + ____ Has 283 line(s). Calls functions: @@ -542,8 +591,7 @@ Called by: .zinit-setup-plugin-dir zpextract -zimv -~~~~ +==== zimv Has 3 line(s). Calls functions: @@ -552,8 +600,7 @@ Has 3 line(s). Calls functions: Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -zpextract -~~~~~~~~~ +==== zpextract Has 1 line(s). Calls functions: @@ -563,8 +610,7 @@ Has 1 line(s). Calls functions: Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-atclone-hook -~~~~~~~~~~~~~~~~~~~ +==== ∞zinit-atclone-hook Has 26 line(s). Calls functions: @@ -576,43 +622,47 @@ Uses feature(s): _eval_, _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-atpull-e-hook -~~~~~~~~~~~~~~~~~~~~ +==== ∞zinit-atpull-e-hook Has 22 line(s). Calls functions: ∞zinit-atpull-e-hook + |-- .zinit-at-eval + |   `-- zinit.zsh/@zinit-substitute `-- zinit-side.zsh/.zinit-countdown Uses feature(s): _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-atpull-hook -~~~~~~~~~~~~~~~~~~ +==== ∞zinit-atpull-hook Has 22 line(s). Calls functions: ∞zinit-atpull-hook + |-- .zinit-at-eval + |   `-- zinit.zsh/@zinit-substitute `-- zinit-side.zsh/.zinit-countdown Uses feature(s): _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-compile-plugin-hook -~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== ∞zinit-compile-plugin-hook Has 19 line(s). Calls functions: ∞zinit-compile-plugin-hook + `-- .zinit-compile-plugin + |-- zinit-side.zsh/.zinit-compute-ice + |-- zinit-side.zsh/.zinit-first + `-- zinit.zsh/+zinit-message Uses feature(s): _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-configure-base-hook -~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== ∞zinit-configure-base-hook ____ @@ -620,11 +670,14 @@ ____ the starting steps are rigid and the same in all hooks, hence the idea. TODO: use in make'' and other places. + ____ Has 65 line(s). Calls functions: ∞zinit-configure-base-hook + |-- .zinit-configure-run-autoconf + |   `-- zinit-side.zsh/.zinit-countdown |-- zinit-side.zsh/.zinit-countdown `-- zinit.zsh/@zinit-substitute @@ -633,48 +686,49 @@ Called by: ∞zinit-configure-e-hook ∞zinit-configure-hook -_Environment variables used:_ zinit.zsh -> ZPFX - -∞zinit-configure-e-hook -~~~~~~~~~~~~~~~~~~~~~~~ +==== ∞zinit-configure-e-hook ____ The !-version of configure'' ice. Runs in between of make'!!' and make'!'. Configure naturally runs before make. + ____ Has 1 line(s). Calls functions: ∞zinit-configure-e-hook `-- ∞zinit-configure-base-hook + |-- .zinit-configure-run-autoconf + |   `-- zinit-side.zsh/.zinit-countdown |-- zinit-side.zsh/.zinit-countdown `-- zinit.zsh/@zinit-substitute Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-configure-hook -~~~~~~~~~~~~~~~~~~~~~ +==== ∞zinit-configure-hook ____ The non-! version of configure'' ice. Runs in between of make'!' and make''. Configure script naturally runs before make. + ____ Has 1 line(s). Calls functions: ∞zinit-configure-hook `-- ∞zinit-configure-base-hook + |-- .zinit-configure-run-autoconf + |   `-- zinit-side.zsh/.zinit-countdown |-- zinit-side.zsh/.zinit-countdown `-- zinit.zsh/@zinit-substitute Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-cp-hook -~~~~~~~~~~~~~~ +==== ∞zinit-cp-hook Has 30 line(s). Calls functions: @@ -685,18 +739,20 @@ Uses feature(s): _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-extract-hook -~~~~~~~~~~~~~~~~~~~ +==== ∞zinit-extract-hook Has 10 line(s). Calls functions: ∞zinit-extract-hook + |-- .zinit-extract + |   |-- ziextract + |   |   `-- zinit.zsh/+zinit-message + |   `-- zinit.zsh/+zinit-message `-- zinit.zsh/@zinit-substitute Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-make-base-hook -~~~~~~~~~~~~~~~~~~~~~ +==== ∞zinit-make-base-hook Has 29 line(s). Calls functions: @@ -710,8 +766,7 @@ Called by: ∞zinit-make-ee-hook ∞zinit-make-hook -∞zinit-make-e-hook -~~~~~~~~~~~~~~~~~~ +==== ∞zinit-make-e-hook Has 1 line(s). Calls functions: @@ -722,8 +777,7 @@ Has 1 line(s). Calls functions: Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-make-ee-hook -~~~~~~~~~~~~~~~~~~~ +==== ∞zinit-make-ee-hook Has 1 line(s). Calls functions: @@ -734,8 +788,7 @@ Has 1 line(s). Calls functions: Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-make-hook -~~~~~~~~~~~~~~~~ +==== ∞zinit-make-hook Has 1 line(s). Calls functions: @@ -746,8 +799,7 @@ Has 1 line(s). Calls functions: Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-mv-hook -~~~~~~~~~~~~~~ +==== ∞zinit-mv-hook Has 35 line(s). Calls functions: @@ -759,8 +811,7 @@ Uses feature(s): _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-ps-on-update-hook -~~~~~~~~~~~~~~~~~~~~~~~~ +==== ∞zinit-ps-on-update-hook Has 18 line(s). Calls functions: @@ -771,8 +822,7 @@ Uses feature(s): _eval_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -∞zinit-reset-hook -~~~~~~~~~~~~~~~~~ +==== ∞zinit-reset-hook Has 79 line(s). Calls functions: @@ -783,8 +833,7 @@ Uses feature(s): _eval_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -compinit -~~~~~~~~ +==== compinit ____ @@ -798,6 +847,7 @@ ____ should be done with its contents: `#compdef ' + ____ Has 573 line(s). Doesn't call other functions. diff --git a/doc/zsdoc/zinit-side.zsh.adoc b/doc/zsdoc/zinit-side.zsh.adoc index b562592ee..a9b3378c4 100644 --- a/doc/zsdoc/zinit-side.zsh.adoc +++ b/doc/zsdoc/zinit-side.zsh.adoc @@ -1,18 +1,11 @@ -zinit-side.zsh(1) -================= -:compat-mode!: NAME ----- + zinit-side.zsh - a shell script -SYNOPSIS --------- Documentation automatically generated with `zshelldoc' -FUNCTIONS ---------- - +== FUNCTIONS .zinit-any-colorify-as-uspl2 .zinit-compute-ice .zinit-countdown @@ -22,16 +15,13 @@ FUNCTIONS .zinit-store-ices .zinit-two-paths -DETAILS -------- +=== DETAILS -Script Body -~~~~~~~~~~~ +==== Script Body Has 1 line(s). No functions are called (may set up e.g. a hook, a Zle widget bound to a key, etc.). -.zinit-any-colorify-as-uspl2 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-any-colorify-as-uspl2 ____ @@ -42,6 +32,7 @@ ____ $2 - plugin (only when $1 - i.e. user - given) $REPLY - ANSI-colorified "user/plugin" string + ____ Has 22 line(s). Calls functions: @@ -63,7 +54,6 @@ Called by: zinit-autoload.zsh/.zinit-recently zinit-autoload.zsh/.zinit-search-completions zinit-autoload.zsh/.zinit-show-completions - zinit-autoload.zsh/.zinit-show-registered-plugins zinit-autoload.zsh/.zinit-show-times zinit-autoload.zsh/.zinit-uncompile-plugin zinit-autoload.zsh/.zinit-unload @@ -74,8 +64,7 @@ Called by: zinit-install.zsh/.zinit-setup-plugin-dir zinit.zsh/.zinit-formatter-pid -.zinit-compute-ice -~~~~~~~~~~~~~~~~~~ +==== .zinit-compute-ice ____ @@ -98,11 +87,28 @@ ____ $6 - name of output string parameter, to hold is-snippet 0/1-bool ("is_snippet") $REPLY - snippet directory filepath + ____ Has 110 line(s). Calls functions: .zinit-compute-ice + |-- .zinit-exists-physically-message + |   |-- .zinit-any-colorify-as-uspl2 + |   |   |-- zinit.zsh/.zinit-any-to-pid + |   |   `-- zinit.zsh/.zinit-any-to-user-plugin + |   |-- .zinit-exists-physically + |   |   `-- zinit.zsh/.zinit-any-to-user-plugin + |   |-- zinit.zsh/+zinit-message + |   |-- zinit.zsh/.zinit-any-to-pid + |   `-- zinit.zsh/.zinit-any-to-user-plugin + |-- .zinit-two-paths + |   |-- .zinit-first + |   |   |-- zinit.zsh/.zinit-any-to-pid + |   |   |-- zinit.zsh/.zinit-any-to-user-plugin + |   |   |-- zinit.zsh/.zinit-find-other-matches + |   |   `-- zinit.zsh/.zinit-get-object-path + |   `-- zinit.zsh/.zinit-get-object-path |-- zinit.zsh/.zinit-any-to-user-plugin `-- zinit.zsh/.zinit-pack-ice @@ -117,14 +123,14 @@ Called by: zinit-autoload.zsh/.zinit-update-or-status zinit-install.zsh/.zinit-compile-plugin -.zinit-countdown -~~~~~~~~~~~~~~~~ +==== .zinit-countdown ____ Displays a countdown 5...4... etc. $REPLY - 1 if Ctrl-C is pressed, otherwise 0 + ____ Has 20 line(s). Calls functions: @@ -144,8 +150,7 @@ Called by: zinit-install.zsh/∞zinit-configure-base-hook zinit-install.zsh/∞zinit-make-base-hook -.zinit-exists-physically -~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-exists-physically ____ @@ -153,6 +158,7 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 8 line(s). Calls functions: @@ -166,8 +172,7 @@ Called by: zinit-autoload.zsh/.zinit-create zinit-autoload.zsh/.zinit-update-or-status -.zinit-exists-physically-message -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-exists-physically-message ____ @@ -176,11 +181,17 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 25 line(s). Calls functions: .zinit-exists-physically-message + |-- .zinit-any-colorify-as-uspl2 + |   |-- zinit.zsh/.zinit-any-to-pid + |   `-- zinit.zsh/.zinit-any-to-user-plugin + |-- .zinit-exists-physically + |   `-- zinit.zsh/.zinit-any-to-user-plugin |-- zinit.zsh/+zinit-message |-- zinit.zsh/.zinit-any-to-pid `-- zinit.zsh/.zinit-any-to-user-plugin @@ -196,8 +207,7 @@ Called by: zinit-autoload.zsh/.zinit-update-or-status zinit-install.zsh/.zinit-install-completions -.zinit-first -~~~~~~~~~~~~ +==== .zinit-first ____ @@ -209,6 +219,7 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin (only when $1 - i.e. user - given) + ____ Has 20 line(s). Calls functions: @@ -226,8 +237,7 @@ Called by: zinit-autoload.zsh/.zinit-stress zinit-install.zsh/.zinit-compile-plugin -.zinit-store-ices -~~~~~~~~~~~~~~~~~ +==== .zinit-store-ices ____ @@ -239,6 +249,7 @@ ____ $4 - additional keys of hash to store, empty-meaningful ices, space separated $5 – URL, if applicable $6 – mode, svn=1, 0=single file + ____ Has 30 line(s). Doesn't call other functions. @@ -249,8 +260,7 @@ Called by: zinit-install.zsh/.zinit-download-snippet zinit-install.zsh/.zinit-setup-plugin-dir -.zinit-two-paths -~~~~~~~~~~~~~~~~ +==== .zinit-two-paths ____ @@ -259,11 +269,17 @@ ____ further examination $REPLY - two filepaths + ____ Has 24 line(s). Calls functions: .zinit-two-paths + |-- .zinit-first + |   |-- zinit.zsh/.zinit-any-to-pid + |   |-- zinit.zsh/.zinit-any-to-user-plugin + |   |-- zinit.zsh/.zinit-find-other-matches + |   `-- zinit.zsh/.zinit-get-object-path `-- zinit.zsh/.zinit-get-object-path Uses feature(s): _setopt_ diff --git a/doc/zsdoc/zinit.zsh.adoc b/doc/zsdoc/zinit.zsh.adoc index f16d73622..7d12c717b 100644 --- a/doc/zsdoc/zinit.zsh.adoc +++ b/doc/zsdoc/zinit.zsh.adoc @@ -1,18 +1,11 @@ -zinit.zsh(1) -============ -:compat-mode!: NAME ----- + zinit.zsh - a shell script -SYNOPSIS --------- Documentation automatically generated with `zshelldoc' -FUNCTIONS ---------- - +== FUNCTIONS +zinit-deploy-message +zinit-message +zinit-prehelp-usage-message @@ -82,27 +75,102 @@ FUNCTIONS zpcompinit zplugin AUTOLOAD add-zsh-hook +AUTOLOAD colors AUTOLOAD compinit AUTOLOAD is-at-least PRECMD-HOOK @zinit-scheduler -DETAILS -------- +=== DETAILS -Script Body -~~~~~~~~~~~ +==== Script Body -Has 249 line(s). Calls functions: +Has 244 line(s). Calls functions: Script-Body |-- +zinit-message + |-- .zinit-get-mtime-into + |-- .zinit-prepare-home + |   |-- zinit-autoload.zsh/.zinit-clear-completions + |   `-- zinit-install.zsh/.zinit-compinit |-- @zinit-register-hook |-- add-zsh-hook + |-- colors |-- is-at-least |-- zinit |   |-- +zinit-message |   |-- +zinit-prehelp-usage-message |   |   `-- +zinit-message + |   |-- .zinit-add-fpath + |   |   `-- .zinit-any-to-user-plugin + |   |-- .zinit-compdef-clear + |   |   `-- +zinit-message + |   |-- .zinit-compdef-replay + |   |   `-- +zinit-message + |   |-- .zinit-get-object-path + |   |   `-- .zinit-any-to-user-plugin + |   |-- .zinit-ice + |   |-- .zinit-load-ices + |   |   `-- .zinit-get-object-path + |   |   `-- .zinit-any-to-user-plugin + |   |-- .zinit-load-object + |   |   |-- .zinit-load + |   |   |   |-- +zinit-deploy-message + |   |   |   |-- .zinit-any-to-user-plugin + |   |   |   |-- .zinit-load-plugin + |   |   |   |   |-- .zinit-add-report + |   |   |   |   |-- .zinit-diff + |   |   |   |   |   |-- .zinit-diff-env + |   |   |   |   |   |-- .zinit-diff-functions + |   |   |   |   |   |-- .zinit-diff-options + |   |   |   |   |   `-- .zinit-diff-parameter + |   |   |   |   |-- .zinit-diff-env + |   |   |   |   |-- .zinit-find-other-matches + |   |   |   |   |-- .zinit-tmp-subst-off + |   |   |   |   |-- .zinit-tmp-subst-on + |   |   |   |   `-- :zinit-tmp-subst-autoload + |   |   |   |   |-- +zinit-message + |   |   |   |   |-- .zinit-add-report + |   |   |   |   |-- .zinit-any-to-user-plugin + |   |   |   |   `-- is-at-least + |   |   |   |-- .zinit-load-snippet + |   |   |   |   |-- +zinit-deploy-message + |   |   |   |   |-- +zinit-message + |   |   |   |   |-- .zinit-add-report + |   |   |   |   |-- .zinit-find-other-matches + |   |   |   |   |-- .zinit-get-object-path + |   |   |   |   |   `-- .zinit-any-to-user-plugin + |   |   |   |   |-- .zinit-pack-ice + |   |   |   |   |-- .zinit-set-m-func + |   |   |   |   |   `-- +zinit-message + |   |   |   |   |-- .zinit-setup-params + |   |   |   |   `-- zinit-install.zsh/.zinit-download-snippet + |   |   |   |-- .zinit-pack-ice + |   |   |   |-- .zinit-register-plugin + |   |   |   |   `-- +zinit-message + |   |   |   |-- .zinit-set-m-func + |   |   |   |   `-- +zinit-message + |   |   |   |-- .zinit-setup-params + |   |   |   |-- zinit-install.zsh/.zinit-get-package + |   |   |   `-- zinit-install.zsh/.zinit-setup-plugin-dir + |   |   `-- .zinit-load-snippet + |   |   |-- +zinit-deploy-message + |   |   |-- +zinit-message + |   |   |-- .zinit-add-report + |   |   |-- .zinit-find-other-matches + |   |   |-- .zinit-get-object-path + |   |   |   `-- .zinit-any-to-user-plugin + |   |   |-- .zinit-pack-ice + |   |   |-- .zinit-set-m-func + |   |   |   `-- +zinit-message + |   |   |-- .zinit-setup-params + |   |   `-- zinit-install.zsh/.zinit-download-snippet + |   |-- .zinit-parse-opts + |   |-- .zinit-run + |   |   |-- +zinit-message + |   |   |-- .zinit-any-to-user-plugin + |   |   `-- .zinit-get-object-path + |   |   `-- .zinit-any-to-user-plugin + |   |-- .zinit-submit-turbo |   |-- compinit |   |-- zinit-additional.zsh/.zinit-clear-debug-report |   |-- zinit-additional.zsh/.zinit-debug-start @@ -113,10 +181,12 @@ Has 249 line(s). Calls functions: |   |-- zinit-autoload.zsh/.zinit-clear-completions |   |-- zinit-autoload.zsh/.zinit-compile-uncompile-all |   |-- zinit-autoload.zsh/.zinit-compiled + |   |-- zinit-autoload.zsh/.zinit-delete |   |-- zinit-autoload.zsh/.zinit-help |   |-- zinit-autoload.zsh/.zinit-list-bindkeys |   |-- zinit-autoload.zsh/.zinit-list-compdef-replay - |   |-- zinit-autoload.zsh/.zinit-ls + |   |-- zinit-autoload.zsh/.zinit-list-plugins + |   |-- zinit-autoload.zsh/.zinit-list-snippets |   |-- zinit-autoload.zsh/.zinit-module |   |-- zinit-autoload.zsh/.zinit-recently |   |-- zinit-autoload.zsh/.zinit-search-completions @@ -124,7 +194,6 @@ Has 249 line(s). Calls functions: |   |-- zinit-autoload.zsh/.zinit-show-all-reports |   |-- zinit-autoload.zsh/.zinit-show-completions |   |-- zinit-autoload.zsh/.zinit-show-debug-report - |   |-- zinit-autoload.zsh/.zinit-show-registered-plugins |   |-- zinit-autoload.zsh/.zinit-show-report |   |-- zinit-autoload.zsh/.zinit-show-times |   |-- zinit-autoload.zsh/.zinit-show-zstatus @@ -140,17 +209,17 @@ Has 249 line(s). Calls functions: |   `-- zinit-install.zsh/.zinit-install-completions `-- zinit-autoload.zsh/.zinit-module -Uses feature(s): _add-zsh-hook_, _alias_, _autoload_, _bindkey_, _export_, _is-at-least_, _setopt_, _source_, _zle_, _zmodload_, _zstyle_ +Uses feature(s): _add-zsh-hook_, _alias_, _autoload_, _bindkey_, _colors_, _export_, _is-at-least_, _setopt_, _source_, _zle_, _zmodload_, _zstyle_ _Exports (environment):_ PMSPEC [big]*//* ZPFX [big]*//* ZSH_CACHE_DIR -+zinit-deploy-message -~~~~~~~~~~~~~~~~~~~~~ +==== +zinit-deploy-message ____ Deploys a sub-prompt message to be displayed OR a 'zle .reset-prompt' call to be invoked + ____ Has 13 line(s). Doesn't call other functions. @@ -163,8 +232,7 @@ Called by: .zinit-load zinit-autoload.zsh/.zinit-recall -+zinit-message -~~~~~~~~~~~~~~ +==== +zinit-message Has 16 line(s). Doesn't call other functions. @@ -185,6 +253,10 @@ Called by: zinit-additional.zsh/:zinit-tmp-subst-source zinit-autoload.zsh/.zinit-build-module zinit-autoload.zsh/.zinit-cd + zinit-autoload.zsh/.zinit-confirm + zinit-autoload.zsh/.zinit-delete + zinit-autoload.zsh/.zinit-glance + zinit-autoload.zsh/.zinit-list-plugins zinit-autoload.zsh/.zinit-self-update zinit-autoload.zsh/.zinit-show-zstatus zinit-autoload.zsh/.zinit-uninstall-completions @@ -213,8 +285,7 @@ Called by: zinit-side.zsh/.zinit-countdown zinit-side.zsh/.zinit-exists-physically-message -+zinit-prehelp-usage-message -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== +zinit-prehelp-usage-message Has 38 line(s). Calls functions: @@ -224,35 +295,33 @@ Has 38 line(s). Calls functions: Called by: zinit - zinit-autoload.zsh/.zinit-delete --zinit_scheduler_add_sh -~~~~~~~~~~~~~~~~~~~~~~~ +==== -zinit_scheduler_add_sh ____ Copies task into ZINIT_RUN array, called when a task timeouts. A small function ran from pattern in /-substitution as a math function. + ____ Has 7 line(s). Doesn't call other functions. Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-add-fpath -~~~~~~~~~~~~~~~~ +==== .zinit-add-fpath Has 10 line(s). Calls functions: .zinit-add-fpath + `-- .zinit-any-to-user-plugin Called by: zinit -.zinit-add-report -~~~~~~~~~~~~~~~~~ +==== .zinit-add-report ____ @@ -260,6 +329,7 @@ ____ $1 - uspl2, i.e. user/plugin $2 - the text + ____ Has 3 line(s). Doesn't call other functions. @@ -275,12 +345,12 @@ Called by: :zinit-tmp-subst-zle :zinit-tmp-subst-zstyle -.zinit-any-to-pid -~~~~~~~~~~~~~~~~~ +==== .zinit-any-to-pid Has 22 line(s). Calls functions: .zinit-any-to-pid + `-- .zinit-util-shands-path Uses feature(s): _setopt_ @@ -290,8 +360,7 @@ Called by: zinit-side.zsh/.zinit-exists-physically-message zinit-side.zsh/.zinit-first -.zinit-any-to-user-plugin -~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-any-to-user-plugin ____ @@ -301,6 +370,7 @@ ____ $2 - plugin (only when $1 - i.e. user - given) $REPLY - user and plugin + ____ Has 29 line(s). Doesn't call other functions. @@ -337,14 +407,12 @@ Called by: zinit-side.zsh/.zinit-exists-physically zinit-side.zsh/.zinit-first -_Environment variables used:_ ZPFX - -.zinit-compdef-clear -~~~~~~~~~~~~~~~~~~~~ +==== .zinit-compdef-clear ____ Implements user-exposed functionality to clear gathered compdefs. + ____ Has 3 line(s). Calls functions: @@ -358,12 +426,12 @@ Called by: zinit zpcdclear -.zinit-compdef-replay -~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-compdef-replay ____ Runs gathered compdef calls. This allows to run 'compinit' after loading plugins. + ____ Has 17 line(s). Calls functions: @@ -379,17 +447,21 @@ Called by: zinit zpcdreplay -.zinit-diff -~~~~~~~~~~~ +==== .zinit-diff ____ Performs diff actions of all types + ____ Has 4 line(s). Calls functions: .zinit-diff + |-- .zinit-diff-env + |-- .zinit-diff-functions + |-- .zinit-diff-options + `-- .zinit-diff-parameter Called by: @@ -397,8 +469,7 @@ Called by: zinit-additional.zsh/.zinit-debug-start zinit-additional.zsh/.zinit-debug-stop -.zinit-diff-env -~~~~~~~~~~~~~~~ +==== .zinit-diff-env ____ @@ -406,6 +477,7 @@ ____ $1 - user/plugin (i.e. uspl2 format) $2 - command, can be "begin" or "end" + ____ Has 18 line(s). Doesn't call other functions. @@ -415,8 +487,7 @@ Called by: .zinit-diff .zinit-load-plugin -.zinit-diff-functions -~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-diff-functions ____ @@ -425,6 +496,7 @@ ____ $1 - user/plugin (i.e. uspl2 format) $2 - command, can be "begin" or "end" + ____ Has 8 line(s). Doesn't call other functions. @@ -433,8 +505,7 @@ Called by: .zinit-diff -.zinit-diff-options -~~~~~~~~~~~~~~~~~~~ +==== .zinit-diff-options ____ @@ -443,6 +514,7 @@ ____ $1 - user/plugin (i.e. uspl2 format) $2 - command, can be "begin" or "end" + ____ Has 7 line(s). Doesn't call other functions. @@ -451,8 +523,7 @@ Called by: .zinit-diff -.zinit-diff-parameter -~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-diff-parameter ____ @@ -461,6 +532,7 @@ ____ $1 - user/plugin (i.e. uspl2 format) $2 - command, can be "begin" or "end" + ____ Has 9 line(s). Doesn't call other functions. @@ -469,14 +541,14 @@ Called by: .zinit-diff -.zinit-find-other-matches -~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-find-other-matches ____ Plugin's main source file is in general `name.plugin.zsh'. However, there can be different conventions, if that file is not found, then this functions examines other conventions in the most sane order. + ____ Has 22 line(s). Doesn't call other functions. @@ -487,28 +559,29 @@ Called by: .zinit-load-snippet zinit-side.zsh/.zinit-first -.zinit-formatter-auto -~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-formatter-auto Has 50 line(s). Calls functions: .zinit-formatter-auto + |-- .zinit-formatter-pid + |   `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 + `-- .zinit-formatter-url Uses feature(s): _type_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-formatter-bar -~~~~~~~~~~~~~~~~~~~~ +==== .zinit-formatter-bar Has 1 line(s). Calls functions: .zinit-formatter-bar + `-- .zinit-formatter-bar-util Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-formatter-bar-util -~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-formatter-bar-util Has 7 line(s). Doesn't call other functions. @@ -517,15 +590,13 @@ Called by: .zinit-formatter-bar .zinit-formatter-th-bar -.zinit-formatter-dbg -~~~~~~~~~~~~~~~~~~~~ +==== .zinit-formatter-dbg Has 5 line(s). Doesn't call other functions. Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-formatter-pid -~~~~~~~~~~~~~~~~~~~~ +==== .zinit-formatter-pid Has 11 line(s). Calls functions: @@ -538,17 +609,16 @@ Called by: .zinit-formatter-auto -.zinit-formatter-th-bar -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-formatter-th-bar Has 1 line(s). Calls functions: .zinit-formatter-th-bar + `-- .zinit-formatter-bar-util Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-formatter-url -~~~~~~~~~~~~~~~~~~~~ +==== .zinit-formatter-url Has 19 line(s). Doesn't call other functions. @@ -556,8 +626,7 @@ Called by: .zinit-formatter-auto -.zinit-get-mtime-into -~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-get-mtime-into Has 7 line(s). Doesn't call other functions. @@ -567,12 +636,12 @@ Called by: zinit-autoload.zsh/.zinit-self-update zinit-autoload.zsh/.zinit-update-or-status-all -.zinit-get-object-path -~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-get-object-path Has 28 line(s). Calls functions: .zinit-get-object-path + `-- .zinit-any-to-user-plugin Called by: @@ -586,14 +655,14 @@ Called by: zinit-side.zsh/.zinit-first zinit-side.zsh/.zinit-two-paths -.zinit-ice -~~~~~~~~~~ +==== .zinit-ice ____ Parses ICE specification, puts the result into ICE global hash. 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. + ____ Has 13 line(s). Doesn't call other functions. @@ -604,10 +673,7 @@ Called by: zinit -_Environment variables used:_ ZPFX - -.zinit-load -~~~~~~~~~~~ +==== .zinit-load ____ @@ -615,12 +681,48 @@ ____ $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) $2 - plugin name, if the third format is used + ____ Has 95 line(s). Calls functions: .zinit-load |-- +zinit-deploy-message + |-- .zinit-any-to-user-plugin + |-- .zinit-load-plugin + |   |-- .zinit-add-report + |   |-- .zinit-diff + |   |   |-- .zinit-diff-env + |   |   |-- .zinit-diff-functions + |   |   |-- .zinit-diff-options + |   |   `-- .zinit-diff-parameter + |   |-- .zinit-diff-env + |   |-- .zinit-find-other-matches + |   |-- .zinit-tmp-subst-off + |   |-- .zinit-tmp-subst-on + |   `-- :zinit-tmp-subst-autoload + |   |-- +zinit-message + |   |-- .zinit-add-report + |   |-- .zinit-any-to-user-plugin + |   `-- is-at-least + |-- .zinit-load-snippet + |   |-- +zinit-deploy-message + |   |-- +zinit-message + |   |-- .zinit-add-report + |   |-- .zinit-find-other-matches + |   |-- .zinit-get-object-path + |   |   `-- .zinit-any-to-user-plugin + |   |-- .zinit-pack-ice + |   |-- .zinit-set-m-func + |   |   `-- +zinit-message + |   |-- .zinit-setup-params + |   `-- zinit-install.zsh/.zinit-download-snippet + |-- .zinit-pack-ice + |-- .zinit-register-plugin + |   `-- +zinit-message + |-- .zinit-set-m-func + |   `-- +zinit-message + |-- .zinit-setup-params |-- zinit-install.zsh/.zinit-get-package `-- zinit-install.zsh/.zinit-setup-plugin-dir @@ -632,32 +734,80 @@ Called by: .zinit-run-task zinit-additional.zsh/.zinit-service -.zinit-load-ices -~~~~~~~~~~~~~~~~ +==== .zinit-load-ices Has 22 line(s). Calls functions: .zinit-load-ices + `-- .zinit-get-object-path + `-- .zinit-any-to-user-plugin Called by: zinit -_Environment variables used:_ ZPFX - -.zinit-load-object -~~~~~~~~~~~~~~~~~~ +==== .zinit-load-object Has 12 line(s). Calls functions: .zinit-load-object + |-- .zinit-load + |   |-- +zinit-deploy-message + |   |-- .zinit-any-to-user-plugin + |   |-- .zinit-load-plugin + |   |   |-- .zinit-add-report + |   |   |-- .zinit-diff + |   |   |   |-- .zinit-diff-env + |   |   |   |-- .zinit-diff-functions + |   |   |   |-- .zinit-diff-options + |   |   |   `-- .zinit-diff-parameter + |   |   |-- .zinit-diff-env + |   |   |-- .zinit-find-other-matches + |   |   |-- .zinit-tmp-subst-off + |   |   |-- .zinit-tmp-subst-on + |   |   `-- :zinit-tmp-subst-autoload + |   |   |-- +zinit-message + |   |   |-- .zinit-add-report + |   |   |-- .zinit-any-to-user-plugin + |   |   `-- is-at-least + |   |-- .zinit-load-snippet + |   |   |-- +zinit-deploy-message + |   |   |-- +zinit-message + |   |   |-- .zinit-add-report + |   |   |-- .zinit-find-other-matches + |   |   |-- .zinit-get-object-path + |   |   |   `-- .zinit-any-to-user-plugin + |   |   |-- .zinit-pack-ice + |   |   |-- .zinit-set-m-func + |   |   |   `-- +zinit-message + |   |   |-- .zinit-setup-params + |   |   `-- zinit-install.zsh/.zinit-download-snippet + |   |-- .zinit-pack-ice + |   |-- .zinit-register-plugin + |   |   `-- +zinit-message + |   |-- .zinit-set-m-func + |   |   `-- +zinit-message + |   |-- .zinit-setup-params + |   |-- zinit-install.zsh/.zinit-get-package + |   `-- zinit-install.zsh/.zinit-setup-plugin-dir + `-- .zinit-load-snippet + |-- +zinit-deploy-message + |-- +zinit-message + |-- .zinit-add-report + |-- .zinit-find-other-matches + |-- .zinit-get-object-path + |   `-- .zinit-any-to-user-plugin + |-- .zinit-pack-ice + |-- .zinit-set-m-func + |   `-- +zinit-message + |-- .zinit-setup-params + `-- zinit-install.zsh/.zinit-download-snippet Called by: zinit -.zinit-load-plugin -~~~~~~~~~~~~~~~~~~ +==== .zinit-load-plugin ____ @@ -666,13 +816,26 @@ ____ $1 - user $2 - plugin $3 - mode (light or load) + ____ Has 128 line(s). Calls functions: .zinit-load-plugin + |-- .zinit-add-report + |-- .zinit-diff + |   |-- .zinit-diff-env + |   |-- .zinit-diff-functions + |   |-- .zinit-diff-options + |   `-- .zinit-diff-parameter + |-- .zinit-diff-env + |-- .zinit-find-other-matches + |-- .zinit-tmp-subst-off + |-- .zinit-tmp-subst-on `-- :zinit-tmp-subst-autoload |-- +zinit-message + |-- .zinit-add-report + |-- .zinit-any-to-user-plugin `-- is-at-least Uses feature(s): _eval_, _setopt_, _source_, _unfunction_, _zle_ @@ -681,14 +844,14 @@ Called by: .zinit-load -.zinit-load-snippet -~~~~~~~~~~~~~~~~~~~ +==== .zinit-load-snippet ____ Implements the exposed-to-user action of loading a snippet. $1 - url (can be local, absolute path). + ____ Has 203 line(s). Calls functions: @@ -696,6 +859,14 @@ Has 203 line(s). Calls functions: .zinit-load-snippet |-- +zinit-deploy-message |-- +zinit-message + |-- .zinit-add-report + |-- .zinit-find-other-matches + |-- .zinit-get-object-path + |   `-- .zinit-any-to-user-plugin + |-- .zinit-pack-ice + |-- .zinit-set-m-func + |   `-- +zinit-message + |-- .zinit-setup-params `-- zinit-install.zsh/.zinit-download-snippet Uses feature(s): _autoload_, _eval_, _setopt_, _source_, _unfunction_, _zparseopts_, _zstyle_ @@ -708,21 +879,20 @@ Called by: pmodload zinit-additional.zsh/.zinit-service -.zinit-main-message-formatter -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-main-message-formatter Has 18 line(s). Doesn't call other functions. Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -.zinit-pack-ice -~~~~~~~~~~~~~~~ +==== .zinit-pack-ice ____ Remembers all ice-mods, assigns them to concrete plugin. Ice spec is in general forgotten for second-next command (i.e., ice melts quickly), however they glue to the object (plugin or snippet) mentioned in the next command for later use with (e.g. 'zinit update ...'). + ____ Has 3 line(s). Doesn't call other functions. @@ -736,23 +906,21 @@ Called by: zinit-install.zsh/.zinit-update-snippet zinit-side.zsh/.zinit-compute-ice -.zinit-parse-opts -~~~~~~~~~~~~~~~~~ +==== .zinit-parse-opts Has 2 line(s). Doesn't call other functions. Called by: zinit - zinit-autoload.zsh/.zinit-delete -.zinit-prepare-home -~~~~~~~~~~~~~~~~~~~ +==== .zinit-prepare-home ____ Creates all directories needed by Zinit, first checks if they already exist. + ____ Has 45 line(s). Calls functions: @@ -767,16 +935,14 @@ Called by: Script-Body -_Environment variables used:_ ZPFX - -.zinit-register-plugin -~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-register-plugin ____ Adds the plugin to ZINIT_REGISTERED_PLUGINS array and to the zsh_loaded_plugins array (managed according to the plugin standard: https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html). + ____ Has 23 line(s). Calls functions: @@ -788,19 +954,22 @@ Called by: .zinit-load -.zinit-run -~~~~~~~~~~ +==== .zinit-run ____ Run code inside plugins folder It uses the 'correct' parameter from uppers scope zinit(). + ____ Has 24 line(s). Calls functions: .zinit-run - `-- +zinit-message + |-- +zinit-message + |-- .zinit-any-to-user-plugin + `-- .zinit-get-object-path + `-- .zinit-any-to-user-plugin Uses feature(s): _eval_, _setopt_ @@ -808,8 +977,7 @@ Called by: zinit -.zinit-run-task -~~~~~~~~~~~~~~~ +==== .zinit-run-task ____ @@ -824,11 +992,63 @@ ____ $4 - tasks index in the ZINIT[WAIT_ICE_...] fields $5 - mode: load, light $6 - details: alias name (derived from id-as''), plugin-spec, or snippet URL + ____ Has 47 line(s). Calls functions: .zinit-run-task + |-- .zinit-load + |   |-- +zinit-deploy-message + |   |-- .zinit-any-to-user-plugin + |   |-- .zinit-load-plugin + |   |   |-- .zinit-add-report + |   |   |-- .zinit-diff + |   |   |   |-- .zinit-diff-env + |   |   |   |-- .zinit-diff-functions + |   |   |   |-- .zinit-diff-options + |   |   |   `-- .zinit-diff-parameter + |   |   |-- .zinit-diff-env + |   |   |-- .zinit-find-other-matches + |   |   |-- .zinit-tmp-subst-off + |   |   |-- .zinit-tmp-subst-on + |   |   `-- :zinit-tmp-subst-autoload + |   |   |-- +zinit-message + |   |   |-- .zinit-add-report + |   |   |-- .zinit-any-to-user-plugin + |   |   `-- is-at-least + |   |-- .zinit-load-snippet + |   |   |-- +zinit-deploy-message + |   |   |-- +zinit-message + |   |   |-- .zinit-add-report + |   |   |-- .zinit-find-other-matches + |   |   |-- .zinit-get-object-path + |   |   |   `-- .zinit-any-to-user-plugin + |   |   |-- .zinit-pack-ice + |   |   |-- .zinit-set-m-func + |   |   |   `-- +zinit-message + |   |   |-- .zinit-setup-params + |   |   `-- zinit-install.zsh/.zinit-download-snippet + |   |-- .zinit-pack-ice + |   |-- .zinit-register-plugin + |   |   `-- +zinit-message + |   |-- .zinit-set-m-func + |   |   `-- +zinit-message + |   |-- .zinit-setup-params + |   |-- zinit-install.zsh/.zinit-get-package + |   `-- zinit-install.zsh/.zinit-setup-plugin-dir + |-- .zinit-load-snippet + |   |-- +zinit-deploy-message + |   |-- +zinit-message + |   |-- .zinit-add-report + |   |-- .zinit-find-other-matches + |   |-- .zinit-get-object-path + |   |   `-- .zinit-any-to-user-plugin + |   |-- .zinit-pack-ice + |   |-- .zinit-set-m-func + |   |   `-- +zinit-message + |   |-- .zinit-setup-params + |   `-- zinit-install.zsh/.zinit-download-snippet `-- zinit-autoload.zsh/.zinit-unload Uses feature(s): _eval_, _source_, _zle_, _zpty_ @@ -837,13 +1057,13 @@ Called by: @zinit-scheduler -.zinit-set-m-func -~~~~~~~~~~~~~~~~~ +==== .zinit-set-m-func ____ ]]] Sets and withdraws the temporary, atclone/atpull time function `m`. + ____ Has 17 line(s). Calls functions: @@ -859,8 +1079,7 @@ Called by: .zinit-load zinit-autoload.zsh/.zinit-update-or-status -.zinit-setup-params -~~~~~~~~~~~~~~~~~~~ +==== .zinit-setup-params Has 3 line(s). Doesn't call other functions. @@ -869,8 +1088,7 @@ Called by: .zinit-load-snippet .zinit-load -.zinit-submit-turbo -~~~~~~~~~~~~~~~~~~~ +==== .zinit-submit-turbo ____ @@ -879,6 +1097,7 @@ ____ ice-mods then the plugin or snipped is to be loaded in turbo-mode, and this function adds it to internal data structures. @zinit-scheduler uses the data to create load or unload tasks. + ____ Has 16 line(s). Doesn't call other functions. @@ -887,13 +1106,13 @@ Called by: zinit -.zinit-tmp-subst-off -~~~~~~~~~~~~~~~~~~~~ +==== .zinit-tmp-subst-off ____ Turn off temporary substituting of functions completely for a given mode ("load", "light", "light-b" (i.e. the `trackbinds' mode) or "compdef"). + ____ Has 21 line(s). Doesn't call other functions. @@ -905,14 +1124,14 @@ Called by: .zinit-load-plugin zinit-additional.zsh/.zinit-debug-stop -.zinit-tmp-subst-on -~~~~~~~~~~~~~~~~~~~ +==== .zinit-tmp-subst-on ____ Turn on temporary substituting of functions of builtins and functions according to passed mode ("load", "light", "light-b" or "compdef"). The temporary substituting of functions is to gather report data, and to hijack 'autoload', 'bindkey' and 'compdef' calls. + ____ Has 32 line(s). Doesn't call other functions. @@ -924,12 +1143,12 @@ Called by: .zinit-load-plugin zinit-additional.zsh/.zinit-debug-start -.zinit-util-shands-path -~~~~~~~~~~~~~~~~~~~~~~~ +==== .zinit-util-shands-path ____ Replaces parts of path with %HOME, etc. + ____ Has 9 line(s). Doesn't call other functions. @@ -940,10 +1159,7 @@ Called by: .zinit-any-to-pid -_Environment variables used:_ ZPFX - -:zinit-reload-and-run -~~~~~~~~~~~~~~~~~~~~~ +==== :zinit-reload-and-run ____ @@ -960,6 +1176,7 @@ ____ $1 - FPATH dedicated to function $2 - autoload options $3 - function name (one that needs autoloading) + ____ Has 11 line(s). Doesn't call other functions. @@ -968,38 +1185,41 @@ Uses feature(s): _autoload_, _unfunction_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -:zinit-tmp-subst-alias -~~~~~~~~~~~~~~~~~~~~~~ +==== :zinit-tmp-subst-alias ____ Function defined to hijack plugin's calls to the `alias' builtin. The hijacking is to gather report data (which is used in unload). + ____ Has 36 line(s). Calls functions: :zinit-tmp-subst-alias + `-- .zinit-add-report Uses feature(s): _alias_, _setopt_, _zparseopts_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -:zinit-tmp-subst-autoload -~~~~~~~~~~~~~~~~~~~~~~~~~ +==== :zinit-tmp-subst-autoload ____ Hijack plugin's calls to the 'autoload' builtin. The hijacking gathers report data and runs custom `autoload' function, that doesn't need FPATH. + ____ Has 111 line(s). Calls functions: :zinit-tmp-subst-autoload |-- +zinit-message + |-- .zinit-add-report + |-- .zinit-any-to-user-plugin `-- is-at-least Uses feature(s): _autoload_, _eval_, _is-at-least_, _setopt_, _zparseopts_ @@ -1009,98 +1229,102 @@ Called by: .zinit-load-plugin @autoload -:zinit-tmp-subst-bindkey -~~~~~~~~~~~~~~~~~~~~~~~~ +==== :zinit-tmp-subst-bindkey ____ Function defined to hijack plugin's calls to the `bindkey' builtin. The hijacking is to gather report data (which is used in unload). + ____ Has 120 line(s). Calls functions: :zinit-tmp-subst-bindkey + |-- .zinit-add-report `-- is-at-least Uses feature(s): _bindkey_, _is-at-least_, _setopt_, _zparseopts_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -:zinit-tmp-subst-compdef -~~~~~~~~~~~~~~~~~~~~~~~~ +==== :zinit-tmp-subst-compdef ____ Function defined to hijack plugin's calls to the `compdef' function. The hijacking is not only for reporting, but also to save compdef calls so that `compinit' can be called after loading plugins. + ____ Has 6 line(s). Calls functions: :zinit-tmp-subst-compdef + `-- .zinit-add-report Uses feature(s): _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -:zinit-tmp-subst-zle -~~~~~~~~~~~~~~~~~~~~ +==== :zinit-tmp-subst-zle ____ Function defined to hijack plugin's calls to the `zle' builtin. The hijacking is to gather report data (which is used in unload). + ____ Has 36 line(s). Calls functions: :zinit-tmp-subst-zle + `-- .zinit-add-report Uses feature(s): _setopt_, _zle_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -:zinit-tmp-subst-zstyle -~~~~~~~~~~~~~~~~~~~~~~~ +==== :zinit-tmp-subst-zstyle ____ Function defined to hijack plugin's calls to the `zstyle' builtin. The hijacking is to gather report data (which is used in unload). + ____ Has 23 line(s). Calls functions: :zinit-tmp-subst-zstyle + `-- .zinit-add-report Uses feature(s): _setopt_, _zparseopts_, _zstyle_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -@autoload -~~~~~~~~~ +==== @autoload Has 4 line(s). Calls functions: @autoload `-- :zinit-tmp-subst-autoload |-- +zinit-message + |-- .zinit-add-report + |-- .zinit-any-to-user-plugin `-- is-at-least Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -@zinit-register-annex -~~~~~~~~~~~~~~~~~~~~~ +==== @zinit-register-annex ____ - ]]] Registers the z-annex inside Zinit – i.e. an Zinit extension + ____ Has 11 line(s). Doesn't call other functions. @@ -1109,12 +1333,12 @@ Uses feature(s): _setopt_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -@zinit-register-hook -~~~~~~~~~~~~~~~~~~~~ +==== @zinit-register-hook ____ Registers the z-annex inside Zinit (i.e., an Zinit extension) + ____ Has 6 line(s). Doesn't call other functions. @@ -1125,8 +1349,7 @@ Called by: Script-Body -@zinit-scheduler -~~~~~~~~~~~~~~~~ +==== @zinit-scheduler ____ @@ -1144,19 +1367,72 @@ ____ needs to install all turbo-mode plugins without any hesitation (delay), i.e. "burst" allows to run package installations from script, not from prompt. + ____ Has 75 line(s). *Is a precmd hook*. Calls functions: @zinit-scheduler + |-- .zinit-run-task + |   |-- .zinit-load + |   |   |-- +zinit-deploy-message + |   |   |-- .zinit-any-to-user-plugin + |   |   |-- .zinit-load-plugin + |   |   |   |-- .zinit-add-report + |   |   |   |-- .zinit-diff + |   |   |   |   |-- .zinit-diff-env + |   |   |   |   |-- .zinit-diff-functions + |   |   |   |   |-- .zinit-diff-options + |   |   |   |   `-- .zinit-diff-parameter + |   |   |   |-- .zinit-diff-env + |   |   |   |-- .zinit-find-other-matches + |   |   |   |-- .zinit-tmp-subst-off + |   |   |   |-- .zinit-tmp-subst-on + |   |   |   `-- :zinit-tmp-subst-autoload + |   |   |   |-- +zinit-message + |   |   |   |-- .zinit-add-report + |   |   |   |-- .zinit-any-to-user-plugin + |   |   |   `-- is-at-least + |   |   |-- .zinit-load-snippet + |   |   |   |-- +zinit-deploy-message + |   |   |   |-- +zinit-message + |   |   |   |-- .zinit-add-report + |   |   |   |-- .zinit-find-other-matches + |   |   |   |-- .zinit-get-object-path + |   |   |   |   `-- .zinit-any-to-user-plugin + |   |   |   |-- .zinit-pack-ice + |   |   |   |-- .zinit-set-m-func + |   |   |   |   `-- +zinit-message + |   |   |   |-- .zinit-setup-params + |   |   |   `-- zinit-install.zsh/.zinit-download-snippet + |   |   |-- .zinit-pack-ice + |   |   |-- .zinit-register-plugin + |   |   |   `-- +zinit-message + |   |   |-- .zinit-set-m-func + |   |   |   `-- +zinit-message + |   |   |-- .zinit-setup-params + |   |   |-- zinit-install.zsh/.zinit-get-package + |   |   `-- zinit-install.zsh/.zinit-setup-plugin-dir + |   |-- .zinit-load-snippet + |   |   |-- +zinit-deploy-message + |   |   |-- +zinit-message + |   |   |-- .zinit-add-report + |   |   |-- .zinit-find-other-matches + |   |   |-- .zinit-get-object-path + |   |   |   `-- .zinit-any-to-user-plugin + |   |   |-- .zinit-pack-ice + |   |   |-- .zinit-set-m-func + |   |   |   `-- +zinit-message + |   |   |-- .zinit-setup-params + |   |   `-- zinit-install.zsh/.zinit-download-snippet + |   `-- zinit-autoload.zsh/.zinit-unload `-- add-zsh-hook Uses feature(s): _add-zsh-hook_, _sched_, _setopt_, _zle_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -@zinit-substitute -~~~~~~~~~~~~~~~~~ +==== @zinit-substitute Has 40 line(s). Doesn't call other functions. @@ -1174,99 +1450,114 @@ Called by: zinit-install.zsh/∞zinit-make-base-hook zinit-install.zsh/∞zinit-mv-hook -_Environment variables used:_ ZPFX - -@zsh-plugin-run-on-unload -~~~~~~~~~~~~~~~~~~~~~~~~~ +==== @zsh-plugin-run-on-unload ____ The Plugin Standard required mechanism, see: https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html + ____ Has 2 line(s). Calls functions: @zsh-plugin-run-on-unload + `-- .zinit-pack-ice Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -@zsh-plugin-run-on-update -~~~~~~~~~~~~~~~~~~~~~~~~~ +==== @zsh-plugin-run-on-update ____ The Plugin Standard required mechanism + ____ Has 2 line(s). Calls functions: @zsh-plugin-run-on-update + `-- .zinit-pack-ice Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -pmodload -~~~~~~~~ +==== pmodload Has 15 line(s). Calls functions: pmodload + `-- .zinit-load-snippet + |-- +zinit-deploy-message + |-- +zinit-message + |-- .zinit-add-report + |-- .zinit-find-other-matches + |-- .zinit-get-object-path + |   `-- .zinit-any-to-user-plugin + |-- .zinit-pack-ice + |-- .zinit-set-m-func + |   `-- +zinit-message + |-- .zinit-setup-params + `-- zinit-install.zsh/.zinit-download-snippet Uses feature(s): _zstyle_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -zicdclear -~~~~~~~~~ +==== zicdclear ____ A wrapper for "zinit cdclear -q" which can be called from hook ices like the atinit"", atload"", etc. ices. + ____ Has 1 line(s). Calls functions: zicdclear + `-- .zinit-compdef-clear + `-- +zinit-message Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -zicdreplay -~~~~~~~~~~ +==== zicdreplay ____ A function that can be invoked from within "atinit", "atload", etc. ice-mod. It works like "zinit cdreplay", which cannot be invoked from such hook ices + ____ Has 1 line(s). Calls functions: zicdreplay + `-- .zinit-compdef-replay + `-- +zinit-message Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -zicompdef -~~~~~~~~~ +==== zicompdef ____ Stores compdef for a replay with "zicdreplay" (turbo mode) or with "zinit cdreplay" (normal mode). An utility functton of an undefined use case. + ____ Has 1 line(s). Doesn't call other functions. Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -zicompinit -~~~~~~~~~~ +==== zicompinit ____ A function that can be invoked from within "atinit", "atload", etc. ice-mod. It runs "autoload compinit; compinit" and respects ZINIT[ZCOMPDUMP_PATH] and ZINIT[COMPINIT_OPTS]. + ____ Has 2 line(s). Calls functions: @@ -1278,21 +1569,92 @@ Uses feature(s): _autoload_, _compinit_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -zinit -~~~~~ +==== zinit ____ Entrypoint function directly exposed to user, consumes subcommands with respective arguments, and completion. + ____ -Has 564 line(s). Calls functions: +Has 566 line(s). Calls functions: zinit |-- +zinit-message |-- +zinit-prehelp-usage-message |   `-- +zinit-message + |-- .zinit-add-fpath + |   `-- .zinit-any-to-user-plugin + |-- .zinit-compdef-clear + |   `-- +zinit-message + |-- .zinit-compdef-replay + |   `-- +zinit-message + |-- .zinit-get-object-path + |   `-- .zinit-any-to-user-plugin + |-- .zinit-ice + |-- .zinit-load-ices + |   `-- .zinit-get-object-path + |   `-- .zinit-any-to-user-plugin + |-- .zinit-load-object + |   |-- .zinit-load + |   |   |-- +zinit-deploy-message + |   |   |-- .zinit-any-to-user-plugin + |   |   |-- .zinit-load-plugin + |   |   |   |-- .zinit-add-report + |   |   |   |-- .zinit-diff + |   |   |   |   |-- .zinit-diff-env + |   |   |   |   |-- .zinit-diff-functions + |   |   |   |   |-- .zinit-diff-options + |   |   |   |   `-- .zinit-diff-parameter + |   |   |   |-- .zinit-diff-env + |   |   |   |-- .zinit-find-other-matches + |   |   |   |-- .zinit-tmp-subst-off + |   |   |   |-- .zinit-tmp-subst-on + |   |   |   `-- :zinit-tmp-subst-autoload + |   |   |   |-- +zinit-message + |   |   |   |-- .zinit-add-report + |   |   |   |-- .zinit-any-to-user-plugin + |   |   |   `-- is-at-least + |   |   |-- .zinit-load-snippet + |   |   |   |-- +zinit-deploy-message + |   |   |   |-- +zinit-message + |   |   |   |-- .zinit-add-report + |   |   |   |-- .zinit-find-other-matches + |   |   |   |-- .zinit-get-object-path + |   |   |   |   `-- .zinit-any-to-user-plugin + |   |   |   |-- .zinit-pack-ice + |   |   |   |-- .zinit-set-m-func + |   |   |   |   `-- +zinit-message + |   |   |   |-- .zinit-setup-params + |   |   |   `-- zinit-install.zsh/.zinit-download-snippet + |   |   |-- .zinit-pack-ice + |   |   |-- .zinit-register-plugin + |   |   |   `-- +zinit-message + |   |   |-- .zinit-set-m-func + |   |   |   `-- +zinit-message + |   |   |-- .zinit-setup-params + |   |   |-- zinit-install.zsh/.zinit-get-package + |   |   `-- zinit-install.zsh/.zinit-setup-plugin-dir + |   `-- .zinit-load-snippet + |   |-- +zinit-deploy-message + |   |-- +zinit-message + |   |-- .zinit-add-report + |   |-- .zinit-find-other-matches + |   |-- .zinit-get-object-path + |   |   `-- .zinit-any-to-user-plugin + |   |-- .zinit-pack-ice + |   |-- .zinit-set-m-func + |   |   `-- +zinit-message + |   |-- .zinit-setup-params + |   `-- zinit-install.zsh/.zinit-download-snippet + |-- .zinit-parse-opts + |-- .zinit-run + |   |-- +zinit-message + |   |-- .zinit-any-to-user-plugin + |   `-- .zinit-get-object-path + |   `-- .zinit-any-to-user-plugin + |-- .zinit-submit-turbo |-- compinit |-- zinit-additional.zsh/.zinit-clear-debug-report |-- zinit-additional.zsh/.zinit-debug-start @@ -1303,10 +1665,12 @@ Has 564 line(s). Calls functions: |-- zinit-autoload.zsh/.zinit-clear-completions |-- zinit-autoload.zsh/.zinit-compile-uncompile-all |-- zinit-autoload.zsh/.zinit-compiled + |-- zinit-autoload.zsh/.zinit-delete |-- zinit-autoload.zsh/.zinit-help |-- zinit-autoload.zsh/.zinit-list-bindkeys |-- zinit-autoload.zsh/.zinit-list-compdef-replay - |-- zinit-autoload.zsh/.zinit-ls + |-- zinit-autoload.zsh/.zinit-list-plugins + |-- zinit-autoload.zsh/.zinit-list-snippets |-- zinit-autoload.zsh/.zinit-module |-- zinit-autoload.zsh/.zinit-recently |-- zinit-autoload.zsh/.zinit-search-completions @@ -1314,7 +1678,6 @@ Has 564 line(s). Calls functions: |-- zinit-autoload.zsh/.zinit-show-all-reports |-- zinit-autoload.zsh/.zinit-show-completions |-- zinit-autoload.zsh/.zinit-show-debug-report - |-- zinit-autoload.zsh/.zinit-show-registered-plugins |-- zinit-autoload.zsh/.zinit-show-report |-- zinit-autoload.zsh/.zinit-show-times |-- zinit-autoload.zsh/.zinit-show-zstatus @@ -1335,34 +1698,35 @@ Called by: Script-Body zplugin + zinit-autoload.zsh/.zinit-delete -zpcdclear -~~~~~~~~~ +==== zpcdclear Has 1 line(s). Calls functions: zpcdclear + `-- .zinit-compdef-clear + `-- +zinit-message Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -zpcdreplay -~~~~~~~~~~ +==== zpcdreplay Has 1 line(s). Calls functions: zpcdreplay + `-- .zinit-compdef-replay + `-- +zinit-message Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -zpcompdef -~~~~~~~~~ +==== zpcompdef Has 1 line(s). Doesn't call other functions. Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -zpcompinit -~~~~~~~~~~ +==== zpcompinit Has 2 line(s). Calls functions: @@ -1373,8 +1737,7 @@ Uses feature(s): _autoload_, _compinit_ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -zplugin -~~~~~~~ +==== zplugin Has 1 line(s). Calls functions: @@ -1383,6 +1746,77 @@ Has 1 line(s). Calls functions: |-- +zinit-message |-- +zinit-prehelp-usage-message |   `-- +zinit-message + |-- .zinit-add-fpath + |   `-- .zinit-any-to-user-plugin + |-- .zinit-compdef-clear + |   `-- +zinit-message + |-- .zinit-compdef-replay + |   `-- +zinit-message + |-- .zinit-get-object-path + |   `-- .zinit-any-to-user-plugin + |-- .zinit-ice + |-- .zinit-load-ices + |   `-- .zinit-get-object-path + |   `-- .zinit-any-to-user-plugin + |-- .zinit-load-object + |   |-- .zinit-load + |   |   |-- +zinit-deploy-message + |   |   |-- .zinit-any-to-user-plugin + |   |   |-- .zinit-load-plugin + |   |   |   |-- .zinit-add-report + |   |   |   |-- .zinit-diff + |   |   |   |   |-- .zinit-diff-env + |   |   |   |   |-- .zinit-diff-functions + |   |   |   |   |-- .zinit-diff-options + |   |   |   |   `-- .zinit-diff-parameter + |   |   |   |-- .zinit-diff-env + |   |   |   |-- .zinit-find-other-matches + |   |   |   |-- .zinit-tmp-subst-off + |   |   |   |-- .zinit-tmp-subst-on + |   |   |   `-- :zinit-tmp-subst-autoload + |   |   |   |-- +zinit-message + |   |   |   |-- .zinit-add-report + |   |   |   |-- .zinit-any-to-user-plugin + |   |   |   `-- is-at-least + |   |   |-- .zinit-load-snippet + |   |   |   |-- +zinit-deploy-message + |   |   |   |-- +zinit-message + |   |   |   |-- .zinit-add-report + |   |   |   |-- .zinit-find-other-matches + |   |   |   |-- .zinit-get-object-path + |   |   |   |   `-- .zinit-any-to-user-plugin + |   |   |   |-- .zinit-pack-ice + |   |   |   |-- .zinit-set-m-func + |   |   |   |   `-- +zinit-message + |   |   |   |-- .zinit-setup-params + |   |   |   `-- zinit-install.zsh/.zinit-download-snippet + |   |   |-- .zinit-pack-ice + |   |   |-- .zinit-register-plugin + |   |   |   `-- +zinit-message + |   |   |-- .zinit-set-m-func + |   |   |   `-- +zinit-message + |   |   |-- .zinit-setup-params + |   |   |-- zinit-install.zsh/.zinit-get-package + |   |   `-- zinit-install.zsh/.zinit-setup-plugin-dir + |   `-- .zinit-load-snippet + |   |-- +zinit-deploy-message + |   |-- +zinit-message + |   |-- .zinit-add-report + |   |-- .zinit-find-other-matches + |   |-- .zinit-get-object-path + |   |   `-- .zinit-any-to-user-plugin + |   |-- .zinit-pack-ice + |   |-- .zinit-set-m-func + |   |   `-- +zinit-message + |   |-- .zinit-setup-params + |   `-- zinit-install.zsh/.zinit-download-snippet + |-- .zinit-parse-opts + |-- .zinit-run + |   |-- +zinit-message + |   |-- .zinit-any-to-user-plugin + |   `-- .zinit-get-object-path + |   `-- .zinit-any-to-user-plugin + |-- .zinit-submit-turbo |-- compinit |-- zinit-additional.zsh/.zinit-clear-debug-report |-- zinit-additional.zsh/.zinit-debug-start @@ -1393,10 +1827,12 @@ Has 1 line(s). Calls functions: |-- zinit-autoload.zsh/.zinit-clear-completions |-- zinit-autoload.zsh/.zinit-compile-uncompile-all |-- zinit-autoload.zsh/.zinit-compiled + |-- zinit-autoload.zsh/.zinit-delete |-- zinit-autoload.zsh/.zinit-help |-- zinit-autoload.zsh/.zinit-list-bindkeys |-- zinit-autoload.zsh/.zinit-list-compdef-replay - |-- zinit-autoload.zsh/.zinit-ls + |-- zinit-autoload.zsh/.zinit-list-plugins + |-- zinit-autoload.zsh/.zinit-list-snippets |-- zinit-autoload.zsh/.zinit-module |-- zinit-autoload.zsh/.zinit-recently |-- zinit-autoload.zsh/.zinit-search-completions @@ -1404,7 +1840,6 @@ Has 1 line(s). Calls functions: |-- zinit-autoload.zsh/.zinit-show-all-reports |-- zinit-autoload.zsh/.zinit-show-completions |-- zinit-autoload.zsh/.zinit-show-debug-report - |-- zinit-autoload.zsh/.zinit-show-registered-plugins |-- zinit-autoload.zsh/.zinit-show-report |-- zinit-autoload.zsh/.zinit-show-times |-- zinit-autoload.zsh/.zinit-show-zstatus @@ -1421,8 +1856,7 @@ Has 1 line(s). Calls functions: Not called by script or any function (may be e.g. a hook, a Zle widget, etc.). -add-zsh-hook -~~~~~~~~~~~~ +==== add-zsh-hook ____ @@ -1436,6 +1870,7 @@ ____ -D behaves like -d, but pattern characters are active in the function name, so any matching function will be deleted from the hook. + ____ Has 93 line(s). Doesn't call other functions. @@ -1447,8 +1882,22 @@ Called by: @zinit-scheduler Script-Body -compinit -~~~~~~~~ +==== colors + +____ + + Put standard ANSI color codes in shell parameters for easy use. + Note that some terminals do not support all combinations. + +____ + +Has 134 line(s). Doesn't call other functions. + +Called by: + + Script-Body + +==== compinit ____ @@ -1462,6 +1911,7 @@ ____ should be done with its contents: `#compdef ' + ____ Has 573 line(s). Doesn't call other functions. @@ -1474,8 +1924,7 @@ Called by: zinit zpcompinit -is-at-least -~~~~~~~~~~~ +==== is-at-least ____ @@ -1489,6 +1938,7 @@ ____ in the first argument that are present in the version string compared are considered as zeroes, eg 3 == 3.0 == 3.0.0 == 3.0.0.0 and so on. + ____ Has 56 line(s). Doesn't call other functions. diff --git a/tests/_support/gen-ghr-test b/tests/_support/gen-ghr-test new file mode 100755 index 000000000..38d16a14b --- /dev/null +++ b/tests/_support/gen-ghr-test @@ -0,0 +1,50 @@ +#!/usr/bin/env zsh +# +# Easily generate gh-r Zunit tests. +# +# Usage: +# gen-ghr-test [...] +# +# Note: Tests might require slight adjustments to the lbin or id-as ice +# +(){ + local flag_help + local -a usage=( + "gen-ghr-test [-h|--help]" + "gen-ghr-test []" + ) + + # -D pulls parsed flags out of $@ + # -E allows flags/args and positionals to be mixed, which we don't want in this example + # -F says fail if we find a flag that wasn't defined + # -M allows us to map option aliases (ie: h=flag_help -help=h) + # -K allows us to set default values without zparseopts overwriting them + # Remember that the first dash is automatically handled, so long options are -opt, not --opt + + zmodload zsh/zutil + zparseopts -D -F -K -- \ + {h,-help}=flag_help \ + || return 1 + + [[ -z "$flag_help" ]] || { print -l $usage; return 0 } + + (( !$# )) && { + builtin print -P -- "%F{red}Error%f gen-ghr-test requires one or more arguments" + return 1 + } + + local repo description bin_name + for repo in $@; do + bin_name="${repo:t}" + description="$(gh search repos "${repo}" --limit 1 --json description -q '.[].[]')" + cat <<- EOF +@test '${bin_name}' { # ${description} + run zinit for @${repo}; assert \$state equals 0 + local $bin_name="\$ZBIN/${bin_name}"; assert "\$${bin_name}" is_executable + run "\$${bin_name}" --version; assert \$state equals 0 +} +EOF + done +} $@ + +# vim: set expandtab filetype=zsh shiftwidth=2 softtabstop=2 tabstop=2: diff --git a/tests/commands.zunit b/tests/commands.zunit new file mode 100644 index 000000000..41041e55c --- /dev/null +++ b/tests/commands.zunit @@ -0,0 +1,38 @@ +#!/usr/bin/env zunit +# +# zdharma-continuum/zinit/tests/commands.zunit +# Copyright (c) 2016-2021 Sebastian Gniazdowski +# Copyright (c) 2021-2023 zdharma-continuum +# Homepage: https://github.com/zdharma-continuum/zinit +# License: MIT License +# + +@setup { + ZBIN="${ZPFX}/bin" +} +@test 'delete --help' { + run zinit delete --help + assert $output contains 'zinit delete [options] [plugins...]' + 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 +} +@test 'delete a snippet' { + run zinit id-as'git.zsh' is-snippet for @'OMZL::git.zsh' + run zinit delete --yes 'git.zsh' + assert $state equals 0 +} +@test 'delete a plugin' { + run zinit from'gh-r' as'program' id-as mv'shfmt* -> shfmt' for @'mvdan/sh' + run zinit delete --yes sh + assert $state equals 0 +} +@test 'delete a program' { + run zinit as'program' cp'wd.sh->wd' mv'_wd.sh->_wd' pick'wd' for @'mfaerevaag/wd' + run zinit delete --yes mfaerevaag/wd + assert $state equals 0 +} + +# vim:ft=zsh:sw=2:sts=2:et:foldmarker={,}:foldmethod=marker diff --git a/tests/gh-r.zunit b/tests/gh-r.zunit index ea3638d60..3b28aa634 100755 --- a/tests/gh-r.zunit +++ b/tests/gh-r.zunit @@ -1,17 +1,44 @@ #!/usr/bin/env zunit + @setup { + export ZBIN="${ZPFX}/bin" + export os_type="${OSTYPE//[0-9\.]*/}" zinit default-ice --quiet from'gh-r' nocompile lbin'!' - ZBIN="${ZPFX}/bin" } +# @test 'atmos' { Universal Tool for DevOps and Cloud Automation (works with terraform, helm, helmfile, etc) +# skip 'null' +# run zinit for lbin'!* -> atmos' @cloudposse/atmos; assert $state equals 0 +# local atmos="$ZBIN/atmos"; assert "$atmos" is_executable +# $atmos version; assert $state equals 0 +# } +# @test 'bit' { A tool for composable software development +# skip 'skip bit test due to gh-r version bug' +# run zinit lbin'!bit* -> bit' for @teambit/bit; assert $state equals 0 +# local bit="$ZBIN/bit"; assert "$bit" is_executable +# $bit --version; assert $state equals 0 +# } +# @test 'neovim::appimage' { # Vim-fork focused on extensibility and usability +# skip 'null' +# run zinit bpick'*appimage*' id-as'neovim/appimage' for neovim/neovim +# assert $state equals 0; assert $output contains 'nvim.appimage' +# assert "$ZINIT[PLUGINS_DIR]/neovim---appimage/nvim.appimage" is_file +# } +# @test 'neovim::binary' { # Vim-fork focused on extensibility and usability +# skip 'null' +# run zinit lbin'!**/nvim' id-as'neovim/binary' for neovim/neovim; assert $state equals 0; assert $output does_not_contain 'appimage' +# local nvim="$ZBIN/nvim"; assert "$nvim" is_executable +# $nvim --version; assert $state equals 0 +# } + @test 'act' { # Run your GitHub Actions locally run zinit for @nektos/act; assert $state equals 0 local act="$ZBIN/act"; assert "$act" is_executable $act --version; assert $state equals 0 } @test 'alacritty' { # Run your GitHub alacrittyions locally - [[ $OSTYPE =~ 'linux*' ]] && skip 'Alacritty test skipped on Linux/GNU' + [[ $OSTYPE =~ 'linux*' ]] && skip "Alacritty test skipped on $os_type" run zinit for @alacritty/alacritty; assert $state equals 0 local alacritty="$ZBIN/alacritty"; assert "$alacritty" is_executable $alacritty --version; assert $state equals 0 @@ -29,93 +56,91 @@ @test 'assh' { # make your ssh client smarter run zinit for @moul/assh; assert $state equals 0 local assh="$ZBIN/assh"; assert "$assh" is_executable - $assh --version; assert $state equals 0 -} -@test 'atmos' { # Universal Tool for DevOps and Cloud Automation (works with terraform, helm, helmfile, etc) - skip 'null' - # run zinit for lbin'!* -> atmos' @cloudposse/atmos; assert $state equals 0 - # local atmos="$ZBIN/atmos"; assert "$atmos" is_executable - # $atmos version; assert $state equals 0 + run $assh --version; assert $state equals 0 } @test 'atuin' { # Magical shell history - run zinit for @ellie/atuin; assert $state equals 0 + run zinit ver'v14.0.0' for @ellie/atuin; assert $state equals 0 local atuin="$ZBIN/atuin"; assert "$atuin" is_executable - $atuin --version; assert $state equals 0 + run $atuin --version; assert $state equals 0 } @test 'aurora' { # Cross-platform beanstalkd queue server admin console run zinit for @xuri/aurora; assert $state equals 0 local aurora="$ZBIN/aurora"; assert "$aurora" is_executable - $aurora -v; assert $state equals 0 + run $aurora -v; assert $state equals 0 } @test 'bandwhich' { # Terminal bandwidth utilization tool - [[ $OSTYPE =~ 'darwin*' ]] && skip 'Bandwhich test skipped on Darwin' + [[ $OSTYPE =~ 'darwin*' ]] && skip "on $os_type" run zinit for @imsnif/bandwhich; assert $state equals 0 local bandwhich="$ZBIN/bandwhich"; assert "$bandwhich" is_executable - $bandwhich --version; assert $state equals 0 + run $bandwhich --version; assert $state equals 0 } @test 'bat' { # A cat(1) clone with wings run zinit for @sharkdp/bat; assert $state equals 0 local bat="$ZBIN/bat"; assert "$bat" is_executable - $bat --version; assert $state equals 0 + run $bat --version; assert $state equals 0 } @test 'bazel' { # a fast, scalable, multi-language and extensible build system run zinit lbin"!bazel* -> bazel" for @bazelbuild/bazel; assert $state equals 0 local bazel="$ZBIN/bazel"; assert "$bazel" is_executable - $bazel --version; assert $state equals 0 -} -# TODO: gh-r does not find older assets anymore (possible bug from https://github.com/zdharma-continuum/zinit/pull/373) -@test 'bit' { # A tool for composable software development - skip 'skip bit test due to gh-r version bug' - run zinit lbin'!bit* -> bit' for @teambit/bit; assert $state equals 0 - local bit="$ZBIN/bit"; assert "$bit" is_executable - $bit --version; assert $state equals 0 + run $bazel --version; assert $state equals 0 } @test 'blast' { # Blast is a simple tool for API load testing and batch jobs - [[ $OSTYPE =~ 'darwin*' ]] && skip 'Blast test skipped on Darwin' + [[ $OSTYPE =~ 'darwin*' ]] && skip "on $os_type" run zinit for @dave/blast; assert $state equals 0 local blast="$ZBIN/blast"; assert "$blast" is_executable - $blast --dry=1; assert $state equals 0 + run $blast --dry=1; assert $state equals 0 } @test 'boilr' { # boilerplate template manager that generates files or directories from template repositories run zinit for @tmrts/boilr; assert $state equals 0 local boilr="$ZBIN/boilr"; assert "$boilr" is_executable [[ $OSTYPE =~ 'darwin*' ]] && assert "$output" contains "darwin_amd64" && pass - $boilr --help; assert $state equals 0 + run $boilr --help; assert $state equals 0 +} +@test 'booklit' { # a pretty lit content authoring system + run zinit for lbin'!* -> booklit' @vito/booklit; assert $state equals 0 + local booklit="$ZBIN/booklit"; assert "$booklit" is_executable + run "$booklit" --version; assert $state equals 0 } @test 'bottom' { # Yet another cross-platform graphical process/system monitor run zinit lbin'!**/btm' for ClementTsang/bottom; assert $state equals 0 local bottom="$ZBIN/btm"; assert "$bottom" is_executable $bottom --version; assert $state equals 0 } +@test 'broot' { # A new way to see and navigate directory trees + [[ $OSTYPE =~ 'darwin*' ]] && skip " on $os_type" + run zinit lbin'!*${OSTYPE}*/* -> broot' for @Canop/broot; assert $state equals 0 + local broot="$ZBIN/broot"; assert "$broot" is_executable + run "$broot" --version; assert $state equals 0 +} @test 'btop' { # A monitor of resources run zinit lbin'!**/btop' for aristocratos/btop; assert $state equals 0 local btop="$ZBIN/btop"; assert "$btop" is_executable - $btop --version; assert $state equals 0 + run $btop --version; assert $state equals 0 } @test 'calico' { # Cloud native networking and network security run zinit lbin"!* -> calico" for @projectcalico/calico; assert $state equals 0 local calico="$ZBIN/calico"; assert "$calico" is_executable - $calico --help; assert $state equals 0 + run $calico --help; assert $state equals 0 } @test 'certificates' { # An opinionated helper for generating tls certificates run zinit lbin"!* -> certificates" for @mvmaasakkers/certificates; assert $state equals 0 local certificates="$ZBIN/certificates"; assert "$certificates" is_executable - $certificates --version; assert $state equals 0 + run $certificates --version; assert $state equals 0 } @test 'checkmake' { # experimental linter/analyzer for Makefiles run zinit lbin'!checkmake* -> checkmake' for @mrtazz/checkmake; assert $state equals 0 local checkmake="$ZBIN/checkmake"; assert "$checkmake" is_executable - $checkmake --version; assert $state equals 0 + run $checkmake --version; assert $state equals 0 } @test 'cog' { # Containers for machine learning run zinit lbin'!cog* -> cog' for @replicate/cog; assert $state equals 0 local cog="$ZBIN/cog"; assert "$cog" is_executable - $cog --version; assert $state equals 0 + run $cog --version; assert $state equals 0 } @test 'compress' { # Optimized Go Compression Packages run zinit bpick'*.tar.gz' lbin'!s2c;s2d;s2sx;' for @klauspost/compress; assert $state equals 0 local compress="$ZBIN/s2c"; assert "$compress" is_executable - $compress --help; assert $state equals 0 + run $compress --help; assert $state equals 0 } @test 'create-go-app' { # Create a new production-ready project with backend, frontend and deploy automation by running one CLI command run zinit for id-as'cgapp' @create-go-app/cli; assert $state equals 0 @@ -133,6 +158,11 @@ local delta="$ZBIN/delta"; assert "$delta" is_executable $delta --version; assert $state equals 0 } +@test 'difftastic' { # A structural diff that understands syntax + run zinit id-as'difft' for @Wilfred/difftastic; assert $state equals 0 + local difftastic="$ZBIN/difft"; assert "$difftastic" is_executable + $difftastic --version; assert $state equals 0 +} @test 'dive' { # A tool for exploring each layer in a docker image run zinit for @wagoodman/dive; assert $state equals 0 local dive="$ZBIN/dive"; assert "$dive" is_executable @@ -149,10 +179,10 @@ $dc --version; assert $state equals 0 } @test 'docker-credential-helpers' { # A monitor of resources - [[ $OSTYPE =~ 'linux*' ]] && skip 'skipped on Linux' + [[ $OSTYPE =~ 'linux*' ]] && skip "on $os_type" run zinit for lbin'!* -> docker-credential-desktop' @docker/docker-credential-helpers; assert $state equals 0 local credential_desktop="$ZBIN/docker-credential-desktop"; assert "$credential_desktop" is_executable - $credential_desktop version; assert $state equals 0 + run $credential_desktop version; assert $state equals 0 } @test 'documize' { # Modern Confluence alternative designed for internal & external docs, built with Go & Ember JS run zinit lbin'!* -> documize' for @documize/community; assert $state equals 0 @@ -194,11 +224,22 @@ local exa="$ZBIN/exa"; assert "$exa" is_executable $exa --version; assert $state equals 0 } +@test 'fclones' { # Efficient duplicate file Finder + [[ $OSTYPE =~ 'darwin*' ]] && skip "on $os_type" + run zinit for @pkolaczk/fclones; assert $state equals 0 + local fclones="$ZBIN/fclones"; assert "$fclones" is_executable + run "$fclones" --help; assert $state equals 0 +} @test 'fd' { # A fast, simple, and user-friendly alternative to find run zinit for @sharkdp/fd; assert $state equals 0 local fd="$ZBIN/fd"; assert "$fd" is_executable $fd version; assert $state equals 0 } +@test 'fnm' { # Fast and simple Node.js version manager, built in Rust + run zinit for @Schniz/fnm; assert $state equals 0 + local fnm="$ZBIN/fnm"; assert "$fnm" is_executable + $fnm --version; assert $state equals 0 +} @test 'fogg' { # Manage Infrastructure as Code with less pain run zinit for @chanzuckerberg/fogg; assert $state equals 0 local fogg="$ZBIN/fogg"; assert "$fogg" is_executable @@ -215,7 +256,7 @@ $fzf --version; assert $state equals 0 } @test 'gaper' { # Builds and restarts a Go project when it crashes or some watched file changes - if [[ ! $OSTYPE =~ 'linux.*' ]]; then skip 'null'; fi + [[ $OSTYPE =~ "linux*" ]] && skip "on $os_type" run zinit lbin'!**/gaper' for @maxcnunes/gaper; assert $state equals 0 local gaper="$ZBIN/gaper"; assert "$gaper" is_executable $gaper --version; assert $state equals 0 @@ -231,7 +272,7 @@ $gf --version; assert $state equals 0 } @test 'ggsrun' { # This is a CLI tool to execute Google Apps Script (GAS) at own terminal on local PC. Also this CLI tool can be used for managing files in Google Drive for OAuth2 and Service Account - run zinit lbin'!* -> ggsrun' for @tanaikech/ggsrun; assert $state equals 0 + run zinit lbin'!* -> ggsrun' ver'v2.0.0' for @tanaikech/ggsrun; assert $state equals 0 local git_sizer="$ZBIN/ggsrun"; assert "$git_sizer" is_executable $git_sizer --version; assert $state equals 0 } @@ -302,7 +343,7 @@ $gomi --version; assert $state equals 0 } @test 'gosu' { # Simple Go-based setuid+setgid+setgroups+exec - if [[ $OSTYPE =~ 'darwin.*' ]]; then skip 'tianon/gosu only tested for Linux/GNU'; fi + [[ $OSTYPE =~ "darwin*" ]] && skip "on $os_type" run zinit lbin'!* -> gosu' for @tianon/gosu; assert $state equals 0 local gosu="$ZBIN/gosu"; assert "$gosu" is_executable $gosu --version; assert $state equals 0 @@ -335,11 +376,11 @@ @test 'hadolint' { # Dockerfile linter, validate inline bash, written in Haskell run zinit ver'v2.12.1-beta' lbin'!hadolint* -> hadolint' for @hadolint/hadolint; assert $state equals 0 local hadolint="$ZBIN/hadolint"; assert "$hadolint" is_executable - $hadolint --version; assert $state equals 0 + run $hadolint --version; assert $state equals 0 } # TODO: gh-r does not find older assets anymore (possible bug from https://github.com/zdharma-continuum/zinit/pull/373) @test 'heksa' { # CLI hex dumper with colors - if [[ $OSTYPE =~ 'darwin.*' ]]; then skip 'heksa only tested for Linux/GNU'; fi + [[ $OSTYPE =~ "darwin*" ]] && skip "on $os_type" run zinit for @raspi/heksa; assert $state equals 0 local heksa="$ZBIN/heksa"; assert "$heksa" is_executable $heksa --version; assert $state equals 0 @@ -365,11 +406,16 @@ $hoofli -h; assert $state equals 0 } @test 'hors' { # instant coding answers via the command line - if [[ $OSTYPE =~ 'linux.*' ]]; then skip 'WindSoilder/hors only tested for macOS'; fi + [[ $OSTYPE =~ "linux*" ]] && skip "skipped on $os_type" run zinit for @WindSoilder/hors; assert $state equals 0 local hors="$ZBIN/hors"; assert "$hors" is_executable $hors --version; assert $state equals 0 } +@test 'htmlq' { # Like jq, but for HTML + run zinit for @mgdm/htmlq; assert $state equals 0 + local htmlq="$ZBIN/htmlq"; assert "$htmlq" is_executable + run "$htmlq" --version; assert $state equals 0 +} @test 'hyperfine' { # A command-line benchmarking tool run zinit bpick'*tar.gz*' for @sharkdp/hyperfine; assert $state equals 0 local hyperfine="$ZBIN/hyperfine"; assert "$hyperfine" is_executable @@ -401,7 +447,7 @@ $just --version; assert $state equals 0 } @test 'keepassxc' { # a cross-platform community-driven port of the Windows application Keepass Password Safe - [[ $OSTYPE =~ 'linux.*' ]] && skip 'null' + [[ $OSTYPE =~ 'linux*' ]] && skip "skipped on $os_type" run zinit for @keepassxreboot/keepassxc; assert $state equals 0 local keepassxc="$ZBIN/keepassxc"; assert "$keepassxc" is_executable $keepassxc -v; assert $state equals 0 @@ -426,34 +472,51 @@ $kopia --version; assert $state equals 0 local lazygit="$ZBIN/lazygit"; assert "$lazygit" is_executable $lazygit --version; assert $state equals 0 } +@test 'lemmeknow' { # The fastest way to identify anything + run zinit lbin'!* -> lemmeknow' for @swanandx/lemmeknow; assert $state equals 0 + local lemmeknow="$ZBIN/lemmeknow"; assert "$lemmeknow" is_executable + run "$lemmeknow" --version; assert $state equals 0 +} @test 'lf' { # Terminal file manager run zinit for @gokcehan/lf; assert $state equals 0 local lf="$ZBIN/lf"; assert "$lf" is_executable $lf -version; assert $state equals 0 } -@test 'lsd' { # The next gen ls command - run zinit for @Peltoche/lsd; assert $state equals 0 - local lsd="$ZBIN/lsd"; assert "$lsd" is_executable - $lsd --version; assert $state equals 0 +@test 'lfs' { # A linux utility to get information on filesystems, like df but better + [[ $OSTYPE =~ 'darwin*' ]] && skip "skipped on $os_type" + run zinit lbin'!**/x86_64-linux/* -> lfs' for @Canop/lfs; assert $state equals 0 + local lfs="$ZBIN/lfs"; assert "$lfs" is_executable + run $lfs --version; assert $state equals 0 } @test 'lnav' { # advanced log file viewer run zinit for @tstack/lnav; assert $state equals 0 local lnav="$ZBIN/lnav"; assert "$lnav" is_executable $lnav --version; assert $state equals 0 } +@test 'lsd' { # The next gen ls command + run zinit for @lsd-rs/lsd; assert $state equals 0 + local lsd="$ZBIN/lsd"; assert "$lsd" is_executable + $lsd --version; assert $state equals 0 +} @test 'lstf' { # The aggregated TCP flows printer in Linux - [[ ! $OSTYPE =~ 'linux.*' ]] && skip 'null' + [[ $OSTYPE =~ 'darwin*' ]] && skip "skipped on $os_type" run zinit for @yuuki/lstf; assert $state equals 0 local lstf="$ZBIN/lstf"; assert "$lstf" is_executable $lstf --version; assert $state equals 0 } +@test 'macchina' { # A system information frontend with an emphasis on performance + [[ $OSTYPE =~ 'darwin*' ]] && skip "skipped on $os_type" + run zinit lbin'!* -> macchina' for @macchina-cli/macchina; assert $state equals 0 + local macchina="$ZBIN/macchina"; assert "$macchina" is_executable + run $macchina --version; assert $state equals 0 +} @test 'mage' { # A Make/rake-like dev tool using Go run zinit for @magefile/mage; assert $state equals 0 local mage="$ZBIN/mage"; assert "$mage" is_executable $mage -version; assert $state equals 0 } @test 'mas' { # Mac App Store command line interface - [[ ! $OSTYPE =~ 'darwin.*' ]] && skip 'null' + [[ $OSTYPE =~ 'linux*' ]] && skip "skipped on $os_type" run zinit lbin'!**/bin/mas' for @mas-cli/mas; assert $state equals 0 local mas="$ZBIN/mas"; assert "$mas" is_executable $mas version; assert $state equals 0 @@ -463,11 +526,22 @@ $kopia --version; assert $state equals 0 local mdbook="$ZBIN/mdbook"; assert "$mdbook" is_executable $mdbook --version; assert $state equals 0 } +@test 'mdcat' { # cat for markdown + run zinit for @swsnr/mdcat; assert $state equals 0 + local mdcat="$ZBIN/mdcat"; assert "$mdcat" is_executable + run "$mdcat" --version; assert $state equals 0 +} @test 'micro' { # A modern and intuitive terminal-based text editor run zinit for @zyedidia/micro; assert $state equals 0 local micro="$ZBIN/micro"; assert "$micro" is_executable $micro --version; assert $state equals 0 } +@test 'miniserve' { # For when you really just want to serve some files over HTTP right now! + [[ $OSTYPE =~ 'darwin*' ]] && skip "skipped on $os_type" + run zinit lbin'!* -> miniserve' for @svenstaro/miniserve; assert $state equals 0 + local miniserve="$ZBIN/miniserve"; assert "$miniserve" is_executable + run $miniserve --help; assert $state equals 0 +} @test 'mkcert' { # A simple zero-config tool to make locally trusted development certificates run zinit lbin'!* -> mkcert' for @FiloSottile/mkcert; assert $state equals 0 local mkcert="$ZBIN/mkcert"; assert "$mkcert" is_executable @@ -493,6 +567,12 @@ $kopia --version; assert $state equals 0 local mocword="$ZBIN/mocword"; assert "$mocword" is_executable $mocword --version; assert $state equals 0 } +@test 'monolith' { # CLI tool for saving complete web pages as a single HTML file + [[ $OSTYPE =~ 'darwin*' ]] && skip "skipped on $os_type" + run zinit lbin'!* -> monolith' for @Y2Z/monolith; assert $state equals 0 + local monolith="$ZBIN/monolith"; assert "$monolith" is_executable + run $monolith --version; assert $state equals 0 +} @test 'moonwalk' { # Cover your tracks during Linux Exploitation by leaving zero traces on system logs and filesystem timestamps run zinit lbin'!**/moonwalk* -> moonwalk' for @mufeedvh/moonwalk; assert $state equals 0 local moonwalk="$ZBIN/moonwalk"; assert "$moonwalk" is_executable @@ -503,119 +583,148 @@ $kopia --version; assert $state equals 0 local navi="$ZBIN/navi" && assert "$navi" is_executable $navi --version && assert $state equals 0 } -@test 'neovim::appimage' { # Vim-fork focused on extensibility and usability - skip 'null' - run zinit bpick'*appimage*' id-as'neovim/appimage' for neovim/neovim - assert $state equals 0; assert $output contains 'nvim.appimage' - assert "$ZINIT[PLUGINS_DIR]/neovim---appimage/nvim.appimage" is_file -} -@test 'neovim::binary' { # Vim-fork focused on extensibility and usability - skip 'null' - run zinit lbin'!**/nvim' id-as'neovim/binary' for neovim/neovim; assert $state equals 0; assert $output does_not_contain 'appimage' - local nvim="$ZBIN/nvim"; assert "$nvim" is_executable - $nvim --version; assert $state equals 0 -} @test 'onefetch' { # Git repository summary on your terminal run zinit for @o2sh/onefetch; assert $state equals 0 local onefetch="$ZBIN/onefetch"; assert "$onefetch" is_executable $onefetch --version; assert $state equals 0 } +@test 'ouch' { # Painless compression and decompression for your terminal + run zinit for @ouch-org/ouch; assert $state equals 0 + local ouch="$ZBIN/ouch"; assert "$ouch" is_executable + run "$ouch" --help; assert $state equals 0 +} +@test 'pastel' { # A command-line tool to generate, analyze, convert and manipulate colors + run zinit for @sharkdp/pastel; assert $state equals 0 + local pastel="$ZBIN/pastel"; assert "$pastel" is_executable + run "$pastel" --version; assert $state equals 0 +} @test 'peco' { # Simplistic interactive filtering tool run zinit for @peco/peco; assert $state equals 0 local peco="$ZBIN/peco"; assert "$peco" is_executable - $peco --version; assert $state equals 0 + run $peco --version; assert $state equals 0 } @test 'piknik' { # Copy/paste anything over the network run zinit for @jedisct1/piknik; assert $state equals 0 local piknik="$ZBIN/piknik"; assert "$piknik" is_executable - $piknik --version; assert $state equals 0 + run $piknik --version; assert $state equals 0 +} +@test 'pipr' { # A tool to interactively write shell pipelines. + [[ $OSTYPE =~ 'darwin*' ]] && skip "skipped on $os_type" + run zinit for @Elkowar/pipr; assert $state equals 0 + local pipr="$ZBIN/pipr"; assert "$pipr" is_executable + run "$pipr" --help; assert $state equals 0 } @test 'pmy' { # General purpose context-aware zsh completion engine powered by fuzzy finder run zinit for @relastle/pmy; assert $state equals 0 local pmy="$ZBIN/pmy"; assert "$pmy" is_executable - $pmy --version; assert $state equals 0 + run "$pmy" --version; assert $state equals 0 } @test 'procs' { # A modern replacement for ps written in Rust run zinit for @dalance/procs; assert $state equals 0 local procs="$ZBIN/procs"; assert "$procs" is_executable - $procs --version; assert $state equals 0 + run "$procs" --version; assert $state equals 0 } @test 'pulumi' { # A modern replacement for ps written in Rust run zinit for @pulumi/pulumi; assert $state equals 0 local pulumi="$ZBIN/pulumi"; assert "$pulumi" is_executable - $pulumi version; assert $state equals 0 + run "$pulumi" version; assert $state equals 0 +} +@test 'qsv' { # CSVs sliced, diced & analyzed. + run zinit for @jqnatividad/qsv; assert $state equals 0 + local qsv="$ZBIN/qsv"; assert "$qsv" is_executable + run "$qsv" --version; assert $state equals 0 } @test 'rare' { # Realtime regex-extraction and aggregation into common formats such as histograms, bar graphs, tables, etc run zinit for @zix99/rare; assert $state equals 0 local rare="$ZBIN/rare"; assert "$rare" is_executable - $rare --version; assert $state equals 0 + run "$rare" --version; assert $state equals 0 +} +@test 'rargs' { # xargs + awk with pattern matching support + run zinit for @lotabout/rargs; assert $state equals 0 + local rargs="$ZBIN/rargs"; assert "$rargs" is_executable + run "$rargs" --version; assert $state equals 0 } @test 'rclone' { # Realtime regex-extraction and aggregation into common formats such as histograms, bar graphs, tables, etc run zinit for @rclone/rclone; assert $state equals 0 local rclone="$ZBIN/rclone"; assert "$rclone" is_executable - $rclone --version; assert $state equals 0 + run "$rclone" --version; assert $state equals 0 } @test 'reg' { # Docker registry v2 command line client and repo listing generator with security checks run zinit lbin'!* -> reg' for @genuinetools/reg; assert $state equals 0 local reg="$ZBIN/reg"; assert "$reg" is_executable - $reg version; assert $state equals 0 + run "$reg" version; assert $state equals 0 } # TODO: gh-r does not find older assets anymore (possible bug from https://github.com/zdharma-continuum/zinit/pull/373) @test 'rip' { # A safe and ergonomic alternative to rm run zinit ver'0.11.3' for @nivekuil/rip; assert $state equals 0 local rip="$ZBIN/rip"; assert "$rip" is_executable - $rip --version; assert $state equals 0 + run "$rip" --version; assert $state equals 0 } -@test 'ripgrep' { # ripgrep recursively searches directories for a regex pattern while respecting your gitignore +@test 'ripgrep' { # Recursively searches directories for a regex pattern while respecting your gitignore run zinit lbin'!**/rg' for @BurntSushi/ripgrep; assert $state equals 0 local rg="$ZBIN/rg"; assert "$rg" is_executable - $rg --version; assert $state equals 0 + run "$rg" --version; assert $state equals 0 } -@test 'ripgrep-prebuilt' { # ripgrep recursively searches directories for a regex pattern while respecting your gitignore - run zinit lbin'!**/rg' for @BurntSushi/ripgrep; assert $state equals 0 - local rg="$ZBIN/rg"; assert "$rg" is_executable - $rg --version; assert $state equals 0 +@test 'ripsecrets' { # A command-line tool to prevent committing secret keys into your source code + run zinit for @sirwart/ripsecrets; assert $state equals 0 + local ripsecrets="$ZBIN/ripsecrets"; assert "$ripsecrets" is_executable + run "$ripsecrets" --version; assert $state equals 0 +} +@test 'rnr' { # A command-line tool to batch rename files and directories + run zinit for @ismaelgv/rnr; assert $state equals 0 + local rnr="$ZBIN/rnr"; assert "$rnr" is_executable + run "$rnr" --version; assert $state equals 0 } @test 'rust-analyzer' { # A Rust compiler front-end for IDEs - [[ $OSTYPE =~ 'linux*' ]] && skip 'rust-analyzer test skipped on Linux' + [[ $OSTYPE =~ "linux*" ]] && skip "skipped on $os_type" run zinit lbin'!* -> rust-analyzer' for @rust-lang/rust-analyzer; assert $state equals 0 local rust_analyzer="$ZBIN/rust-analyzer"; assert "$rust_analyzer" is_executable - $rust_analyzer --version; assert $state equals 0 + run "$rust_analyzer" --version; assert $state equals 0 } @test 's' { # Open a web search in your terminal run zinit for @zquestz/s; assert $state equals 0 local s="$ZBIN/s"; assert "$s" is_executable - $s --version; assert $state equals 0 + run "$s" --version; assert $state equals 0 } -@test 'sd' { # Intuitive find & replace CLI (sed alternative) +@test 'sd' { # Intuitive find & replace CLI a.k.a modern sed run zinit lbin'!sd* -> sd' for @chmln/sd; assert $state equals 0 local sd="$ZBIN/sd"; assert "$sd" is_executable - $sd --version; assert $state equals 0 + run "$sd" --version; assert $state equals 0 } @test 'shellcheck' { # a static analysis tool for shell scripts run zinit for @koalaman/shellcheck; assert $state equals 0 local shellcheck="$ZBIN/shellcheck"; assert "$shellcheck" is_executable - $shellcheck --version; assert $state equals 0 + run "$shellcheck" --version; assert $state equals 0 } -@test 'shfmt' { # A shell parser, formatter, and interpreter with bash support; includes shfmt +@test 'shfmt' { # A shell parser, formatter, and interpreter with bash support run zinit lbin'!**/sh* -> shfmt' for @mvdan/sh; assert $state equals 0 local shfmt="$ZBIN/shfmt"; assert "$shfmt" is_executable - $shfmt --version; assert $state equals 0 + run $shfmt --version; assert $state equals 0 +} +@test 'skim' { # Fuzzy Finder in rust + run zinit ver'v0.9.4' for @lotabout/skim; assert $state equals 0 + local skim="$ZBIN/sk"; assert "$skim" is_executable + run "$skim" --version; assert $state equals 0 } @test 'starship' { # The minimal, blazing-fast, and infinitely customizable prompt for any shell run zinit for @starship/starship; assert $state equals 0 local starship="$ZBIN/starship"; assert "$starship" is_executable - $starship --version; assert $state equals 0 + run "$starship" --version; assert $state equals 0 } @test 'stern' { # Multi pod and container log tailing for Kubernetes run zinit for @stern/stern; assert $state equals 0 local stern="$ZBIN/stern"; assert "$stern" is_executable - $stern --version; assert $state equals 0 + run "$stern" --version; assert $state equals 0 } @test 'tealdeer' { # A very fast implementation of tldr in Rust run zinit lbin'!tealdeer* -> tealdeer' for @dbrgn/tealdeer; assert $state equals 0 local tealdeer="$ZBIN/tealdeer"; assert "$tealdeer" is_executable - $tealdeer --version; assert $state equals 0 + run "$tealdeer" --version; assert $state equals 0 +} +@test 'tin-summer' { # Find build artifacts that are taking up disk space + run zinit for @vmchale/tin-summer; assert $state equals 0 + local tin_summer="$ZBIN/sn"; assert "$tin_summer" is_executable + run "$tin_summer" --version; assert $state equals 0 } @test 'tokei' { # Count your code, quickly. run zinit lbin'!*tokei -> tokei' ver'v12.1.1' for @XAMPPRocky/tokei; assert $state equals 0 @@ -648,6 +757,11 @@ $kopia --version; assert $state equals 0 local volta="$ZBIN/volta"; assert "$volta" is_executable run $volta --version; assert $state equals 0 } +@test 'watchexec' { # Executes commands in response to file modifications + run zinit for @watchexec/watchexec; assert $state equals 0 + local watchexec="$ZBIN/watchexec"; assert "$watchexec" is_executable + run "$watchexec" --version; assert $state equals 0 +} @test 'whalebrew' { # Homebrew, but with Docker images run zinit lbin'!* -> whalebrew' for whalebrew/whalebrew; assert $state equals 0 local whalebrew="$ZBIN/whalebrew"; assert "$whalebrew" is_executable @@ -668,6 +782,11 @@ $kopia --version; assert $state equals 0 local xh="$ZBIN/xh"; assert "$xh" is_executable run $xh --version; assert $state equals 0 } +@test 'xsv' { # A fast CSV command line toolkit written in Rust. + run zinit for @BurntSushi/xsv; assert $state equals 0 + local xsv="$ZBIN/xsv"; assert "$xsv" is_executable + run "$xsv" --version; assert $state equals 0 +} @test 'yabai' { # A tiling window manager for macOS based on binary space partitioning [[ $OSTYPE =~ 'linux*' ]] && skip 'Yabai skipped on Linux' run zinit for @koekeishiya/yabai; assert $state equals 0 @@ -687,7 +806,7 @@ $kopia --version; assert $state equals 0 @test 'zoxide' { # A smarter cd command run zinit for @ajeetdsouza/zoxide; assert $state equals 0 local zoxide="$ZBIN/zoxide"; assert "$zoxide" is_executable - $zoxide --version; assert $state equals 0 + run $zoxide --version; assert $state equals 0 } # vim:ft=zsh:sw=2:sts=2:et:foldmarker={,}:foldmethod=marker diff --git a/tests/plugins.zunit b/tests/plugins.zunit index e30bda8cd..251bb23a1 100755 --- a/tests/plugins.zunit +++ b/tests/plugins.zunit @@ -37,6 +37,12 @@ local vim="$ZBIN/vim"; assert $vim is_executable $vim --version; assert $state equals 0 } +@test 'zsh-completions' { + run zinit light-mode for zsh-users/zsh-completions + zinit cd zsh-users/zsh-completions + run zinit creinstall -q .; assert $state equals 0 + local broken_completions=($(echo "$ZINIT[COMPLETIONS_DIR]"/*(-@))); assert "${#broken_completions[@]}" equals 0 +} # @test 'zsh_bin' { # run zinit as'null' sbin'bin/zsh' for @romkatv/zsh-bin # assert $state equals 0 diff --git a/zi-browse-symbol b/zi-browse-symbol index b33ab32b0..004588465 100644 --- a/zi-browse-symbol +++ b/zi-browse-symbol @@ -31,7 +31,7 @@ zmodload zsh/termcap 2>/dev/null typeset -gA TAG integer -g __tfind_spe_index -integer -g __tfind_spe_restart __tfind_spe_call_count __tfind_spe_funct +integer -g __tfind_spe_restart __tfind_spe_call_count __tfind_spe_funct __tfind_spe_sort typeset -g __tfind_page_size __tfind_high_color __tfind_heading_color \ __tfind_title_color __tfind_arrow_color __tfind_func_color \ __tfind_var_color __tfind_eqdol_color __tfind_macro_color @@ -47,21 +47,15 @@ trap '(( __tfind_spe_call_count -- )); return 0;' INT _tfind_find_index() { local q + local -a p # Read tags file - if [[ -f ./TAGS ]]; then - TAG[file]=$PWD/TAGS - # Save current project name - TAG[git-or-project]="$PWD:t" - elif [[ -f ../TAGS ]]; then - TAG[file]=$PWD:h/TAGS - # Save current project name - TAG[git-or-project]="$PWD:h:t" - elif [[ -f ../../TAGS ]]; then - TAG[file]=$PWD:h:h/TAGS - # Save current project name - TAG[git-or-project]="$PWD:h:h:t" + p=( (../)#TAGS(N) ) + TAG[file]=${${(On)p}[1]} + [[ -f ./TAGS ]] && TAG[file]=$PWD/TAGS + if [[ -n $TAG[file] ]]; then + TAG[git-or-project]=${${TAG[file]:a}:h:t} else - [[ -z $TAG[file] ]] && TAG[git-or-project]="" + TAG[git-or-project]="" #TAG[file]= fi @@ -78,17 +72,18 @@ _tfind_find_index() { fi # Read index, and as index is found, establish git main dir for it - __tfind_outside_git= + __tfind_outside_git=$TAG[file]:h if [[ -n $TAG[file] && -f $TAG[file-pp] ]]; then __tfind_tag_data=( ${"${(@f)"$(<${TAG[file-pp]})"}"##[[:space:]]##} ) # Cleanup functions and their preambles __tfind_tag_data=( ${__tfind_tag_data[@]/(#b)(\([^\)]#\))[[:space:]]#[\{]*($'\x7f')/$match[1]$match[2]} ) __tfind_tag_data=( ${__tfind_tag_data[@]/(#b)[[:space:]]\#*($'\x7f')/$match[1]} ) - __tfind_outside_git="${PWD%/${$(git rev-parse --show-prefix)%/}}" + __tfind_outside_git="${PWD%/${$(git rev-parse --quiet --show-prefix 2>/dev/null)%/}}" if [[ -d $__tfind_outside_git && -n ${${(M)PWD##$__tfind_outside_git}##$HOME} ]]; then TAG[git-or-project]=$__tfind_outside_git:t TAG[repo-dir]=$__tfind_outside_git else + TAG[git-or-project]=$TAG[file]:h TAG[repo-dir]=$TAG[file]:h fi return 0 @@ -105,6 +100,8 @@ _tfind_error_msg() elif [[ $#__tfind_tag_data -eq 0 ]]; then POSTDISPLAY=$'\n'"The index file contains NO symbol data, forced sleeping..." local search_buffer= + elif [[ $#__tfind_spe_found -eq 0 && $search_buffer == [[:space:]]# ]]; then + POSTDISPLAY=$'\n'"No items found" elif [[ $search_buffer != [[:space:]]# && $#__tfind_spe_found -eq 0 ]]; then POSTDISPLAY=$'\n'"Found 0 matches for query: $search_buffer" else @@ -137,8 +134,8 @@ _tfind_main() { zstyle -s ":plugin:zinit:symbol-search" macro-color __tfind_macro_color || __tfind_macro_color="fg=208,bold" zstyle -s ":plugin:zinit:symbol-search" eqdol-color __tfind_eqdol_color || __tfind_eqdol_color="fg=69,bold" - # Find the index to operate on, git dir, etc. - _tfind_find_index || { _tfind_error_msg; return;} + # Find the index to operate on, git dir, etc. + _tfind_find_index || { _tfind_error_msg && return;} fi # '0' will get changed into $to_display limit @@ -166,11 +163,12 @@ _tfind_main() { repeat 1; do # Match only before ^? ($'\177') __tfind_spe_found=( "${(@M)__tfind_tag_data:#(#i)$~search_pattern*$'\177'*}" ) - (( __tfind_spe_funct )) && __tfind_spe_found=( ${(M)__tfind_spe_found:#[[:alnum:]$TAG[fun-xt-chars]]##[[:space:]]#\([^\)]#\)[[:space:]]#(\{|)*} ) + ((__tfind_spe_funct)) && __tfind_spe_found=(${(M)__tfind_spe_found:#[[:alnum:]$TAG[fun-xt-chars]]##[[:space:]]#\([^\)]#\)[[:space:]]#(\{|)*}) + ((__tfind_spe_sort)) && __tfind_spe_found=(${(no)__tfind_spe_found}) done fi - if [[ $#__tfind_spe_found -eq 0 ]]; then + if ((!$#__tfind_spe_found)); then _tfind_error_msg && return fi @@ -217,8 +215,8 @@ _tfind_main() { # Colorify # local noun=${${${__tfind_spe_funct:#0}:+function}:-symbol} - local preamble=$'\n'"View of ${noun}s for repo: «««$TAG[git-or-project]»»» located at: $__tfind_outside_git:h"$'\n'"${(C)noun} no. #$__tfind_spe_index. Found $max_index ${noun}s in the index."$'\n' \ - key="Ctrl-F to toggle functions-ONLY view."$'\n' + local preamble=$'\n'"View of ${noun}s for repo: «««${(U)TAG[git-or-project]}»»» located at: $TAG[repo-dir]:h"$'\n'"${(C)noun} no. #$__tfind_spe_index. Found $max_index ${noun}s in the index."$'\n' \ + key="Ctrl-f to toggle functions-ONLY view. Alt-s to toggle sort."$'\n' preamble+=$key local text="${(F)disp_list}" @@ -228,9 +226,9 @@ _tfind_main() { region_highlight=( "$(( offset + ${#txt_before} )) $(( offset + ${#txt_before} + ${#entry} + 1 )) underline" ) - color_att() { local c;if (($4==0)){c=$__tfind_title_color;} elif (($4==1)){c=$__tfind_high_color;} elif (($4==4)){c=$__tfind_var_color;} elif (($4==7)){c=$__tfind_func_color;} elif (($4==9)){c=$__tfind_eqdol_color;} elif (($4==10)){c=$__tfind_macro_color;} else {c=$__tfind_arrow_color;}; region_highlight+=("$(($1+$2-1)) $(($1+$3)) $c"); } + color_att() { local c;if (($4==0)){c=$__tfind_title_color;} elif (($4==1)){c=$__tfind_high_color;} elif (($4==4)){c=$__tfind_var_color;} elif (($4==7)){c=$__tfind_func_color;} elif (($4==9)){c=$__tfind_eqdol_color;} elif (($4==10)){c=$__tfind_macro_color;} else {c=$__tfind_arrow_color;}; region_highlight_+=("$(($1+$2-1)) $(($1+$3)) $c"); } functions -M coloratt 4 4 color_att - + local -a region_highlight_ # Also highlight project name local h="$(( 30+buflen+__tfind_spe_funct*2 )) $(( 30+$buflen+${#TAG[git-or-project]}+__tfind_spe_funct*2 )) $__tfind_title_color" local q="$buflen $offset $__tfind_heading_color" @@ -238,7 +236,8 @@ _tfind_main() { : "${preamble//(#b)no. ([^.]##)./$((coloratt(buflen,mbegin[1],mend[1],0)))}" : "${preamble//(#b)Found ([0-9]##)/$((coloratt(buflen,mbegin[1],mend[1],1)))}" : "${preamble//(#b)» located at: ([^$p]##)/$((coloratt(buflen,mbegin[1],mend[1],1)))}" - : "${preamble//(#b)(Ctrl-F)/$((coloratt(buflen,mbegin[1],mend[1],0)))}" + : "${preamble//(#b)(Ctrl-f)/$((coloratt(buflen,mbegin[1],mend[1],0)))}" + : "${preamble//(#b)(Alt-s)/$((coloratt(buflen,mbegin[1],mend[1],0)))}" : "${text//((#s)|$p)(#b)(»)/$((coloratt(offset,mbegin[1],mend[1],3)))}" # Basic syntax highlighting - a few keywords like C/Java type names : "${text//(#b)((([[:space:]\(\{\[]int|double|enum|short|long|(u|w|g|gu)(int|char|long|short)(8|16|32|64|128|max|)(_t|)|char|(|un)signed|FILE|const|restrict|size_t|va_list|ptrdiff_t|off_t|gboolean|gpointer|gconstpointer|typedef|static|struct|union)[[:space:]])|[a-zA-Z_]##_t|local|integer|float|declare|typeset|readonly)/$((coloratt(offset,mbegin[1],mend[1],4)))}" @@ -251,8 +250,9 @@ _tfind_main() { : "${(f)${(S)text//*(#bi)(${~csearch_pattern})/$((coloratt(offset,mbegin[1],mend[1],1)))}}" fi - functions +M color_att - unfunction color_att + functions +M color_att + unfunction color_att + region_highlight+=( $region_highlight_ ) } @@ -261,6 +261,11 @@ _tfind_functions() { __tfind_spe_restart=1 _tfind_simulate_widget } +_tfind_sort() { + __tfind_spe_sort=1-__tfind_spe_sort + __tfind_spe_restart=1 + _tfind_simulate_widget +} _tfind_simulate_widget() { (( __tfind_spe_call_count ++ )) _tfind_main @@ -369,6 +374,7 @@ if [[ $__tfind_spe_call_count -eq 1 ]]; then zle -N backward-delete-char _tfind_backward_delete_char zle -N delete-char _tfind_delete_char zle -N tfind-functions _tfind_functions + zle -N tfind-sort _tfind_sort # Override ourselves with what we actually are # because zsh-autosuggestions change us @@ -394,12 +400,13 @@ if [[ $__tfind_spe_call_count -eq 1 ]]; then zle -N _tfind_cancel_accept bindkey -M tfind "^[" _tfind_cancel_accept bindkey -M tfind "^f" tfind-functions + bindkey -M tfind "\es" tfind-sort local redrawbkp=0 # Trap INT to manually interrupt Zle to work around a bug trap 'zle && zle .send-break' INT if zle .recursive-edit -K tfind; then - if [[ $__tfind_spe_index -lt 0 ]]; then + if ((__tfind_spe_index<=0)); then : else zstyle -s ":plugin:zinit:symbol-search" editor selected_editor || selected_editor=${VISUAL:-${EDITOR:-mcedit}} @@ -414,8 +421,12 @@ if [[ $__tfind_spe_call_count -eq 1 ]]; then tagline=${taglinebyte%%,*} # CD vs absolute path - tagfile=$__tfind_outside_git/${match[2]} - + if [[ $match[2] != /* && -n $TAG[repo-dir] ]]; then + tagfile=$TAG[repo-dir]/$match[2] + else + tagfile=$match[2] + fi + [[ ! -f $tagfile && -f $match[2] ]] && tagfile=$match[2] # Editor command case "$selected_editor" in (vim|vi|gvim|mvim|nvim) diff --git a/zinit-autoload.zsh b/zinit-autoload.zsh index ae2f38c4a..559113e51 100644 --- a/zinit-autoload.zsh +++ b/zinit-autoload.zsh @@ -1,5 +1,11 @@ -# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors. +#!/usr/bin/env zsh +# +# zdharma-continuum/zinit/zinit-autoload.zsh +# Copyright (c) 2016-2021 Sebastian Gniazdowski +# Copyright (c) 2021-2023 zdharma-continuum +# Homepage: https://github.com/zdharma-continuum/zinit +# License: MIT License +# builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { builtin print -P "${ZINIT[col-error]}ERROR:%f%b Couldn't find ${ZINIT[col-obj]}zinit-side.zsh%f%b."; return 1; } @@ -702,1421 +708,1352 @@ ZINIT[EXTENDED_GLOB]="" return 0 } # ]]] -# FUNCTION: .zinit-self-update [[[ -# Updates Zinit code (does a git pull) -.zinit-self-update() { - builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - setopt extendedglob typesetsilent warncreateglobal - - [[ $1 = -q ]] && +zinit-message "{pre}[self-update]{info} updating zinit repository{msg2}" \ - - local nl=$'\n' escape=$'\x1b[' - local current_branch=$(git -C $ZINIT[BIN_DIR] rev-parse --abbrev-ref HEAD) - # local current_branch='main' - local -a lines - ( - builtin cd -q "$ZINIT[BIN_DIR]" \ - && +zinit-message -n "{pre}[self-update]{info} fetching latest changes from {obj}$current_branch{info} branch$nl{rst}" \ - && command git fetch --quiet \ - && lines=( ${(f)"$(command git log --color --date=short --pretty=format:'%Cgreen%cd %h %Creset%s %Cred%d%Creset || %b' ..origin/HEAD)"} ) - if (( ${#lines} > 0 )); then - # Remove the (origin/main ...) segments, to expect only tags to appear - lines=( "${(S)lines[@]//\(([,[:blank:]]#(origin|HEAD|master|main)[^a-zA-Z]##(HEAD|origin|master|main)[,[:blank:]]#)#\)/}" ) - # Remove " ||" if it ends the line (i.e. no additional text from the body) - lines=( "${lines[@]/ \|\|[[:blank:]]#(#e)/}" ) - # If there's no ref-name, 2 consecutive spaces occur - fix this - lines=( "${lines[@]/(#b)[[:space:]]#\|\|[[:space:]]#(*)(#e)/|| ${match[1]}}" ) - lines=( "${lines[@]/(#b)$escape([0-9]##)m[[:space:]]##${escape}m/$escape${match[1]}m${escape}m}" ) - # Replace what follows "|| ..." with the same thing but with no - # newlines, and also only first 10 words (the (w)-flag enables - # word-indexing) - lines=( "${lines[@]/(#b)[[:blank:]]#\|\|(*)(#e)/| ${${match[1]//$nl/ }[(w)1,(w)10]}}" ) - builtin print -rl -- "${lines[@]}" | .zinit-pager - builtin print - fi - if [[ $1 != -q ]] { - command git pull --no-stat --ff-only origin main - } else { - command git pull --no-stat --quiet --ff-only origin main +# FUNCTION: .zinit-build-module [[[ +# Performs ./configure && make on the module and displays information +# how to load the module in .zshrc. +.zinit-build-module() { + setopt localoptions localtraps + trap 'return 1' INT TERM + if command git -C "${ZINIT[MODULE_DIR]}" rev-parse 2>/dev/null; then + command git -C "${ZINIT[MODULE_DIR]}" clean -d -f -f + command git -C "${ZINIT[MODULE_DIR]}" reset --hard HEAD + command git -C "${ZINIT[MODULE_DIR]}" pull + else + command git clone "https://github.com/zdharma-continuum/zinit-module.git" "${ZINIT[MODULE_DIR]}" || { + builtin print "${ZINIT[col-error]}Failed to clone module repo${ZINIT[col-rst]}" + return 1 } + fi + ( builtin cd -q "${ZINIT[MODULE_DIR]}" + +zinit-message "{pname}== Building module zdharma-continuum/zinit-module, running: make clean, then ./configure and then make =={rst}" + +zinit-message "{pname}== The module sources are located at: "${ZINIT[MODULE_DIR]}" =={rst}" + if [[ -f Makefile ]] { + if [[ "$1" = "--clean" ]] { + noglob +zinit-message {p}-- make distclean --{rst} + make distclean + ((1)) + } else { + noglob +zinit-message {p}-- make clean --{rst} + make clean + } + } + noglob +zinit-message {p}-- ./configure --{rst} + CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O3" LDFLAGS=-L/usr/local/lib ./configure --disable-gdbm --without-tcsetpgrp && { + noglob +zinit-message {p}-- make --{rst} + if { make } { + [[ -f Src/zdharma_continuum/zinit.so ]] && cp -vf Src/zdharma_continuum/zinit.{so,bundle} + noglob +zinit-message "{info}Module has been built correctly.{rst}" + .zinit-module info + } else { + noglob +zinit-message "{error}Module didn't build.{rst} " + .zinit-module info --link + } + } + builtin print $EPOCHSECONDS >! "${ZINIT[MAN_DIR]}/COMPILED_AT" ) - if [[ $1 != -q ]] { - +zinit-message "{pre}[self-update]{info} compiling zinit via {obj}zcompile{rst}" - } - command rm -f $ZINIT[BIN_DIR]/*.zwc(DN) - zcompile -U $ZINIT[BIN_DIR]/zinit.zsh - zcompile -U $ZINIT[BIN_DIR]/zinit-{'side','install','autoload','additional'}.zsh - zcompile -U $ZINIT[BIN_DIR]/share/git-process-output.zsh - # Load for the current session - [[ $1 != -q ]] && +zinit-message "{pre}[self-update]{info} reloading zinit for the current session{rst}" - - # +zinit-message "{pre}[self-update]{info} resetting zinit repository via{rst}: {cmd}${ICE[reset]:-git reset --hard HEAD}{rst}" - source $ZINIT[BIN_DIR]/zinit.zsh - zcompile -U $ZINIT[BIN_DIR]/zinit-{'side','install','autoload'}.zsh - # Read and remember the new modification timestamps - local file - for file ( "" -side -install -autoload ) { - .zinit-get-mtime-into "${ZINIT[BIN_DIR]}/zinit$file.zsh" "ZINIT[mtime$file]" - } } # ]]] -# FUNCTION: .zinit-show-registered-plugins [[[ -# Lists loaded plugins (subcommands list, lodaded) -.zinit-show-registered-plugins() { - builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - setopt extendedglob warncreateglobal typesetsilent noshortloops - - typeset -a filtered - local keyword="$1" - - keyword="${keyword## ##}" - keyword="${keyword%% ##}" - if [[ -n "$keyword" ]]; then - builtin print "Installed plugins matching ${ZINIT[col-info]}$keyword${ZINIT[col-rst]}:" - filtered=( "${(M)ZINIT_REGISTERED_PLUGINS[@]:#*$keyword*}" ) - else - filtered=( "${ZINIT_REGISTERED_PLUGINS[@]}" ) +# FUNCTION: .zinit-module [[[ +# Function that has sub-commands passed as long-options (with two dashes, --). +# It's an attempt to plugin only this one function into `zinit' function +# defined in zinit.zsh, to not make this file longer than it's needed. +.zinit-module() { + if [[ "$1" = "build" ]]; then + .zinit-build-module "${@[2,-1]}" + elif [[ "$1" = "info" ]]; then + if [[ "$2" = "--link" ]]; then + builtin print -r "You can copy the error messages and submit" + builtin print -r "error-report at: https://github.com/zdharma-continuum/zinit-module/issues" + else + builtin print -r "To load the module, add following 2 lines to .zshrc, at top:" + builtin print -r " module_path+=( \"${ZINIT[MODULE_DIR]}/Src\" )" + builtin print -r " zmodload zdharma_continuum/zinit" + builtin print -r "" + builtin print -r "After loading, use command \`zpmod' to communicate with the module." + builtin print -r "See \`zpmod -h' for more information." + fi + elif [[ "$1" = (help|usage) ]]; then + builtin print -r "Usage: zinit module {build|info|help} [options]" + builtin print -r " zinit module build [--clean]" + builtin print -r " zinit module info [--link]" + builtin print -r "" + builtin print -r "To start using the zinit Zsh module run: \`zinit module build'" + builtin print -r "and follow the instructions. Option --clean causes \`make distclean'" + builtin print -r "to be run. To display the instructions on loading the module, run:" + builtin print -r "\`zinit module info'." fi - - local i - for i in "${filtered[@]}"; do - [[ "$i" = "_local/zinit" ]] && continue - .zinit-any-colorify-as-uspl2 "$i" - # Mark light loads - [[ "${ZINIT[STATES__$i]}" = "1" ]] && REPLY="$REPLY ${ZINIT[col-info]}*${ZINIT[col-rst]}" - builtin print -r -- "$REPLY" - done } # ]]] -# FUNCTION: .zinit-unload [[[ -# 1. call the zsh plugin's standard *_plugin_unload function -# 2. call the code provided by the zsh plugin's standard @zsh-plugin-run-at-update -# 3. delete bindkeys (...) -# 4. delete zstyles -# 5. restore options -# 6. remove aliases -# 7. restore zle state -# 8. unfunction functions (created by plugin) -# 9. clean-up fpath and path -# 10. delete created variables -# 11. forget the plugin + +# FUNCTION: .zinit-cd [[[ +# Jumps to plugin's directory (in Zinit's home directory). +# +# User-action entry point. # # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $2 - plugin (only when $1 - i.e. user - given) -.zinit-unload() { - .zinit-any-to-user-plugin "$1" "$2" - local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" user="${reply[-2]}" plugin="${reply[-1]}" quiet="${${3:+1}:-0}" - local k - - .zinit-any-colorify-as-uspl2 "$uspl2" - (( quiet )) || builtin print -r -- "${ZINIT[col-bar]}---${ZINIT[col-rst]} Unloading plugin: $REPLY ${ZINIT[col-bar]}---${ZINIT[col-rst]}" +.zinit-cd() { + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent rcquotes - local ___dir - [[ "$user" = "%" ]] && ___dir="$plugin" || ___dir="${ZINIT[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}" + .zinit-get-path "$1" "$2" && { + if [[ -e $REPLY ]]; then + builtin pushd $REPLY + else + +zinit-message "No such plugin or snippet" + return 1 + fi + builtin print + } || { + +zinit-message "No such plugin or snippet" + return 1 + } +} # ]]] +# FUNCTION: .zinit-cdisable [[[ +# Enables given installed completion. +# +# User-action entry point. +# +# $1 - e.g. "_mkdir" or "mkdir" +.zinit-cdisable() { + local c="$1" + c="${c#_}" - # KSH_ARRAYS immunity - integer correct=0 - [[ -o "KSH_ARRAYS" ]] && correct=1 + local cfile="${ZINIT[COMPLETIONS_DIR]}/_${c}" + local bkpfile="${cfile:h}/$c" - # Allow unload for debug user - if [[ "$uspl2" != "_dtrace/_dtrace" ]]; then - .zinit-exists-message "$1" "$2" || return 1 + if [[ ! -e "$cfile" && ! -e "$bkpfile" ]]; then + builtin print "${ZINIT[col-error]}No such completion \`$c'${ZINIT[col-rst]}" + return 1 fi - .zinit-any-colorify-as-uspl2 "$1" "$2" - local uspl2col="$REPLY" + # Check if it's already disabled + # Not existing "$cfile" says that + if [[ ! -e "$cfile" ]]; then + builtin print "Completion ${ZINIT[col-info]}$c${ZINIT[col-rst]} already disabled" - # Store report of the plugin in variable LASTREPORT - typeset -g LASTREPORT - LASTREPORT=`.zinit-show-report "$1" "$2"` + .zinit-check-comp-consistency "$cfile" "$bkpfile" 0 + return 1 + fi - # Call the Zsh Plugin's Standard *_plugin_unload function - (( ${+functions[${plugin}_plugin_unload]} )) && ${plugin}_plugin_unload + # No disable, but bkpfile exists? + if [[ -e "$bkpfile" ]]; then + builtin print "${ZINIT[col-error]}Warning: completion's backup file \`${bkpfile:t}' already exists, will overwrite${ZINIT[col-rst]}" + .zinit-check-comp-consistency "$cfile" "$bkpfile" 1 + command rm -f "$bkpfile" + else + .zinit-check-comp-consistency "$cfile" "$bkpfile" 0 + fi - # Call the code provided by the Zsh Plugin's Standard @zsh-plugin-run-at-update - local -a tmp - local -A sice - tmp=( "${(z@)ZINIT_SICE[$uspl2]}" ) - (( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) && sice=( "${(Q)tmp[@]}" ) || sice=() + # Disable + command mv "$cfile" "$bkpfile" - if [[ -n ${sice[ps-on-unload]} ]]; then - (( quiet )) || builtin print -r "Running plugin's provided unload code: ${ZINIT[col-info]}${sice[ps-on-unload][1,50]}${sice[ps-on-unload][51]:+…}${ZINIT[col-rst]}" - local ___oldcd="$PWD" - () { setopt localoptions noautopushd; builtin cd -q "$___dir"; } - eval "${sice[ps-on-unload]}" - () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; } - fi + # Prepare readlink command for establishing completion's owner + .zinit-prepare-readlink + # Get completion's owning plugin + .zinit-get-completion-owner-uspl2col "$bkpfile" "$REPLY" - # 1. Delete done bindkeys - typeset -a string_widget - string_widget=( "${(z)ZINIT[BINDKEYS__$uspl2]}" ) - local sw - for sw in "${(Oa)string_widget[@]}"; do - [[ -z "$sw" ]] && continue - # Remove one level of quoting to split using (z) - sw="${(Q)sw}" - typeset -a sw_arr - sw_arr=( "${(z)sw}" ) + builtin print "Disabled ${ZINIT[col-info]}$c${ZINIT[col-rst]} completion belonging to $REPLY" - # Remove one level of quoting to pass to bindkey - local sw_arr1="${(Q)sw_arr[1-correct]}" # Keys - local sw_arr2="${(Q)sw_arr[2-correct]}" # Widget - local sw_arr3="${(Q)sw_arr[3-correct]}" # Optional previous-bound widget - local sw_arr4="${(Q)sw_arr[4-correct]}" # Optional -M or -A or -N - local sw_arr5="${(Q)sw_arr[5-correct]}" # Optional map name - local sw_arr6="${(Q)sw_arr[6-correct]}" # Optional -R (not with -A, -N) + return 0 +} # ]]] +# FUNCTION: .zinit-cenable [[[ +# Disables given installed completion. +# +# User-action entry point. +# +# $1 - e.g. "_mkdir" or "mkdir" +.zinit-cenable() { + local c="$1" + c="${c#_}" - if [[ "$sw_arr4" = "-M" && "$sw_arr6" != "-R" ]]; then - if [[ -n "$sw_arr3" ]]; then - () { - builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} - (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3 ${ZINIT[col-info]}in map ${ZINIT[col-rst]}$sw_arr5" - } - bindkey -M "$sw_arr5" "$sw_arr1" "$sw_arr3" - else - (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2 ${ZINIT[col-info]}in map ${ZINIT[col-rst]}$sw_arr5" - bindkey -M "$sw_arr5" -r "$sw_arr1" - fi - elif [[ "$sw_arr4" = "-M" && "$sw_arr6" = "-R" ]]; then - if [[ -n "$sw_arr3" ]]; then - (( quiet )) || builtin print -r "Restoring ${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3 ${ZINIT[col-info]}in map ${ZINIT[col-rst]}$sw_arr5" - bindkey -RM "$sw_arr5" "$sw_arr1" "$sw_arr3" - else - (( quiet )) || builtin print -r "Deleting ${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2 ${ZINIT[col-info]}in map ${ZINIT[col-rst]}$sw_arr5" - bindkey -M "$sw_arr5" -Rr "$sw_arr1" - fi - elif [[ "$sw_arr4" != "-M" && "$sw_arr6" = "-R" ]]; then - if [[ -n "$sw_arr3" ]]; then - (( quiet )) || builtin print -r "Restoring ${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3" - bindkey -R "$sw_arr1" "$sw_arr3" - else - (( quiet )) || builtin print -r "Deleting ${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2" - bindkey -Rr "$sw_arr1" - fi - elif [[ "$sw_arr4" = "-A" ]]; then - (( quiet )) || builtin print -r "Linking backup-\`main' keymap \`$sw_arr5' back to \`main'" - bindkey -A "$sw_arr5" "main" - elif [[ "$sw_arr4" = "-N" ]]; then - (( quiet )) || builtin print -r "Deleting keymap \`$sw_arr5'" - bindkey -D "$sw_arr5" - else - if [[ -n "$sw_arr3" ]]; then - () { - builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} - (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3" - } - bindkey "$sw_arr1" "$sw_arr3" - else - (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2" - bindkey -r "$sw_arr1" - fi - fi - done + local cfile="${ZINIT[COMPLETIONS_DIR]}/_${c}" + local bkpfile="${cfile:h}/$c" - # 2. Delete created Zstyles + if [[ ! -e "$cfile" && ! -e "$bkpfile" ]]; then + builtin print "${ZINIT[col-error]}No such completion \`$c'${ZINIT[col-rst]}" + return 1 + fi - typeset -a pattern_style - pattern_style=( "${(z)ZINIT[ZSTYLES__$uspl2]}" ) - local ps - for ps in "${(Oa)pattern_style[@]}"; do - [[ -z "$ps" ]] && continue - # Remove one level of quoting to split using (z) - ps="${(Q)ps}" - typeset -a ps_arr - ps_arr=( "${(z)ps}" ) + # Check if there is no backup file + # This is treated as if the completion is already enabled + if [[ ! -e "$bkpfile" ]]; then + builtin print "Completion ${ZINIT[col-info]}$c${ZINIT[col-rst]} already enabled" - # Remove one level of quoting to pass to zstyle - local ps_arr1="${(Q)ps_arr[1-correct]}" - local ps_arr2="${(Q)ps_arr[2-correct]}" + .zinit-check-comp-consistency "$cfile" "$bkpfile" 0 + return 1 + fi - (( quiet )) || builtin print "Deleting zstyle $ps_arr1 $ps_arr2" + # Disabled, but completion file already exists? + if [[ -e "$cfile" ]]; then + builtin print "${ZINIT[col-error]}Warning: completion's file \`${cfile:t}' exists, will overwrite${ZINIT[col-rst]}" + builtin print "${ZINIT[col-error]}Completion is actually enabled and will re-enable it again${ZINIT[col-rst]}" + .zinit-check-comp-consistency "$cfile" "$bkpfile" 1 + command rm -f "$cfile" + else + .zinit-check-comp-consistency "$cfile" "$bkpfile" 0 + fi - zstyle -d "$ps_arr1" "$ps_arr2" - done + # Enable + command mv "$bkpfile" "$cfile" # move completion's backup file created when disabling - # 3. Restore changed options - # paranoid, don't want bad key/value pair error - .zinit-diff-options-compute "$uspl2" - integer empty=0 - .zinit-save-set-extendedglob - [[ "${ZINIT[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1 - .zinit-restore-extendedglob + # Prepare readlink command for establishing completion's owner + .zinit-prepare-readlink + # Get completion's owning plugin + .zinit-get-completion-owner-uspl2col "$cfile" "$REPLY" - if (( empty != 1 )); then - typeset -A opts - opts=( "${(z)ZINIT[OPTIONS__$uspl2]}" ) - for k in "${(kon)opts[@]}"; do - # Internal options - [[ "$k" = "physical" ]] && continue + builtin print "Enabled ${ZINIT[col-info]}$c${ZINIT[col-rst]} completion belonging to $REPLY" - if [[ "${opts[$k]}" = "on" ]]; then - (( quiet )) || builtin print "Setting option $k" - builtin setopt "$k" - else - (( quiet )) || builtin print "Unsetting option $k" - builtin unsetopt "$k" - fi - done - fi + return 0 +} # ]]] +# FUNCTION: .zinit-changes [[[ +# Shows `git log` of given plugin. +# +# User-action entry point. +# +# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) +# $2 - plugin (only when $1 - i.e. user - given) +.zinit-changes() { + .zinit-any-to-user-plugin "$1" "$2" + local user="${reply[-2]}" plugin="${reply[-1]}" - # 4. Delete aliases - typeset -a aname_avalue - aname_avalue=( "${(z)ZINIT[ALIASES__$uspl2]}" ) - local nv - for nv in "${(Oa)aname_avalue[@]}"; do - [[ -z "$nv" ]] && continue - # Remove one level of quoting to split using (z) - nv="${(Q)nv}" - typeset -a nv_arr - nv_arr=( "${(z)nv}" ) + .zinit-exists-physically-message "$user" "$plugin" || return 1 - # Remove one level of quoting to pass to unalias - local nv_arr1="${(Q)nv_arr[1-correct]}" - local nv_arr2="${(Q)nv_arr[2-correct]}" - local nv_arr3="${(Q)nv_arr[3-correct]}" + ( + builtin cd -q "${ZINIT[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}" && \ + command git log -p --graph --decorate --date=relative -C -M + ) +} # ]]] +# FUNCTION: .zinit-clear-completions [[[ +# Delete stray and improper completions. +# +# Completions live even when plugin isn't loaded - if they are +# installed and enabled. +# +# User-action entry point. +.zinit-clear-completions() { + builtin setopt localoptions nullglob extendedglob nokshglob noksharrays - if [[ "$nv_arr3" = "-s" ]]; then - if [[ -n "$nv_arr2" ]]; then - (( quiet )) || builtin print "Restoring ${ZINIT[col-info]}suffix${ZINIT[col-rst]} alias ${nv_arr1}=${nv_arr2}" - alias "$nv_arr1" &> /dev/null && unalias -s -- "$nv_arr1" - alias -s -- "${nv_arr1}=${nv_arr2}" - else - (( quiet )) || alias "$nv_arr1" &> /dev/null && { - builtin print "Removing ${ZINIT[col-info]}suffix${ZINIT[col-rst]} alias ${nv_arr1}" - unalias -s -- "$nv_arr1" - } - fi - elif [[ "$nv_arr3" = "-g" ]]; then - if [[ -n "$nv_arr2" ]]; then - (( quiet )) || builtin print "Restoring ${ZINIT[col-info]}global${ZINIT[col-rst]} alias ${nv_arr1}=${nv_arr2}" - alias "$nv_arr1" &> /dev/null && unalias -g -- "$nv_arr1" - alias -g -- "${nv_arr1}=${nv_arr2}" - else - (( quiet )) || alias "$nv_arr1" &> /dev/null && { - builtin print "Removing ${ZINIT[col-info]}global${ZINIT[col-rst]} alias ${nv_arr1}" - unalias -- "${(q)nv_arr1}" - } - fi - else - if [[ -n "$nv_arr2" ]]; then - (( quiet )) || builtin print "Restoring alias ${nv_arr1}=${nv_arr2}" - alias "$nv_arr1" &> /dev/null && unalias -- "$nv_arr1" - alias -- "${nv_arr1}=${nv_arr2}" - else - (( quiet )) || alias "$nv_arr1" &> /dev/null && { - builtin print "Removing alias ${nv_arr1}" - unalias -- "$nv_arr1" - } - fi - fi + typeset -a completions + completions=( "${ZINIT[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc "${ZINIT[COMPLETIONS_DIR]}"/[^_.]*~*.zwc ) + + # Find longest completion name + local cpath c + integer longest=0 + for cpath in "${completions[@]}"; do + c="${cpath:t}" + c="${c#_}" + [[ "${#c}" -gt "$longest" ]] && longest="${#c}" done - # - # 5. Restore Zle state - # + .zinit-prepare-readlink + local rdlink="$REPLY" - local -a keys - keys=( "${(@on)ZINIT[(I)TIME_<->_*]}" ) - integer keys_size=${#keys} - () { - setopt localoptions extendedglob noksharrays typesetsilent - typeset -a restore_widgets skip_delete - local wid - restore_widgets=( "${(z)ZINIT[WIDGETS_SAVED__$uspl2]}" ) - for wid in "${(Oa)restore_widgets[@]}"; do - [[ -z "$wid" ]] && continue - wid="${(Q)wid}" - typeset -a orig_saved - orig_saved=( "${(z)wid}" ) + integer disabled unknown stray + for cpath in "${completions[@]}"; do + c="${cpath:t}" + [[ "${c#_}" = "${c}" ]] && disabled=1 || disabled=0 + c="${c#_}" - local tpe="${orig_saved[1]}" - local orig_saved1="${(Q)orig_saved[2]}" # Original widget - local comp_wid="${(Q)orig_saved[3]}" - local orig_saved2="${(Q)orig_saved[4]}" # Saved target function - local orig_saved3="${(Q)orig_saved[5]}" # Saved previous $widget's contents + # This will resolve completion's symlink to obtain + # information about the repository it comes from, i.e. + # about user and plugin, taken from directory name + .zinit-get-completion-owner "$cpath" "$rdlink" + [[ "$REPLY" = "[unknown]" ]] && unknown=1 || unknown=0 + .zinit-any-colorify-as-uspl2 "$REPLY" - local found_time_key="${keys[(r)TIME_<->_${uspl2//\//---}]}" to_process_plugin - integer found_time_idx=0 idx=0 - to_process_plugin="" - [[ "$found_time_key" = (#b)TIME_(<->)_* ]] && found_time_idx="${match[1]}" - if (( found_time_idx )); then # Must be true - for (( idx = found_time_idx + 1; idx <= keys_size; ++ idx )); do - found_time_key="${keys[(r)TIME_${idx}_*]}" - local oth_uspl2="" - [[ "$found_time_key" = (#b)TIME_${idx}_(*) ]] && oth_uspl2="${match[1]//---//}" - local -a entry_splitted - entry_splitted=( "${(z@)ZINIT[WIDGETS_SAVED__$oth_uspl2]}" ) - integer found_idx="${entry_splitted[(I)(-N|-C)\ $orig_saved1\\\ *]}" - local -a entry_splitted2 - entry_splitted2=( "${(z@)ZINIT[BINDKEYS__$oth_uspl2]}" ) - integer found_idx2="${entry_splitted2[(I)*\ $orig_saved1\ *]}" - if (( found_idx || found_idx2 )) - then - # Skip multiple loads of the same plugin - # TODO: fully handle multiple plugin loads - if [[ "$oth_uspl2" != "$uspl2" ]]; then - to_process_plugin="$oth_uspl2" - # only the first one is needed - break - fi - fi - done - if [[ -n "$to_process_plugin" ]]; then - if (( !found_idx && !found_idx2 )); then - (( quiet )) || builtin print "Problem (1) during handling of widget \`$orig_saved1' (contents: $orig_saved2)" - continue - fi - (( quiet )) || builtin print "Chaining widget \`$orig_saved1' to plugin $oth_uspl2" - local -a oth_orig_saved - if (( found_idx )) { - oth_orig_saved=( "${(z)${(Q)entry_splitted[found_idx]}}" ) - local oth_fun="${oth_orig_saved[4]}" - # below is wrong because we don't want to call other plugins function at any moment - # oth_orig_saved[2]="${(q)orig_saved2}" - oth_orig_saved[5]="${(q)orig_saved3}" # chain up the widget - entry_splitted[found_idx]="${(q)${(j: :)oth_orig_saved}}" - ZINIT[WIDGETS_SAVED__$oth_uspl2]="${(j: :)entry_splitted}" - } else { - oth_orig_saved=( "${(z)${(Q)entry_splitted2[found_idx2]}}" ) - local oth_fun="${widgets[${oth_orig_saved[3]}]#*:}" - } - integer idx="${functions[$orig_saved2][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}" - if (( idx <= ${#functions[$orig_saved2]} )) - then - local prefix_X="${match[1]#\{}" - [[ $prefix_X != \$* ]] && prefix_X="${prefix_X%\}}" - idx="${functions[$oth_fun][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}" - if (( idx <= ${#functions[$oth_fun]} )); then - match[1]="${match[1]#\{}" - [[ ${match[1]} != \$* ]] && match[1]="${match[1]%\}}" - eval "local oth_prefix_uspl2_X=\"${match[1]}\"" - if [[ "${widgets[$prefix_X]}" = builtin ]]; then - (( quiet )) || builtin print "Builtin-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" - zle -A ".${prefix_X#.}" "$oth_prefix_uspl2_X" - elif [[ "${widgets[$prefix_X]}" = completion:* ]]; then - (( quiet )) || builtin print "Chain*-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" - zle -C "$oth_prefix_uspl2_X" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}" - else - (( quiet )) || builtin print "Chain-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" - zle -N "$oth_prefix_uspl2_X" "${widgets[$prefix_X]#user:}" - fi - fi - # The alternate method - # skip_delete+=( "${match[1]}" ) - # functions[$oth_fun]="${functions[$oth_fun]//[^\{[:space:]]#$orig_saved1/${match[1]}}" - fi - else - (( quiet )) || builtin print "Restoring Zle widget $orig_saved1" - if [[ "$orig_saved3" = builtin ]]; then - zle -A ".$orig_saved1" "$orig_saved1" - elif [[ "$orig_saved3" = completion:* ]]; then - zle -C "$orig_saved1" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}" - else - zle -N "$orig_saved1" "${orig_saved3#user:}" - fi - fi - else - (( quiet )) || builtin print "Problem (2) during handling of widget \`$orig_saved1' (contents: $orig_saved2)" - fi - done - } - - typeset -a delete_widgets - delete_widgets=( "${(z)ZINIT[WIDGETS_DELETE__$uspl2]}" ) - local wid - for wid in "${(Oa)delete_widgets[@]}"; do - [[ -z "$wid" ]] && continue - wid="${(Q)wid}" - if [[ -n "${skip_delete[(r)$wid]}" ]]; then - builtin print "Would delete $wid" - continue - fi - if [[ "${ZINIT_ZLE_HOOKS_LIST[$wid]}" = "1" ]]; then - (( quiet )) || builtin print "Removing Zle hook \`$wid'" - else - (( quiet )) || builtin print "Removing Zle widget \`$wid'" + # If we successfully read a symlink (unknown == 0), test if it isn't broken + stray=0 + if (( unknown == 0 )); then + [[ ! -f "$cpath" ]] && stray=1 fi - zle -D "$wid" - done - - # 6. Unfunction - .zinit-diff-functions-compute "$uspl2" - typeset -a func - func=( "${(z)ZINIT[FUNCTIONS__$uspl2]}" ) - local f - for f in "${(on)func[@]}"; do - [[ -z "$f" ]] && continue - f="${(Q)f}" - (( quiet )) || builtin print "Deleting function $f" - (( ${+functions[$f]} )) && unfunction -- "$f" - (( ${+precmd_functions} )) && precmd_functions=( ${precmd_functions[@]:#$f} ) - (( ${+preexec_functions} )) && preexec_functions=( ${preexec_functions[@]:#$f} ) - (( ${+chpwd_functions} )) && chpwd_functions=( ${chpwd_functions[@]:#$f} ) - (( ${+periodic_functions} )) && periodic_functions=( ${periodic_functions[@]:#$f} ) - (( ${+zshaddhistory_functions} )) && zshaddhistory_functions=( ${zshaddhistory_functions[@]:#$f} ) - (( ${+zshexit_functions} )) && zshexit_functions=( ${zshexit_functions[@]:#$f} ) - done - # 7. Clean up FPATH and PATH - .zinit-diff-env-compute "$uspl2" - # iterate over $path elements and skip those that were added by the plugin - typeset -a new elem p - elem=( "${(z)ZINIT[PATH__$uspl2]}" ) - for p in "${path[@]}"; do - if [[ -z "${elem[(r)${(q)p}]}" ]] { - new+=( "$p" ) - } else { - (( quiet )) || builtin print "Removing PATH element ${ZINIT[col-info]}$p${ZINIT[col-rst]}" - [[ -d "$p" ]] || (( quiet )) || builtin print "${ZINIT[col-error]}Warning:${ZINIT[col-rst]} it didn't exist on disk" - } + if (( unknown == 1 || stray == 1 )); then + builtin print -n "Removing completion: ${(r:longest+1:: :)c} $REPLY" + (( disabled )) && builtin print -n " ${ZINIT[col-error]}[disabled]${ZINIT[col-rst]}" + (( unknown )) && builtin print -n " ${ZINIT[col-error]}[unknown file]${ZINIT[col-rst]}" + (( stray )) && builtin print -n " ${ZINIT[col-error]}[stray]${ZINIT[col-rst]}" + builtin print + command rm -f "$cpath" + fi done - path=( "${new[@]}" ) - - # The same for $fpath - elem=( "${(z)ZINIT[FPATH__$uspl2]}" ) - new=( ) - for p ( "${fpath[@]}" ) { - if [[ -z "${elem[(r)${(q)p}]}" ]] { - new+=( "$p" ) - } else { - (( quiet )) || builtin print "Removing FPATH element ${ZINIT[col-info]}$p${ZINIT[col-rst]}" - [[ -d "$p" ]] || (( quiet )) || builtin print "${ZINIT[col-error]}Warning:${ZINIT[col-rst]} it didn't exist on disk" - } - } - fpath=( "${new[@]}" ) - - # 8. Delete created variables - .zinit-diff-parameter-compute "$uspl2" - empty=0 - .zinit-save-set-extendedglob - [[ "${ZINIT[PARAMETERS_POST__$uspl2]}" != *[$'! \t']* ]] && empty=1 - .zinit-restore-extendedglob +} # ]]] +# FUNCTION: .zinit-compile-uncompile-all [[[ +# Compiles or uncompiles all existing (on disk) plugins. +# +# User-action entry point. +.zinit-compile-uncompile-all() { + builtin setopt localoptions nullglob - if (( empty != 1 )); then - typeset -A elem_pre elem_post - elem_pre=( "${(z)ZINIT[PARAMETERS_PRE__$uspl2]}" ) - elem_post=( "${(z)ZINIT[PARAMETERS_POST__$uspl2]}" ) + local compile="$1" - # Find variables created or modified - local wl found - local -a whitelist - whitelist=( "${(@Q)${(z@)ZINIT[ENV-WHITELIST]}}" ) - for k in "${(k)elem_post[@]}"; do - k="${(Q)k}" - local v1="${(Q)elem_pre[$k]}" - local v2="${(Q)elem_post[$k]}" + typeset -a plugins + plugins=( "${ZINIT[PLUGINS_DIR]}"/*(DN) ) - # "" means a variable was deleted, not created/changed - if [[ $v2 != '""' ]]; then - # Don't unset readonly variables - [[ ${(tP)k} == *-readonly(|-*) ]] && continue + local p user plugin + for p in "${plugins[@]}"; do + [[ "${p:t}" = "custom" || "${p:t}" = "_local---zinit" ]] && continue - # Don't unset arrays managed by add-zsh-hook, also ignore a few special parameters - # TODO: remember and remove hooks - case "$k" in - (chpwd_functions|precmd_functions|preexec_functions|periodic_functions|zshaddhistory_functions|zshexit_functions|zsh_directory_name_functions) - continue - (path|PATH|fpath|FPATH) - continue; - ;; - esac + .zinit-any-to-user-plugin "${p:t}" + user="${reply[-2]}" plugin="${reply[-1]}" - # Don't unset redefined variables, only newly defined "" means variable didn't exist before plugin load (didn't have a type). - # Do an exception for the prompt variables - if [[ $v1 = '""' || ( $k = (RPROMPT|RPS1|RPS2|PROMPT|PS1|PS2|PS3|PS4) && $v1 != $v2 ) ]]; then - found=0 - for wl in "${whitelist[@]}"; do - if [[ "$k" = ${~wl} ]]; then - found=1 - break - fi - done - if (( !found )); then - (( quiet )) || builtin print "Unsetting variable $k" - # checked that 4.3.17 does support "--"; cannot be parameter starting with "-" but let's defensively use "--" here - unset -- "$k" - else - builtin print "Skipping unset of variable $k (whitelist)" - fi - fi - fi - done - fi + .zinit-any-colorify-as-uspl2 "$user" "$plugin" + builtin print -r -- "$REPLY:" - # 9. Forget the plugin - if [[ "$uspl2" = "_dtrace/_dtrace" ]]; then - .zinit-clear-debug-report - (( quiet )) || builtin print "dtrace report saved to \$LASTREPORT" - else - (( quiet )) || builtin print "Unregistering plugin $uspl2col" - .zinit-unregister-plugin "$user" "$plugin" "${sice[teleid]}" - zsh_loaded_plugins[${zsh_loaded_plugins[(i)$user${${user:#(%|/)*}:+/}$plugin]}]=() # Support Zsh plugin standard - .zinit-clear-report-for "$user" "$plugin" - (( quiet )) || builtin print "Plugin's report saved to \$LASTREPORT" - fi + if [[ "$compile" = "1" ]]; then + .zinit-compile-plugin "$user" "$plugin" + else + .zinit-uncompile-plugin "$user" "$plugin" "1" + fi + done } # ]]] -# FUNCTION: .zinit-show-report [[[ -# Displays report of the plugin given. +# FUNCTION: .zinit-compiled [[[ +# Displays list of plugins that are compiled. # -# $1 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin) -# $2 - plugin (only when $1 - i.e. user - given) -.zinit-show-report() { - setopt localoptions extendedglob warncreateglobal typesetsilent noksharrays - .zinit-any-to-user-plugin "$1" "$2" - local user="${reply[-2]}" plugin="${reply[-1]}" uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" +# User-action entry point. +.zinit-compiled() { + builtin setopt localoptions nullglob - # Allow debug report - if [[ "$user/$plugin" != "_dtrace/_dtrace" ]]; then - .zinit-exists-message "$user" "$plugin" || return 1 + typeset -a matches m + matches=( ${ZINIT[PLUGINS_DIR]}/*/*.zwc(DN) ) + + if [[ "${#matches[@]}" -eq "0" ]]; then + builtin print "No compiled plugins" + return 0 fi - # Print title - builtin printf "${ZINIT[col-title]}Report for${ZINIT[col-rst]} %s%s plugin\n"\ - "${user:+${ZINIT[col-uname]}$user${ZINIT[col-rst]}}${${user:#(%|/)*}:+/}"\ - "${ZINIT[col-pname]}$plugin${ZINIT[col-rst]}" - - # Print "----------" - local msg="Report for $user${${user:#(%|/)*}:+/}$plugin plugin" - builtin print -- "${ZINIT[col-bar]}${(r:${#msg}::-:)tmp__}${ZINIT[col-rst]}" - - local -A map - map=( - Error: "${ZINIT[col-error]}" - Warning: "${ZINIT[col-error]}" - Note: "${ZINIT[col-note]}" - ) - # Print report gathered via shadowing - () { - setopt localoptions extendedglob - builtin print -rl -- "${(@)${(f@)ZINIT_REPORTS[$uspl2]}/(#b)(#s)([^[:space:]]##)([[:space:]]##)/${map[${match[1]}]:-${ZINIT[col-keyword]}}${match[1]}${ZINIT[col-rst]}${match[2]}}" - } - - # Print report gathered via $functions-diffing - REPLY="" - .zinit-diff-functions-compute "$uspl2" - .zinit-format-functions "$uspl2" - [[ -n "$REPLY" ]] && builtin print "${ZINIT[col-p]}Functions created:${ZINIT[col-rst]}"$'\n'"$REPLY" - - # Print report gathered via $options-diffing - REPLY="" - .zinit-diff-options-compute "$uspl2" - .zinit-format-options "$uspl2" - [[ -n "$REPLY" ]] && builtin print "${ZINIT[col-p]}Options changed:${ZINIT[col-rst]}"$'\n'"$REPLY" - - # Print report gathered via environment diffing - REPLY="" - .zinit-diff-env-compute "$uspl2" - .zinit-format-env "$uspl2" "1" - [[ -n "$REPLY" ]] && builtin print "${ZINIT[col-p]}PATH elements added:${ZINIT[col-rst]}"$'\n'"$REPLY" - - REPLY="" - .zinit-format-env "$uspl2" "2" - [[ -n "$REPLY" ]] && builtin print "${ZINIT[col-p]}FPATH elements added:${ZINIT[col-rst]}"$'\n'"$REPLY" - - # Print report gathered via parameter diffing - .zinit-diff-parameter-compute "$uspl2" - .zinit-format-parameter "$uspl2" - [[ -n "$REPLY" ]] && builtin print "${ZINIT[col-p]}Variables added or redefined:${ZINIT[col-rst]}"$'\n'"$REPLY" - - # Print what completions plugin has - .zinit-find-completions-of-plugin "$user" "$plugin" - typeset -a completions - completions=( "${reply[@]}" ) - - if [[ "${#completions[@]}" -ge "1" ]]; then - builtin print "${ZINIT[col-p]}Completions:${ZINIT[col-rst]}" - .zinit-check-which-completions-are-installed "${completions[@]}" - typeset -a installed - installed=( "${reply[@]}" ) + local cur_plugin="" uspl1 file user plugin + for m in "${matches[@]}"; do + file="${m:t}" + uspl1="${${m:h}:t}" + .zinit-any-to-user-plugin "$uspl1" + user="${reply[-2]}" plugin="${reply[-1]}" - .zinit-check-which-completions-are-enabled "${completions[@]}" - typeset -a enabled - enabled=( "${reply[@]}" ) + if [[ "$cur_plugin" != "$uspl1" ]]; then + [[ -n "$cur_plugin" ]] && builtin print # newline + .zinit-any-colorify-as-uspl2 "$user" "$plugin" + builtin print -r -- "$REPLY:" + cur_plugin="$uspl1" + fi - integer count="${#completions[@]}" idx - for (( idx=1; idx <= count; idx ++ )); do - builtin print -n "${completions[idx]:t}" - if [[ "${installed[idx]}" != "1" ]]; then - builtin print -n " ${ZINIT[col-uninst]}[not installed]${ZINIT[col-rst]}" - else - if [[ "${enabled[idx]}" = "1" ]]; then - builtin print -n " ${ZINIT[col-info]}[enabled]${ZINIT[col-rst]}" - else - builtin print -n " ${ZINIT[col-error]}[disabled]${ZINIT[col-rst]}" - fi - fi - builtin print - done - builtin print - fi -} # ]]] -# FUNCTION: .zinit-show-all-reports [[[ -# Displays reports of all loaded plugins. -# -# User-action entry point. -.zinit-show-all-reports() { - local i - for i in "${ZINIT_REGISTERED_PLUGINS[@]}"; do - [[ "$i" = "_local/zinit" ]] && continue - .zinit-show-report "$i" + builtin print "$file" done } # ]]] -# FUNCTION: .zinit-show-debug-report [[[ -# Displays dtrace report (data recorded in interactive session). +# FUNCTION: .zinit-confirm [[[ +# Prints given question, waits for "y" key, evals +# given expression if "y" obtained # -# User-action entry point. -.zinit-show-debug-report() { - .zinit-show-report "_dtrace/_dtrace" +# $1 - question +# $2 - expression +.zinit-confirm() { + integer retval + if (( OPTS[opt_-y,--yes] )); then + builtin eval "${2}"; retval=$? + (( OPTS[opt_-q,--quiet] )) || +zinit-message -lrP "{m} Action executed (exit code: {num}${retval}{rst})" + else + local choice prompt + builtin print -D -v prompt "$(+zinit-message '{i} Press [{opt}Y{rst}/{opt}y{rst}] to continue: {nl}')" + +zinit-message "${1}" + if builtin read -qs "choice?${prompt}"; then + builtin eval "${2}"; retval=$? + +zinit-message "{m} Action executed (exit code: {num}${retval}{rst})" + return 0 + else + +zinit-message "{m} No action executed ('{opt}${choice}{rst}' not 'Y' or 'y')" + return 1 + fi + fi } # ]]] -# FUNCTION: .zinit-update-or-status [[[ -# Updates (git pull) or does `git status' for given plugin. +# FUNCTION: .zinit-create [[[ +# Creates a plugin, also on Github (if not "_local/name" plugin). # # User-action entry point. # -# $1 - "status" for status, other for update -# $2 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin) -# $3 - plugin (only when $1 - i.e. user - given) -.zinit-update-or-status() { - # Set the localtraps option. +# $1 - (optional) plugin spec (4 formats: user---plugin, user/plugin, user, plugin) +# $2 - (optional) plugin (only when $1 - i.e. user - given) +.zinit-create() { builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops - - local -a arr - ZINIT[first-plugin-mark]=${${ZINIT[first-plugin-mark]:#init}:-1} - ZINIT[-r/--reset-opt-hook-has-been-run]=0 + setopt localoptions extendedglob noshortloops rcquotes typesetsilent warncreateglobal - # Deliver and withdraw the `m` function when finished. - .zinit-set-m-func set - trap ".zinit-set-m-func unset" EXIT + .zinit-any-to-user-plugin "$1" "$2" + local user="${reply[-2]}" plugin="${reply[-1]}" - integer retval hook_rc was_snippet - .zinit-two-paths "$2${${2:#(%|/)*}:+${3:+/}}$3" - if [[ -d ${reply[-4]} || -d ${reply[-2]} ]]; then - .zinit-update-or-status-snippet "$1" "$2${${2:#(%|/)*}:+${3:+/}}$3" - retval=$? - was_snippet=1 + if (( ${+commands[curl]} == 0 || ${+commands[git]} == 0 )); then + builtin print "${ZINIT[col-error]}curl and git are needed${ZINIT[col-rst]}" + return 1 fi - .zinit-any-to-user-plugin "$2" "$3" - local user=${reply[-2]} plugin=${reply[-1]} st=$1 \ - local_dir filename is_snippet key \ - id_as="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" - local -A ice - - if (( was_snippet )) { - .zinit-exists-physically "$user" "$plugin" || return $retval - .zinit-any-colorify-as-uspl2 "$2" "$3" - (( !OPTS[opt_-q,--quiet] )) && \ - +zinit-message "{msg2}Updating also \`$REPLY{rst}{msg2}'" \ - "plugin (already updated a snippet of the same name){…}{rst}" - } else { - .zinit-exists-physically-message "$user" "$plugin" || return 1 - } + # Read whether to create under organization + local isorg + vared -cp 'Create under an organization? (y/n): ' isorg - if [[ $st = status ]]; then - ( builtin cd -q ${ZINIT[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}; command git status; ) - return $retval + if [[ $isorg = (y|yes) ]]; then + local org="$user" + vared -cp "Github organization name: " org fi - command rm -f ${TMPDIR:-${TMPDIR:-/tmp}}/zinit-execs.$$.lst ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.installed_comps.$$.lst \ - ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.skipped_comps.$$.lst ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.compiled.$$.lst - - # A flag for the annexes. 0 – no new commits, 1 - run-atpull mode, - # 2 – full update/there are new commits to download, 3 - full but - # a forced download (i.e.: the medium doesn't allow to peek update) - ZINIT[annex-multi-flag:pull-active]=0 + # Read user + local compcontext="user:User Name:(\"$USER\" \"$user\")" + vared -cp "Github user name or just \"_local\" (or leave blank, for an userless plugin): " user - (( ${#ICE[@]} > 0 )) && { ZINIT_SICE[$user${${user:#(%|/)*}:+/}$plugin]=""; local nf="-nftid"; } + # Read plugin + unset compcontext + vared -cp 'Plugin name: ' plugin - .zinit-compute-ice "$user${${user:#(%|/)*}:+/}$plugin" "pack$nf" \ - ice local_dir filename is_snippet || return 1 + if [[ "$plugin" = "_unknown" ]]; then + builtin print "${ZINIT[col-error]}No plugin name entered${ZINIT[col-rst]}" + return 1 + fi - .zinit-any-to-user-plugin ${ice[teleid]:-$id_as} - user=${reply[1]} plugin=${reply[2]} + plugin="${plugin//[^a-zA-Z0-9_]##/-}" + .zinit-any-colorify-as-uspl2 "${${${(M)isorg:#(y|yes)}:+$org}:-$user}" "$plugin" + local uspl2col="$REPLY" + builtin print "Plugin is $uspl2col" - local repo="${${${(M)id_as#%}:+${id_as#%}}:-${ZINIT[PLUGINS_DIR]}/${id_as//\//---}}" + if .zinit-exists-physically "${${${(M)isorg:#(y|yes)}:+$org}:-$user}" "$plugin"; then + builtin print "${ZINIT[col-error]}Repository${ZINIT[col-rst]} $uspl2col ${ZINIT[col-error]}already exists locally${ZINIT[col-rst]}" + return 1 + fi - # Run annexes' preinit hooks - local -a arr - reply=( - ${(on)ZINIT_EXTS2[(I)zinit hook:preinit-pre <->]} - ${(on)ZINIT_EXTS[(I)z-annex hook:preinit-<-> <->]} - ${(on)ZINIT_EXTS2[(I)zinit hook:preinit-post <->]} - ) - for key in "${reply[@]}"; do - arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) - "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" ${${key##(zinit|z-annex) hook:}%% <->} update || \ - return $(( 10 - $? )) - done + builtin cd -q "${ZINIT[PLUGINS_DIR]}" - # Check if repository has a remote set, if it is _local - if [[ -f $local_dir/.git/config ]]; then - local -a config - config=( ${(f)"$(<$local_dir/.git/config)"} ) - if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]]; then - (( !OPTS[opt_-q,--quiet] )) && { - .zinit-any-colorify-as-uspl2 "$id_as" - [[ $id_as = _local/* ]] && builtin print -r -- "Skipping local plugin $REPLY" || \ - builtin print -r -- "$REPLY doesn't have a remote set, will not fetch" - } - return 1 + if [[ "$user" != "_local" && -n "$user" ]]; then + builtin print "${ZINIT[col-info]}Creating Github repository${ZINIT[col-rst]}" + if [[ $isorg = (y|yes) ]]; then + curl --silent -u "$user" https://api.github.com/orgs/$org/repos -d '{"name":"'"$plugin"'"}' >/dev/null + else + curl --silent -u "$user" https://api.github.com/user/repos -d '{"name":"'"$plugin"'"}' >/dev/null fi + command git clone "https://github.com/${${${(M)isorg:#(y|yes)}:+$org}:-$user}/${plugin}.git" "${${${(M)isorg:#(y|yes)}:+$org}:-$user}---${plugin//\//---}" || { + builtin print "${ZINIT[col-error]}Creation of remote repository $uspl2col ${ZINIT[col-error]}failed${ZINIT[col-rst]}" + builtin print "${ZINIT[col-error]}Bad credentials?${ZINIT[col-rst]}" + return 1 + } + builtin cd -q "${${${(M)isorg:#(y|yes)}:+$org}:-$user}---${plugin//\//---}" + command git config credential.https://github.com.username "${user}" + else + builtin print "${ZINIT[col-info]}Creating local git repository${${user:+.}:-, ${ZINIT[col-pname]}free-style, without the \"_local/\" part${ZINIT[col-info]}.}${ZINIT[col-rst]}" + command mkdir "${user:+${user}---}${plugin//\//---}" + builtin cd -q "${user:+${user}---}${plugin//\//---}" + command git init || { + builtin print "Git repository initialization failed, aborting" + return 1 + } fi - command rm -f $local_dir/.zinit_lastupd - - if (( 1 )); then - if [[ -z ${ice[is_release]} && ${ice[from]} = (gh-r|github-rel|cygwin) ]] { - ice[is_release]=true - } + local user_name="$(command git config user.name 2>/dev/null)" + local year="${$(command date "+%Y"):-2020}" - integer count is_release=0 - for (( count = 1; count <= 5; ++ count )) { - if (( ${+ice[is_release${count:#1}]} )) { - is_release=1 - } - } - - (( ${+functions[.zinit-setup-plugin-dir]} )) || builtin source ${ZINIT[BIN_DIR]}"/zinit-install.zsh" - if [[ $ice[from] == (gh-r|github-rel) ]] { - { - ICE=( "${(kv)ice[@]}" ) - .zinit-get-latest-gh-r-url-part "$user" "$plugin" || return $? - } always { - ICE=() - } - } else { - REPLY="" - } + command cat >! "${plugin:t}.plugin.zsh" <= 1 )) { - if (( OPTS[opt_-q,--quiet] && !PUPDATE )) { - .zinit-any-colorify-as-uspl2 "$id_as" - (( ZINIT[first-plugin-mark] )) && { - ZINIT[first-plugin-mark]=0 - } || builtin print - builtin print "\rUpdating $REPLY" - } +# According to the Zsh Plugin Standard: +# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html - ICE=( "${(kv)ice[@]}" ) - # Run annexes' atpull hooks (the before atpull-ice ones). - # The gh-r / GitHub releases block. - reply=( - ${(on)ZINIT_EXTS2[(I)zinit hook:e-\!atpull-pre <->]} - ${${(M)ICE[atpull]#\!}:+${(on)ZINIT_EXTS[(I)z-annex hook:\!atpull-<-> <->]}} - ${(on)ZINIT_EXTS2[(I)zinit hook:e-\!atpull-post <->]} - ) - for key in "${reply[@]}"; do - arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) - "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zinit|z-annex) hook:}%% <->}" update:bin - hook_rc=$? - [[ "$hook_rc" -ne 0 ]] && { - # note: this will effectively return the last != 0 rc - retval="$hook_rc" - builtin print -Pr -- "${ZINIT[col-warn]}Warning:%f%b ${ZINIT[col-obj]}${arr[5]}${ZINIT[col-warn]} hook returned with ${ZINIT[col-obj]}${hook_rc}${ZINIT[col-rst]}" - } - done +0=\${\${ZERO:-\${0:#\$ZSH_ARGZERO}}:-\${(%):-%N}} +0=\${\${(M)0:#/*}:-\$PWD/\$0} - if (( ZINIT[annex-multi-flag:pull-active] >= 2 )) { - if ! .zinit-setup-plugin-dir "$user" "$plugin" "$id_as" release -u $version; then - ZINIT[annex-multi-flag:pull-active]=0 - fi - if (( OPTS[opt_-q,--quiet] != 1 )) { - builtin print - } - } - ICE=() - } - } +# Then \${0:h} to get plugin's directory - if [[ -d $local_dir/.git ]] && ( builtin cd -q $local_dir ; git show-ref --verify --quiet refs/heads/main ); then - local main_branch=main - else - local main_branch=master - fi +if [[ \${zsh_loaded_plugins[-1]} != */${plugin:t} && -z \${fpath[(r)\${0:h}]} ]] { + fpath+=( "\${0:h}" ) +} - if (( ! is_release )) { - ( builtin cd -q "$local_dir" || return 1 - integer had_output=0 - local IFS=$'\n' - command git fetch --quiet && \ - command git --no-pager log --color --date=short --pretty=format:'%Cgreen%cd %h %Creset%s%n' ..FETCH_HEAD | \ - while read line; do - [[ -n ${line%%[[:space:]]##} ]] && { - [[ $had_output -eq 0 ]] && { - had_output=1 - if (( OPTS[opt_-q,--quiet] && !PUPDATE )) { - .zinit-any-colorify-as-uspl2 "$id_as" - (( ZINIT[first-plugin-mark] )) && { - ZINIT[first-plugin-mark]=0 - } || builtin print - builtin print "Updating $REPLY" - } - } - builtin print $line - } - done | \ - command tee .zinit_lastupd | \ - .zinit-pager & +# Standard hash for plugins, to not pollute the namespace +typeset -gA Plugins +Plugins[${${(U)plugin:t}//-/_}_DIR]="\${0:h}" - integer pager_pid=$! - { sleep 20 && kill -9 $pager_pid 2>/dev/null 1>&2; } &! - { wait $pager_pid; } > /dev/null 2>&1 +autoload -Uz template-script - local -a log - { log=( ${(@f)"$(<$local_dir/.zinit_lastupd)"} ); } 2>/dev/null - command rm -f $local_dir/.zinit_lastupd +# Use alternate vim marks [[[ and ]]] as the original ones can +# confuse nested substitutions, e.g.: \${\${\${VAR}}} - if [[ ${#log} -gt 0 ]] { - ZINIT[annex-multi-flag:pull-active]=2 - } else { - if (( ${+ice[run-atpull]} || OPTS[opt_-u,--urge] )) { - ZINIT[annex-multi-flag:pull-active]=1 +# vim:ft=zsh:tw=80:sw=4:sts=4:et:foldmarker=[[[,]]] +EOF - # Handle the snippet/plugin boundary in the messages - if (( OPTS[opt_-q,--quiet] && !PUPDATE )) { - .zinit-any-colorify-as-uspl2 "$id_as" - (( ZINIT[first-plugin-mark] )) && { - ZINIT[first-plugin-mark]=0 - } || builtin print - builtin print "\rUpdating $REPLY" - } - } else { - ZINIT[annex-multi-flag:pull-active]=0 - } - } + builtin print -r -- "# $plugin" >! "README.md" + command cp -vf "${ZINIT[BIN_DIR]}/LICENSE" LICENSE + command cp -vf "${ZINIT[BIN_DIR]}/share/template-plugin/zsh.gitignore" .gitignore + command cp -vf "${ZINIT[BIN_DIR]}/share/template-plugin/template-script" . - if (( ZINIT[annex-multi-flag:pull-active] >= 1 )) { - ICE=( "${(kv)ice[@]}" ) - # Run annexes' atpull hooks (the before atpull-ice ones). - # The regular Git-plugins block. - reply=( - ${(on)ZINIT_EXTS2[(I)zinit hook:e-\!atpull-pre <->]} - ${${(M)ICE[atpull]#\!}:+${(on)ZINIT_EXTS[(I)z-annex hook:\!atpull-<-> <->]}} - ${(on)ZINIT_EXTS2[(I)zinit hook:e-\!atpull-post <->]} - ) - for key in "${reply[@]}"; do - arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) - "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zinit|z-annex) hook:}%% <->}" update:git - hook_rc=$? - [[ "$hook_rc" -ne 0 ]] && { - # note: this will effectively return the last != 0 rc - retval="$hook_rc" - builtin print -Pr -- "${ZINIT[col-warn]}Warning:%f%b ${ZINIT[col-obj]}${arr[5]}${ZINIT[col-warn]} hook returned with ${ZINIT[col-obj]}${hook_rc}${ZINIT[col-rst]}" - } - done - ICE=() - (( ZINIT[annex-multi-flag:pull-active] >= 2 )) && command git pull --no-stat ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} |& command grep -E -v '(FETCH_HEAD|up.to.date\.|From.*://)' - } - return ${ZINIT[annex-multi-flag:pull-active]} - ) - ZINIT[annex-multi-flag:pull-active]=$? - } + command sed -i -e "s/MY_PLUGIN_DIR/${${(U)plugin:t}//-/_}_DIR/g" template-script + command sed -i -e "s/USER_NAME/$user_name/g" template-script + command sed -i -e "s/YEAR/$year/g" template-script - if [[ -d $local_dir/.git ]]; then - ( - builtin cd -q "$local_dir" # || return 1 - don't return, maybe it's some hook's logic - if (( OPTS[opt_-q,--quiet] )) { - command git pull --recurse-submodules ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} &> /dev/null - } else { - command git pull --recurse-submodules ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} |& command grep -E -v '(FETCH_HEAD|up.to.date\.|From.*://)' - } - ) + if [[ "$user" != "_local" && -n "$user" ]]; then + builtin print "Your repository is ready\!" + builtin print "An MIT LICENSE file has been placed - please review the " \ + "license terms to see if they fit your new project:" + builtin print "- https://choosealicense.com/" + builtin print "Remote repository $uspl2col set up as origin." + builtin print "You're in plugin's local folder, the files aren't added to git." + builtin print "Your next step after commiting will be:" + builtin print "git push -u origin master (or \`… -u origin main')" + else + builtin print "Created local $uspl2col plugin." + builtin print "You're in plugin's repository folder, the files aren't added to git." + fi +} # ]]] +# FUNCTION: .zinit-delete [[[ +# Deletes a plugin or snippet and related files and hooks. +# +# $1 - snippet url or plugin +.zinit-delete () { + emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + setopt extendedglob noksharrays nokshglob nullglob typesetsilent warncreateglobal + local o_all o_clean o_debug o_help o_verbose o_yes rc + local -a usage=( + 'Usage:' + ' zinit delete [options] [plugins...]' + ' ' + 'Options:' + ' -a, --all Delete all installed plugins, snippets, and completions' + ' -c, --clean Delete unloaded plugins and snippets' + ' -h, --help Show list of command-line options' + ' -y, --yes Don´t prompt for user confirmation' + ) + zmodload zsh/zutil + zparseopts -D -F -K -- \ + {a,-all}=o_all \ + {c,-clean}=o_clean \ + {d,-dry-run}=o_debug \ + {h,-help}=o_help \ + {y,-yes}=o_yes \ + || return 1 + (( $#o_help )) && { + print -l -- $usage + return 0 + } + (( $#o_clean && $#o_all )) && { + +zinit-message "{e} Invalid usage: Options --all and --clean are mutually exclusive" + return 1 + } + (( $#o_clean )) && { + local -a unld_plgns + local -aU ld_snips unld_snips del_list + local snip plugin _retval dir=${${ZINIT[SNIPPETS_DIR]%%[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/xyzcba231} + + unld_snips=( $dir/*/*/*(ND/) $dir/*/*(ND/) $dir/*(ND/) ) + ld_snips=(${${ZINIT_SNIPPETS[@]% <*>}/(#m)*/$(.zinit-get-object-path snippet "$MATCH" && builtin print -rn -- $REPLY; )}) + del_list=(${unld_snips[@]:#*/(${(~j:|:)ld_snips}|*/plugins|._backup|._zinit|.svn|.git)(|/*)}) + del_list=(${del_list[@]//(#m)*/$( .zinit-get-object-path snippet "${${${MATCH##${dir}[/[:space:]]#}/(#i)(#b)(http(s|)|ftp(s|)|ssh|rsync)--/${match[1]##--}://}//--//}" && builtin print -r -- $REPLY)}) + del_list=(${del_list[@]:#(${(~j:|:)ld_snips}|*/plugins|*/._backup|*/._zinit|*/.svn|*/.git)(|/*)}) + unld_snips=(${${${(@)${(@)del_list##$dir/#}//(#i)(#m)(http(s|)|ftp(s|)|ssh|rsync)--/${MATCH%--}://}//--//}//(#b)(*)\/([^\/]##)(#e)/$match[1]/$ZINIT[col-file]$match[2]$ZINIT[col-rst]}) + unld_snips=(${unld_snips[@]//(#m)(#s)[^\/]##(#e)/$ZINIT[col-file]$MATCH$ZINIT[col-rst]}) + del_list=(${${${(@)${(@)del_list##$dir/#}//(#i)(#m)(http(s|)|ftp(s|)|ssh|rsync)--/${MATCH%--}://}//--//}//(#b)(*)\/([^\/]##)(#e)/$match[1]/$match[2]}) + unld_plgns=(${${ZINIT[PLUGINS_DIR]%%[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcEFG312}/*~*/(${(~j:|:)${ZINIT_REGISTERED_PLUGINS[@]//\//---}})(ND/)) + unld_plgns=(${(@)${unld_plgns[@]##$ZINIT[PLUGINS_DIR]/#}//---//}) + # delete unloaded snippets & plugins + (( $#del_list || $#unld_plgns )) && { + +zinit-message "{m} Deleting {num}${#unld_snips}{rst} unloaded snippets:" $unld_snips + +zinit-message "{m} Deleting {num}${#unld_plgns}{rst} unloaded plugins:" $unld_plgns + if (( $#o_yes )) || ( .zinit-prompt "delete ${#unld_snips} snippets and ${#unld_plgns} plugins?"); then + for snip in $del_list $unld_plgns ; do + zinit delete --yes "$snip" + _retval+=$? + done + return _retval fi - if [[ -n ${(v)ice[(I)(mv|cp|atpull|ps-on-update|cargo)]} || $+ice[sbin]$+ice[make]$+ice[extract]$+ice[configure] -ne 0 ]] { - if (( !OPTS[opt_-q,--quiet] && ZINIT[annex-multi-flag:pull-active] == 1 )) { - +zinit-message -n "{pre}[update]{msg3} Continuing with the update because " - (( ${+ice[run-atpull]} )) && \ - +zinit-message "{ice}run-atpull{apo}''{msg3} ice given.{rst}" || \ - +zinit-message "{opt}-u{msg3}/{opt}--urge{msg3} given.{rst}" - } - } - - # Any new commits? - if (( ZINIT[annex-multi-flag:pull-active] >= 1 )) { - ICE=( "${(kv)ice[@]}" ) - # Run annexes' atpull hooks (the before atpull[^!]…-ice ones). - # Block common for Git and gh-r plugins. - reply=( - ${(on)ZINIT_EXTS2[(I)zinit hook:no-e-\!atpull-pre <->]} - ${${ICE[atpull]:#\!*}:+${(on)ZINIT_EXTS[(I)z-annex hook:\!atpull-<-> <->]}} - ${(on)ZINIT_EXTS2[(I)zinit hook:no-e-\!atpull-post <->]} - ) - for key in "${reply[@]}"; do - arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) - "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zinit|z-annex) hook:}%% <->}" update - hook_rc="$?" - [[ "$hook_rc" -ne 0 ]] && { - # note: this will effectively return the last != 0 rc - retval="$hook_rc" - builtin print -Pr -- "${ZINIT[col-warn]}Warning:%f%b ${ZINIT[col-obj]}${arr[5]}${ZINIT[col-warn]} hook returned with ${ZINIT[col-obj]}${hook_rc}${ZINIT[col-rst]}" - } + } || { + +zinit-message "{m} No unloaded plugins or snippets to delete" + return 0 + } + } + if (( $#o_all && !$#o_clean )); then + local -a all_installed=(${${ZINIT[PLUGINS_DIR]}%%[/[:space:]]##}/*~*/_local---zinit(/ND) ${${ZINIT[SNIPPETS_DIR]}%%[/[:space:]]##}/*~*/plugins(/ND)) + if (( $#o_yes )) || ( .zinit-prompt "Delete all plugins and snippets (${#all_installed} total)"); then + command rm -rf -- ${(@)all_installed} + command rm -f -- $ZINIT[HOME_DIR]/**/*(-@N) + for f in ${(M)${(k)ZINIT[@]}:##STATES__*~*local/zinit*}; do + builtin unset "ZINIT[$f]" done - - # Run annexes' atpull hooks (the after atpull-ice ones). - # Block common for Git and gh-r plugins. - reply=( - ${(on)ZINIT_EXTS2[(I)zinit hook:atpull-pre <->]} - ${(on)ZINIT_EXTS[(I)z-annex hook:atpull-<-> <->]} - ${(on)ZINIT_EXTS2[(I)zinit hook:atpull-post <->]} - ) - for key in "${reply[@]}"; do - arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) - "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zinit|z-annex) hook:}%% <->}" update - hook_rc="$?" - [[ "$hook_rc" -ne 0 ]] && { - # note: this will effectively return the last != 0 rc - retval="$hook_rc" - builtin print -Pr -- "${ZINIT[col-warn]}Warning:%f%b ${ZINIT[col-obj]}${arr[5]}${ZINIT[col-warn]} hook returned with ${ZINIT[col-obj]}${hook_rc}${ZINIT[col-rst]}" + local rc=$? + +zinit-message "{m} Deleted all completed with return code {num}${rc}{rst}" + return $rc + fi + return 1 + fi + (( !$# )) && { + +zinit-message "{e} Invalid usage: This command requires at least 1 plugin or snippet argument." + return 0 + } + local i + if (( $#o_yes )) || ( .zinit-prompt "Delete ${(j:, :)@}"); then + local -A ICE ICE2 + for i in $@; do + local the_id="${${i:#(%|/)*}}" filename is_snippet local_dir + .zinit-compute-ice "$the_id" "pack" ICE2 local_dir filename is_snippet || return 1 + if [[ "$local_dir" != /* ]]; then + +zinit-message "{w} No available plugin or snippet with the name '$i'" + return 1 + fi + ICE2[teleid]="${ICE2[teleid]:-${ICE2[id-as]}}" + local -a files + files=("$local_dir"/*(%DN:t) "$local_dir"/*(*DN:t) "$local_dir"/*(.DN:t) "$local_dir"/*(=DN:t) "$local_dir"/*(@DN:t) "$local_dir"/*(pDN:t) "$local_dir"/*.(zsh|sh|bash|ksh)(DN:t) "$local_dir"/*~*/.(_zinit|svn|git)(/DN:t)) + (( !${#files} )) && files=("no files?") + files=(${(@)files[1,4]} ${files[4]+more…}) + ICE=("${(kv)ICE2[@]}") + if [[ -e $local_dir ]]; then + (( is_snippet )) && { + .zinit-run-delete-hooks snippet "${ICE2[teleid]}" "" "$the_id" "$local_dir" + } || { + .zinit-any-to-user-plugin "${ICE2[teleid]}" + .zinit-run-delete-hooks plugin "${reply[-2]}" "${reply[-1]}" "$the_id" "$local_dir" } - done - ICE=() - } + command rm -rf -- ${(q)${${local_dir:#[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcYZX321}}(N) # delete files + command rm -f -- $ZINIT[HOME_DIR]/**/*(-@N) # delete broken symlins + builtin unset "ZINIT[STATES__${ICE2[id-as]}]" || builtin unset "ZINIT[STATES__${ICE2[teleid]}]" + +zinit-message "{m} Uninstalled $i" + else + +zinit-message "{w} No available plugin or snippet with the name '$i'" + return 1 + fi + done + fi + return 0 +} # ]]] +# FUNCTION: .zinit-edit [[[ +# Runs $EDITOR on source of given plugin. If the variable is not +# set then defaults to `vim'. +# +# User-action entry point. +# +# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) +# $2 - plugin (only when $1 - i.e. user - given) +.zinit-edit() { + local -A ICE2 + local local_dir filename is_snippet the_id="$1${${1:#(%|/)*}:+${2:+/}}$2" - # Store ices to disk at update of plugin - .zinit-store-ices "$local_dir/._zinit" ice "" "" "" "" + .zinit-compute-ice "$the_id" "pack" \ + ICE2 local_dir filename is_snippet || return 1 + + ICE2[teleid]="${ICE2[teleid]:-${ICE2[id-as]}}" + + if (( is_snippet )); then + if [[ ! -e "$local_dir" ]]; then + builtin print "No such snippet" + return 1 + fi + else + if [[ ! -e "$local_dir" ]]; then + builtin print -r -- "No such plugin or snippet" + return 1 + fi fi - # Run annexes' atpull hooks (the `always' after atpull-ice ones) - # Block common for Git and gh-r plugins. - ICE=( "${(kv)ice[@]}" ) - reply=( - ${(on)ZINIT_EXTS2[(I)zinit hook:%atpull-pre <->]} - ${(on)ZINIT_EXTS[(I)z-annex hook:%atpull-<-> <->]} - ${(on)ZINIT_EXTS2[(I)zinit hook:%atpull-post <->]} - ) - for key in "${reply[@]}"; do - arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) - "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zinit|z-annex) hook:}%% <->}" update:$ZINIT[annex-multi-flag:pull-active] - hook_rc=$? - [[ "$hook_rc" -ne 0 ]] && { - # note: this will effectively return the last != 0 rc - retval="$hook_rc" - builtin print -Pr -- "${ZINIT[col-warn]}Warning:%f%b ${ZINIT[col-obj]}${arr[5]}${ZINIT[col-warn]} hook returned with ${ZINIT[col-obj]}${hook_rc}${ZINIT[col-rst]}" - } + "${EDITOR:-vim}" "$local_dir" + return 0 +} # ]]] +# FUNCTION: .zinit-get-path [[[ +# Returns path of given ID-string, which may be a plugin-spec +# (like "user/plugin" or "user" "plugin"), an absolute path +# ("%" "/home/..." and also "%SNIPPETS/..." etc.), or a plugin +# nickname (i.e. id-as'' ice-mod), or a snippet nickname. +.zinit-get-path() { + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + setopt extendedglob warncreateglobal typesetsilent noshortloops + + [[ $1 == % ]] && local id_as=%$2 || local id_as=$1${1:+/}$2 + .zinit-get-object-path snippet "$id_as" || \ + .zinit-get-object-path plugin "$id_as" + + return $(( 1 - reply[3] )) +} # ]]] +# FUNCTION: .zinit-glance [[[ +# Shows colorized source code of plugin. Is able to use pygmentize, +# highlight, GNU source-highlight. +# +# User-action entry point. +# +# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) +# $2 - plugin (only when $1 - i.e. user - given) +.zinit-glance() { + .zinit-any-to-user-plugin "$1" "$2" + local user="${reply[-2]}" plugin="${reply[-1]}" + + .zinit-exists-physically-message "$user" "$plugin" || return 1 + + .zinit-first "$1" "$2" || { + +zinit-message '{log-err} No source file found, cannot glance' + return 1 + } + + local fname="${reply[-1]}" + + integer has_256_colors=0 + [[ "$TERM" = xterm* || "$TERM" = "screen" ]] && has_256_colors=1 + + { + if (( ${+commands[pygmentize]} )); then + +zinit-message "{log-info} Inspecting via {cmd}pygmentize{rst}" + pygmentize -l 'bash' "$fname" + elif (( ${+commands[highlight]} )); then + +zinit-message "{log-info} Inspecting via {cmd}highlight{rst}" + if (( has_256_colors )); then + highlight --force --output-format xterm256 --quiet --syntax sh "$fname" + else + highlight --force --output-format ansi --quiet --syntax sh "$fname" + fi + elif (( ${+commands[source-highlight]} )); then + +zinit-message "{log-info} Inspecting via {cmd}source-highlight{rst}" + source-highlight -fesc --failsafe -s zsh -o STDOUT -i "$fname" + else + cat "$fname" + fi + } | { + if [[ -t 1 ]]; then + .zinit-pager + else + cat + fi + } +} # ]]] +# FUNCTION: .zinit-help [[[ +# Shows usage information. +# +# User-action entry point. +.zinit-help() { + builtin print -r -- "${ZINIT[col-p]}Usage${ZINIT[col-rst]}: +—— -h|--help|help – usage information +—— man – manual +—— version – display zinit version +—— self-update – updates and compiles Zinit +—— zstatus – overall Zinit statu—— 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 +—— load ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – load plugin, can also receive absolute local path +—— light [-b] ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – light plugin load, without reporting/tracking (-b – do track but bindkey-calls only) +—— unload ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – unload plugin loaded with \`zinit load ...', -q – quiet +—— snippet [-f] ${ZINIT[col-pname]}{url}${ZINIT[col-rst]} – source local or remote file (by direct URL), -f: force – don't use cache +—— ls – list snippets in formatted and colorized manner +—— ice – add ICE to next command, argument is e.g. from\"gitlab\" +—— 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 +—— 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) +—— report ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – show plugin's report (or all plugins' if ——all passed) +—— delete [--all|--clean] ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]}|URL – remove plugin or snippet from disk (good to forget wrongly passed ice-mods); --all – purge, --clean – delete plugins and snippets that are not loaded +—— loaded|list {keyword} – show what plugins are loaded (filter with \'keyword') +—— cd ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – cd into plugin's directory; also support snippets, if feed with URL +—— create ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – create plugin (also together with Github repository) +—— edit ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – edit plugin's file with \$EDITOR +—— glance ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – look at plugin's source (pygmentize, {,source-}highlight) +—— stress ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – test plugin for compatibility with set of options +—— changes ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – view plugin's git log +—— recently ${ZINIT[col-info]}[time-spec]${ZINIT[col-rst]} – show plugins that changed recently, argument is e.g. 1 month 2 days +—— clist|completions – list completions in use +—— cdisable ${ZINIT[col-info]}cname${ZINIT[col-rst]} – disable completion \`cname' +—— cenable ${ZINIT[col-info]}cname${ZINIT[col-rst]} – enable completion \`cname' +—— creinstall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – install completions for plugin, can also receive absolute local path; -q – quiet +—— cuninstall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – uninstall completions for plugin +—— csearch – search for available completions from any plugin +—— compinit – refresh installed completions +—— dtrace|dstart – start tracking what's going on in session +—— dstop – stop tracking what's going on in session +—— dunload – revert changes recorded between dstart and dstop +—— dreport – report what was going on in session +—— dclear – clear report of what was going on in session +—— compile ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – compile plugin (or all plugins if ——all passed) +—— uncompile ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – remove compiled version of plugin (or of all plugins if ——all passed) +—— compiled – list plugins that are compiled +—— cdlist – show compdef replay list +—— cdreplay [-q] – replay compdefs (to be done after compinit), -q – quiet +—— cdclear [-q] – clear compdef replay list, -q – quiet +—— srv {service-id} [cmd] – control a service, command can be: stop,start,restart,next,quit; \`next' moves the service to another Zshell +—— recall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]}|URL – fetch saved ice modifiers and construct \`zinit ice ...' command +—— env-whitelist [-v|-h] {env..} – allows to specify names (also patterns) of variables left unchanged during an unload. -v – verbose +—— bindkeys – lists bindkeys set up by each plugin +—— module – manage binary Zsh module shipped with Zinit, see \`zinit module help' +—— 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" + + integer idx + local type key + local -a arr + for type in subcommand hook; do + for (( idx=1; idx <= ZINIT_EXTS[seqno]; ++ idx )); do + key="${(k)ZINIT_EXTS[(r)$idx *]}" + [[ -z "$key" || "$key" != "z-annex $type:"* ]] && continue + arr=( "${(Q)${(z@)ZINIT_EXTS[$key]}[@]}" ) + (( ${+functions[${arr[6]}]} )) && { "${arr[6]}"; ((1)); } || \ + { builtin print -rl -- "(Couldn't find the help-handler \`${arr[6]}' of the z-annex \`${arr[3]}')"; } + done done - ICE=() - typeset -ga INSTALLED_EXECS - { INSTALLED_EXECS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zinit-execs.$$.lst)}" ) } 2>/dev/null +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[*]}" +} # ]]] - if [[ -e ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.skipped_comps.$$.lst || -e ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.installed_comps.$$.lst ]] { - typeset -ga INSTALLED_COMPS SKIPPED_COMPS - { INSTALLED_COMPS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zinit.installed_comps.$$.lst)}" ) } 2>/dev/null - { SKIPPED_COMPS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zinit.skipped_comps.$$.lst)}" ) } 2>/dev/null - } +# FUNCTION: .zinit-list-bindkeys [[[ +.zinit-list-bindkeys() { + local uspl2 uspl2col sw first=1 + local -a string_widget - if [[ -e ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.compiled.$$.lst ]] { - typeset -ga ADD_COMPILED - { ADD_COMPILED=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zinit.compiled.$$.lst)}" ) } 2>/dev/null - } + # KSH_ARRAYS immunity + integer correct=0 + [[ -o "KSH_ARRAYS" ]] && correct=1 - if (( PUPDATE && ZINIT[annex-multi-flag:pull-active] > 0 )) { - builtin print ${ZINIT[annex-multi-flag:pull-active]} >! $PUFILE.ind - } + for uspl2 in "${(@ko)ZINIT[(I)BINDKEYS__*]}"; do + [[ -z "${ZINIT[$uspl2]}" ]] && continue - return $retval -} # ]]] -# FUNCTION: .zinit-update-or-status-snippet [[[ -# -# Implements update or status operation for snippet given by URL. -# -# $1 - "status" or "update" -# $2 - snippet URL -.zinit-update-or-status-snippet() { - local st="$1" URL="${2%/}" local_dir filename is_snippet - (( ${#ICE[@]} > 0 )) && { ZINIT_SICE[$URL]=""; local nf="-nftid"; } - local -A ICE2 - .zinit-compute-ice "$URL" "pack$nf" \ - ICE2 local_dir filename is_snippet || return 1 + (( !first )) && builtin print + first=0 - integer retval + uspl2="${uspl2#BINDKEYS__}" - if [[ "$st" = "status" ]]; then - if (( ${+ICE2[svn]} )); then - builtin print -r -- "${ZINIT[col-info]}Status for ${${${local_dir:h}:t}##*--}/${local_dir:t}${ZINIT[col-rst]}" - ( builtin cd -q "$local_dir"; command svn status -vu ) - retval=$? - builtin print - else - builtin print -r -- "${ZINIT[col-info]}Status for ${${local_dir:h}##*--}/$filename${ZINIT[col-rst]}" - ( builtin cd -q "$local_dir"; command ls -lth $filename ) - retval=$? - builtin print - fi - else - (( ${+functions[.zinit-setup-plugin-dir]} )) || builtin source ${ZINIT[BIN_DIR]}"/zinit-install.zsh" - ICE=( "${(kv)ICE2[@]}" ) - .zinit-update-snippet "${ICE2[teleid]:-$URL}" - retval=$? - fi + .zinit-any-colorify-as-uspl2 "$uspl2" + uspl2col="$REPLY" + builtin print "$uspl2col" - ICE=() + string_widget=( "${(z@)ZINIT[BINDKEYS__$uspl2]}" ) + for sw in "${(Oa)string_widget[@]}"; do + [[ -z "$sw" ]] && continue + # Remove one level of quoting to split using (z) + sw="${(Q)sw}" + typeset -a sw_arr + sw_arr=( "${(z@)sw}" ) - if (( PUPDATE && ZINIT[annex-multi-flag:pull-active] > 0 )) { - builtin print ${ZINIT[annex-multi-flag:pull-active]} >! $PUFILE.ind - } + # Remove one level of quoting to pass to bindkey + local sw_arr1="${(Q)sw_arr[1-correct]}" # Keys + local sw_arr2="${(Q)sw_arr[2-correct]}" # Widget + local sw_arr3="${(Q)sw_arr[3-correct]}" # Optional -M or -A or -N + local sw_arr4="${(Q)sw_arr[4-correct]}" # Optional map name + local sw_arr5="${(Q)sw_arr[5-correct]}" # Optional -R (not with -A, -N) - return $retval + if [[ "$sw_arr3" = "-M" && "$sw_arr5" != "-R" ]]; then + builtin print "bindkey $sw_arr1 $sw_arr2 ${ZINIT[col-info]}for keymap $sw_arr4${ZINIT[col-rst]}" + elif [[ "$sw_arr3" = "-M" && "$sw_arr5" = "-R" ]]; then + builtin print "${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey $sw_arr1 $sw_arr2 ${ZINIT[col-info]}mapped to $sw_arr4${ZINIT[col-rst]}" + elif [[ "$sw_arr3" != "-M" && "$sw_arr5" = "-R" ]]; then + builtin print "${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey $sw_arr1 $sw_arr2" + elif [[ "$sw_arr3" = "-A" ]]; then + builtin print "Override of keymap \`main'" + elif [[ "$sw_arr3" = "-N" ]]; then + builtin print "New keymap \`$sw_arr4'" + else + builtin print "bindkey $sw_arr1 $sw_arr2" + fi + done + done } # ]]] -# FUNCTION: .zinit-update-or-status-all [[[ -# Updates (git pull) or does `git status` for all existing plugins. -# This includes also plugins that are not loaded into Zsh (but exist -# on disk). Also updates (i.e. redownloads) snippets. +# FUNCTION: .zinit-list-compdef-replay [[[ +# Shows recorded compdefs (called by plugins loaded earlier). +# Plugins often call `compdef' hoping for `compinit' being +# already ran. Zinit solves this by recording compdefs. # # User-action entry point. -.zinit-update-or-status-all() { +.zinit-list-compdef-replay() { + builtin print "Recorded compdefs:" + local cdf + for cdf in "${ZINIT_COMPDEF_REPLAY[@]}"; do + builtin print "compdef ${(Q)cdf}" + done +} # ]]] +# FUNCTION: .zinit-list-plugins [[[ +# Lists loaded plugins (subcommands list, lodaded) +.zinit-list-plugins() { builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops + setopt extendedglob warncreateglobal typesetsilent noshortloops + typeset -a filtered + local keyword="$1" + keyword="${keyword## ##}" + keyword="${keyword%% ##}" + if [[ -n "$keyword" ]]; then + +zinit-message "{i} Installed plugins matching {info}$keyword{rst}:" + filtered=( "${(M)ZINIT[@]:#STATES__*$keyword*}" ) + else + filtered=(${${(M)${(k)ZINIT[@]}:##STATES__*}//[A-Z]*__/}) + fi + local i + +zinit-message '{m} {b}Plugins{rst}' + for i in "${(o)filtered[@]}"; do + [[ "$i" = "local/zinit" ]] && continue + local is_loaded='{error}U' + (( "ZINIT[STATES__$i]" )) && is_loaded="{happy}L" + +zinit-message -C2 -- $is_loaded{rst} $i + done + +zinit-message -- '{nl}Loaded: {happy}L{rst} | Unloaded: {error}U{rst}' +} # ]]] +# FUNCTION: .zinit-list-snippets [[[ +.zinit-list-snippets() { + (( ${+commands[tree]} )) || { + builtin print "${ZINIT[col-error]}No \`tree' program, it is required by the subcommand \`ls\'${ZINIT[col-rst]}" + builtin print "Download from: http://mama.indstate.edu/users/ice/tree/" + builtin print "It is also available probably in all distributions and Homebrew, as package \`tree'" + } + ( + setopt localoptions extendedglob nokshglob noksharrays + builtin cd -q "${ZINIT[SNIPPETS_DIR]}" + local -a list + local -x LANG=en_US.utf-8 + list=( "${(f@)"$(${=ZINIT[LIST_COMMAND]})"}" ) + # Oh-My-Zsh single file + list=( "${list[@]//(#b)(https--github.com--(ohmyzsh|robbyrussel)l--oh-my-zsh--raw--master(--)(#c0,1)(*))/$ZINIT[col-info]Oh-My-Zsh$ZINIT[col-error]${match[2]/--//}$ZINIT[col-pname]${match[3]//--/$ZINIT[col-error]/$ZINIT[col-pname]} $ZINIT[col-info](single-file)$ZINIT[col-rst] ${match[1]}}" ) + # Oh-My-Zsh SVN + list=( "${list[@]//(#b)(https--github.com--(ohmyzsh|robbyrussel)l--oh-my-zsh--trunk(--)(#c0,1)(*))/$ZINIT[col-info]Oh-My-Zsh$ZINIT[col-error]${match[2]/--//}$ZINIT[col-pname]${match[3]//--/$ZINIT[col-error]/$ZINIT[col-pname]} $ZINIT[col-info](SVN)$ZINIT[col-rst] ${match[1]}}" ) + # Prezto single file + list=( "${list[@]//(#b)(https--github.com--sorin-ionescu--prezto--raw--master(--)(#c0,1)(*))/$ZINIT[col-info]Prezto$ZINIT[col-error]${match[2]/--//}$ZINIT[col-pname]${match[3]//--/$ZINIT[col-error]/$ZINIT[col-pname]} $ZINIT[col-info](single-file)$ZINIT[col-rst] ${match[1]}}" ) + # Prezto SVN + list=( "${list[@]//(#b)(https--github.com--sorin-ionescu--prezto--trunk(--)(#c0,1)(*))/$ZINIT[col-info]Prezto$ZINIT[col-error]${match[2]/--//}$ZINIT[col-pname]${match[3]//--/$ZINIT[col-error]/$ZINIT[col-pname]} $ZINIT[col-info](SVN)$ZINIT[col-rst] ${match[1]}}" ) - local -F2 SECONDS=0 + # First-level names + list=( "${list[@]//(#b)(#s)(│   └──| └──| ├──|│   ├──) (*)/${match[1]} $ZINIT[col-p]${match[2]}$ZINIT[col-rst]}" ) - .zinit-self-update -q + list[-1]+=", located at ZINIT[SNIPPETS_DIR], i.e. ${ZINIT[SNIPPETS_DIR]}" + builtin print -rl -- "${list[@]}" + ) +} # ]]] - [[ $2 = restart ]] && \ - +zinit-message "{msg2}Restarting the update with the new codebase loaded.{rst}"$'\n' +# FUNCTION: .zinit-prompt [[[ +# Prompt user to confirm +# +# $1 - prompt +# +# $REPLY - 0 or 1 +.zinit-prompt () { + local REPLY + read -q ${(%):-"?%s%F{cyan}==>%f%s ${1}? [y/N]: "} && REPLY=y + print '' + [[ $REPLY == y ]] && return 0 || return 1 +} # ]]] +# FUNCTION: .zinit-recall [[[ +.zinit-recall() { + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + setopt extendedglob warncreateglobal typesetsilent noshortloops - local file - integer sum el update_rc - for file ( "" -side -install -autoload ) { - .zinit-get-mtime-into "${ZINIT[BIN_DIR]}/zinit$file.zsh" el; sum+=el - } + local -A ice + local el val cand1 cand2 local_dir filename is_snippet - # Reload Zinit? - if [[ $2 != restart ]] && (( ZINIT[mtime] + ZINIT[mtime-side] + - ZINIT[mtime-install] + ZINIT[mtime-autoload] != sum - )) { - +zinit-message "{msg2}Detected Zinit update in another session -" \ - "{pre}reloading Zinit{msg2}{…}{rst}" - source $ZINIT[BIN_DIR]/zinit.zsh - source $ZINIT[BIN_DIR]/zinit-side.zsh - source $ZINIT[BIN_DIR]/zinit-install.zsh - source $ZINIT[BIN_DIR]/zinit-autoload.zsh - for file ( "" -side -install -autoload ) { - .zinit-get-mtime-into "${ZINIT[BIN_DIR]}/zinit$file.zsh" "ZINIT[mtime$file]" - } - +zinit-message "%B{pname}Done.{rst}"$'\n' - .zinit-update-or-status-all "$1" restart - return $? - } + local -a ice_order nval_ices output + ice_order=( + ${(s.|.)ZINIT[ice-list]} - integer retval + # Include all additional ices – after + # stripping them from the possible: '' + ${(@)${(@Akons:|:u)${ZINIT_EXTS[ice-mods]//\'\'/}}/(#s)<->-/} + ) + nval_ices=( + ${(s.|.)ZINIT[nval-ice-list]} + # Include only those additional ices, + # don't have the '' in their name, i.e. + # aren't designed to hold value + ${(@)${(@)${(@Akons:|:u)ZINIT_EXTS[ice-mods]}:#*\'\'*}/(#s)<->-/} - if (( OPTS[opt_-p,--parallel] )) && [[ $1 = update ]] { - (( !OPTS[opt_-q,--quiet] )) && \ - +zinit-message '{info2}Parallel Update Starts Now{…}{rst}' - .zinit-update-all-parallel - retval=$? - .zinit-compinit 1 1 &>/dev/null - rehash - if (( !OPTS[opt_-q,--quiet] )) { - +zinit-message "{msg2}The update took {obj}${SECONDS}{msg2} seconds{rst}" - } - return $retval - } + # Must be last + svn + ) + .zinit-compute-ice "$1${${1:#(%|/)*}:+${2:+/}}$2" "pack" \ + ice local_dir filename is_snippet || return 1 - local st=$1 id_as repo snip pd user plugin - integer PUPDATE=0 + [[ -e $local_dir ]] && { + for el ( ${ice_order[@]} ) { + val="${ice[$el]}" + cand1="${(qqq)val}" + cand2="${(qq)val}" + if [[ -n "$val" ]] { + [[ "${cand1/\\\$/}" != "$cand1" || "${cand1/\\\!/}" != "$cand1" ]] && output+=( "$el$cand2" ) || output+=( "$el$cand1" ) + } elif [[ ${+ice[$el]} = 1 && -n "${nval_ices[(r)$el]}" ]] { + output+=( "$el" ) + } + } - local -A ICE + if [[ ${#output} = 0 ]]; then + builtin print -zr "# No Ice modifiers" + else + builtin print -zr "zinit ice ${output[*]}; zinit " + fi + +zinit-deploy-message @rst + } || builtin print -r -- "No such plugin or snippet" +} # ]]] +# FUNCTION: .zinit-recently [[[ +# Shows plugins that obtained commits in specified past time. +# +# User-action entry point. +# +# $1 - time spec, e.g. "1 week" +.zinit-recently() { + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt nullglob extendedglob warncreateglobal \ + typesetsilent noshortloops + local IFS=. + local gitout + local timespec=${*// ##/.} + timespec=${timespec//.##/.} + [[ -z $timespec ]] && timespec=1.week - if (( OPTS[opt_-s,--snippets] || !OPTS[opt_-l,--plugins] )) { - local -a snipps - snipps=( ${ZINIT[SNIPPETS_DIR]}/**/(._zinit|._zplugin)(ND) ) + typeset -a plugins + plugins=( ${ZINIT[PLUGINS_DIR]}/*(DN-/) ) - [[ $st != status && ${OPTS[opt_-q,--quiet]} != 1 && -n $snipps ]] && \ - +zinit-message "{info}Note:{rst} updating also unloaded snippets" + local p uspl1 + for p in ${plugins[@]}; do + uspl1=${p:t} + [[ $uspl1 = custom || $uspl1 = _local---zinit ]] && continue - for snip ( ${ZINIT[SNIPPETS_DIR]}/**/(._zinit|._zplugin)/mode(D) ) { - [[ ! -f ${snip:h}/url ]] && continue - [[ -f ${snip:h}/id-as ]] && \ - id_as="$(<${snip:h}/id-as)" || \ - id_as= - .zinit-update-or-status-snippet "$st" "${id_as:-$(<${snip:h}/url)}" - ICE=() - } - [[ -n $snipps ]] && builtin print + pushd "$p" >/dev/null || continue + if [[ -d .git ]]; then + gitout=`command git log --all --max-count=1 --since=$timespec 2>/dev/null` + if [[ -n $gitout ]]; then + .zinit-any-colorify-as-uspl2 "$uspl1" + builtin print -r -- "$REPLY" + fi + fi + popd >/dev/null + done +} # ]]] +# FUNCTION: .zinit-run-delete-hooks [[[ +.zinit-run-delete-hooks() { + # Call make uninstall if available + local make_path=$5/Makefile + [[ -f $make_path ]] && grep '^uninstall:' $make_path &>/dev/null && { + +zinit-message "{m} Running {cmd}make uninstall{rst}" + make -C "$make_path:h" uninstall; } - ICE=() + if [[ -n ${ICE[atdelete]} ]]; then + .zinit-countdown "atdelete" && ( + (( ${+ICE[nocd]} == 0 )) && { + builtin cd -q "$5" && eval "${ICE[atdelete]}"; ((1)); + } || eval "${ICE[atdelete]}" + ) + fi - if (( OPTS[opt_-s,--snippets] && !OPTS[opt_-l,--plugins] )) { - return - } + local -a arr + local key + # Run annexes' atdelete hooks + reply=( + ${(on)ZINIT_EXTS2[(I)zinit hook:atdelete-pre <->]} + ${(on)ZINIT_EXTS[(I)z-annex hook:atdelete-<-> <->]} + ${(on)ZINIT_EXTS2[(I)zinit hook:atdelete-post <->]} + ) + for key in "${reply[@]}"; do + arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) + "${arr[5]}" "$1" "$2" $3 "$4" "$5" "${${key##(zinit|z-annex) hook:}%% <->}" delete:TODO + done +} # ]]] +# FUNCTION: .zinit-search-completions [[[ +# While .zinit-show-completions() shows what completions are +# installed, this functions searches through all plugin dirs +# showing what's available in general (for installation). +# +# User-action entry point. +.zinit-search-completions() { + builtin setopt localoptions nullglob extendedglob nokshglob noksharrays - if [[ $st = status ]]; then - (( !OPTS[opt_-q,--quiet] )) && \ - +zinit-message "{info}Note:{rst} status done also for unloaded plugins" - else - (( !OPTS[opt_-q,--quiet] )) && \ - +zinit-message "{info}Note:{rst} updating also unloaded plugins" - fi + typeset -a plugin_paths + plugin_paths=( "${ZINIT[PLUGINS_DIR]}"/*(DN) ) - ZINIT[first-plugin-mark]=init + # Find longest plugin name. Things are ran twice here, first pass + # is to get longest name of plugin which is having any completions + integer longest=0 + typeset -a completions + local pp + for pp in "${plugin_paths[@]}"; do + completions=( "$pp"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) ) + if [[ "${#completions[@]}" -gt 0 ]]; then + local pd="${pp:t}" + [[ "${#pd}" -gt "$longest" ]] && longest="${#pd}" + fi + done - for repo in ${ZINIT[PLUGINS_DIR]}/*; do - pd=${repo:t} + builtin print "${ZINIT[col-info]}[+]${ZINIT[col-rst]} is installed, ${ZINIT[col-p]}[-]${ZINIT[col-rst]} uninstalled, ${ZINIT[col-error]}[+-]${ZINIT[col-rst]} partially installed" - # Two special cases - [[ $pd = custom || $pd = _local---zinit ]] && continue + local c + for pp in "${plugin_paths[@]}"; do + completions=( "$pp"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) ) - .zinit-any-colorify-as-uspl2 "$pd" + if [[ "${#completions[@]}" -gt 0 ]]; then + # Array of completions, e.g. ( _cp _xauth ) + completions=( "${completions[@]:t}" ) - # Check if repository has a remote set - if [[ -f $repo/.git/config ]]; then - local -a config - config=( ${(f)"$(<$repo/.git/config)"} ) - if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]]; then - if (( !OPTS[opt_-q,--quiet] )) { - [[ $pd = _local---* ]] && \ - builtin print -- "\nSkipping local plugin $REPLY" || \ - builtin print "\n$REPLY doesn't have a remote set, will not fetch" - } - continue + # Detect if the completions are installed + integer all_installed="${#completions[@]}" + for c in "${completions[@]}"; do + if [[ -e "${ZINIT[COMPLETIONS_DIR]}/$c" || -e "${ZINIT[COMPLETIONS_DIR]}/${c#_}" ]]; then + (( all_installed -- )) + fi + done + + if [[ "$all_installed" -eq "${#completions[@]}" ]]; then + builtin print -n "${ZINIT[col-p]}[-]${ZINIT[col-rst]} " + elif [[ "$all_installed" -eq "0" ]]; then + builtin print -n "${ZINIT[col-info]}[+]${ZINIT[col-rst]} " + else + builtin print -n "${ZINIT[col-error]}[+-]${ZINIT[col-rst]} " fi - fi - .zinit-any-to-user-plugin "$pd" - local user=${reply[-2]} plugin=${reply[-1]} + # Convert directory name to colorified $user/$plugin + .zinit-any-colorify-as-uspl2 "${pp:t}" - # Must be a git repository or a binary release - if [[ ! -d $repo/.git && ! -f $repo/._zinit/is_release ]]; then - (( !OPTS[opt_-q,--quiet] )) && \ - builtin print "$REPLY: not a git repository" - continue - fi + # Adjust for escape code (nasty, utilizes fact that + # ${ZINIT[col-rst]} is used twice, so as a $ZINIT_COL) + integer adjust_ec=$(( ${#ZINIT[col-rst]} * 2 + ${#ZINIT[col-uname]} + ${#ZINIT[col-pname]} )) - if [[ $st = status ]]; then - builtin print "\nStatus for plugin $REPLY" - ( builtin cd -q "$repo"; command git status ) - else - (( !OPTS[opt_-q,--quiet] )) && builtin print "Updating $REPLY" || builtin print -n . - .zinit-update-or-status update "$user" "$plugin" - update_rc=$? - [[ $update_rc -ne 0 ]] && { - +zinit-message "🚧{warn}Warning: {pid}${user}/${plugin} {warn}update returned {obj}$update_rc" - retval=$? - } + builtin print "${(r:longest+adjust_ec:: :)REPLY} ${(j:, :)completions}" fi done - - .zinit-compinit 1 1 &>/dev/null - if (( !OPTS[opt_-q,--quiet] )) { - +zinit-message "{msg2}The update took {obj}${SECONDS}{msg2} seconds{rst}" - } - - return "$retval" } # ]]] -# FUNCTION: .zinit-update-all-parallel [[[ -.zinit-update-all-parallel() { +# FUNCTION: .zinit-self-update [[[ +# Updates Zinit code (does a git pull) +.zinit-self-update() { builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - setopt extendedglob warncreateglobal typesetsilent \ - noshortloops nomonitor nonotify + setopt extendedglob typesetsilent warncreateglobal - local id_as repo snip uspl user plugin PUDIR="$(mktemp -d)" + [[ $1 = -q ]] && +zinit-message "{pre}[self-update]{info} updating zinit repository{msg2}" \ - local -A PUAssocArray map - map=( / -- "=" -EQ- "?" -QM- "&" -AMP- : - ) - local -a files - integer main_counter counter PUPDATE=1 + local nl=$'\n' escape=$'\x1b[' + local current_branch=$(git -C $ZINIT[BIN_DIR] rev-parse --abbrev-ref HEAD) + # local current_branch='main' + local -a lines + ( + builtin cd -q "$ZINIT[BIN_DIR]" \ + && +zinit-message -n "{pre}[self-update]{info} fetching latest changes from {obj}$current_branch{info} branch$nl{rst}" \ + && command git fetch --quiet \ + && lines=( ${(f)"$(command git log --color --date=short --pretty=format:'%Cgreen%cd %h %Creset%s %Cred%d%Creset || %b' ..origin/HEAD)"} ) + if (( ${#lines} > 0 )); then + # Remove the (origin/main ...) segments, to expect only tags to appear + lines=( "${(S)lines[@]//\(([,[:blank:]]#(origin|HEAD|master|main)[^a-zA-Z]##(HEAD|origin|master|main)[,[:blank:]]#)#\)/}" ) + # Remove " ||" if it ends the line (i.e. no additional text from the body) + lines=( "${lines[@]/ \|\|[[:blank:]]#(#e)/}" ) + # If there's no ref-name, 2 consecutive spaces occur - fix this + lines=( "${lines[@]/(#b)[[:space:]]#\|\|[[:space:]]#(*)(#e)/|| ${match[1]}}" ) + lines=( "${lines[@]/(#b)$escape([0-9]##)m[[:space:]]##${escape}m/$escape${match[1]}m${escape}m}" ) + # Replace what follows "|| ..." with the same thing but with no + # newlines, and also only first 10 words (the (w)-flag enables + # word-indexing) + lines=( "${lines[@]/(#b)[[:blank:]]#\|\|(*)(#e)/| ${${match[1]//$nl/ }[(w)1,(w)10]}}" ) + builtin print -rl -- "${lines[@]}" | .zinit-pager + builtin print + fi + if [[ $1 != -q ]] { + command git pull --no-stat --ff-only origin main + } else { + command git pull --no-stat --quiet --ff-only origin main + } + ) + if [[ $1 != -q ]] { + +zinit-message "{pre}[self-update]{info} compiling zinit via {obj}zcompile{rst}" + } + command rm -f $ZINIT[BIN_DIR]/*.zwc(DN) + zcompile -U $ZINIT[BIN_DIR]/zinit.zsh + zcompile -U $ZINIT[BIN_DIR]/zinit-{'side','install','autoload','additional'}.zsh + zcompile -U $ZINIT[BIN_DIR]/share/git-process-output.zsh + # Load for the current session + [[ $1 != -q ]] && +zinit-message "{pre}[self-update]{info} reloading zinit for the current session{rst}" - files=( ${ZINIT[SNIPPETS_DIR]}/**/(._zinit|._zplugin)/mode(ND) ) - main_counter=${#files} - if (( OPTS[opt_-s,--snippets] || !OPTS[opt_-l,--plugins] )) { - for snip ( "${files[@]}" ) { - main_counter=main_counter-1 - # The continue may cause the tail of processes to fall-through to the following plugins-specific `wait' - # Should happen only in a very special conditions - # TODO handle this - [[ ! -f ${snip:h}/url ]] && continue - [[ -f ${snip:h}/id-as ]] && \ - id_as="$(<${snip:h}/id-as)" || \ - id_as= + # +zinit-message "{pre}[self-update]{info} resetting zinit repository via{rst}: {cmd}${ICE[reset]:-git reset --hard HEAD}{rst}" + source $ZINIT[BIN_DIR]/zinit.zsh + zcompile -U $ZINIT[BIN_DIR]/zinit-{'side','install','autoload'}.zsh + # Read and remember the new modification timestamps + local file + for file ( "" -side -install -autoload ) { + .zinit-get-mtime-into "${ZINIT[BIN_DIR]}/zinit$file.zsh" "ZINIT[mtime$file]" + } +} # ]]] - counter+=1 - local ef_id="${id_as:-$(<${snip:h}/url)}" - local PUFILEMAIN=${${ef_id#/}//(#m)[\/=\?\&:]/${map[$MATCH]}} - local PUFILE=$PUDIR/${counter}_$PUFILEMAIN.out +# FUNCTION: .zinit-show-all-reports [[[ +# Displays reports of all loaded plugins. +# +# User-action entry point. +.zinit-show-all-reports() { + local i + for i in "${ZINIT_REGISTERED_PLUGINS[@]}"; do + [[ "$i" = "_local/zinit" ]] && continue + .zinit-show-report "$i" + done +} # ]]] +# FUNCTION: .zinit-show-completions [[[ +# Display installed (enabled and disabled), completions. Detect +# stray and improper ones. +# +# Completions live even when plugin isn't loaded - if they are +# installed and enabled. +# +# User-action entry point. +.zinit-show-completions() { + builtin setopt localoptions nullglob extendedglob nokshglob noksharrays + local count="${1:-3}" - .zinit-update-or-status-snippet "$st" "$ef_id" &>! $PUFILE & + typeset -a completions + completions=( "${ZINIT[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc "${ZINIT[COMPLETIONS_DIR]}"/[^_.]*~*.zwc ) - PUAssocArray[$!]=$PUFILE + local cpath c o s group - .zinit-wait-for-update-jobs snippets - } - } + # Prepare readlink command for establishing + # completion's owner + .zinit-prepare-readlink + local rdlink="$REPLY" - counter=0 - PUAssocArray=() + float flmax=${#completions} flcur=0 + typeset -F1 flper - if (( OPTS[opt_-l,--plugins] || !OPTS[opt_-s,--snippets] )) { - local -a files2 - files=( ${ZINIT[PLUGINS_DIR]}/*(ND/) ) + local -A owner_to_group + local -a packs splitted - # Pre-process plugins - for repo ( $files ) { - uspl=${repo:t} - # Two special cases - [[ $uspl = custom || $uspl = _local---zinit ]] && continue + integer disabled unknown stray + for cpath in "${completions[@]}"; do + c="${cpath:t}" + [[ "${c#_}" = "${c}" ]] && disabled=1 || disabled=0 + c="${c#_}" - # Check if repository has a remote set - if [[ -f $repo/.git/config ]] { - local -a config - config=( ${(f)"$(<$repo/.git/config)"} ) - if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]] { - continue - } - } + # This will resolve completion's symlink to obtain + # information about the repository it comes from, i.e. + # about user and plugin, taken from directory name + .zinit-get-completion-owner "$cpath" "$rdlink" + [[ "$REPLY" = "[unknown]" ]] && unknown=1 || unknown=0 + o="$REPLY" - .zinit-any-to-user-plugin "$uspl" - local user=${reply[-2]} plugin=${reply[-1]} + # If we successfully read a symlink (unknown == 0), test if it isn't broken + stray=0 + if (( unknown == 0 )); then + [[ ! -f "$cpath" ]] && stray=1 + fi - # Must be a git repository or a binary release - if [[ ! -d $repo/.git && ! -f $repo/._zinit/is_release ]] { - continue - } - files2+=( $repo ) - } + s=$(( 1*disabled + 2*unknown + 4*stray )) - main_counter=${#files2} - for repo ( "${files2[@]}" ) { - main_counter=main_counter-1 + owner_to_group[${o}--$s]+="$c;" + group="${owner_to_group[${o}--$s]%;}" + splitted=( "${(s:;:)group}" ) - uspl=${repo:t} - id_as=${uspl//---//} + if [[ "${#splitted}" -ge "$count" ]]; then + packs+=( "${(q)group//;/, } ${(q)o} ${(q)s}" ) + unset "owner_to_group[${o}--$s]" + fi - counter+=1 - local PUFILEMAIN=${${id_as#/}//(#m)[\/=\?\&:]/${map[$MATCH]}} - local PUFILE=$PUDIR/${counter}_$PUFILEMAIN.out + (( ++ flcur )) + flper=$(( flcur / flmax * 100 )) + builtin print -u 2 -n -- "\r${flper}% " + done - .zinit-any-colorify-as-uspl2 "$uspl" - +zinit-message "Updating $REPLY{…}" >! $PUFILE + for o in "${(k)owner_to_group[@]}"; do + group="${owner_to_group[$o]%;}" + s="${o##*--}" + o="${o%--*}" + packs+=( "${(q)group//;/, } ${(q)o} ${(q)s}" ) + done + packs=( "${(on)packs[@]}" ) - .zinit-any-to-user-plugin "$uspl" - local user=${reply[-2]} plugin=${reply[-1]} + builtin print -u 2 # newline after percent - .zinit-update-or-status update "$user" "$plugin" &>>! $PUFILE & + # Find longest completion name + integer longest=0 + local -a unpacked + for c in "${packs[@]}"; do + unpacked=( "${(Q@)${(z@)c}}" ) + [[ "${#unpacked[1]}" -gt "$longest" ]] && longest="${#unpacked[1]}" + done - PUAssocArray[$!]=$PUFILE + for c in "${packs[@]}"; do + unpacked=( "${(Q@)${(z@)c}}" ) # TODO: ${(Q)${(z@)c}[@]} ? - .zinit-wait-for-update-jobs plugins + .zinit-any-colorify-as-uspl2 "$unpacked[2]" + builtin print -n "${(r:longest+1:: :)unpacked[1]} $REPLY" - } - } - # Shouldn't happen - # (( ${#PUAssocArray} > 0 )) && wait ${(k)PUAssocArray} -} # ]]] -# FUNCTION: .zinit-wait-for-update-jobs [[[ -.zinit-wait-for-update-jobs() { - local tpe=$1 - if (( counter > OPTS[value] || main_counter == 0 )) { - wait ${(k)PUAssocArray} - local ind_file - for ind_file ( ${^${(von)PUAssocArray}}.ind(DN.) ) { - command cat ${ind_file:r} - (( !OPTS[opt_-d,--debug] && !ZINIT[DEBUG_MODE] )) && \ - command rm -f $ind_file - } - (( !OPTS[opt_-d,--debug] && !ZINIT[DEBUG_MODE] )) && \ - command rm -f ${(v)PUAssocArray} - counter=0 - PUAssocArray=() - } elif (( counter == 1 && !OPTS[opt_-q,--quiet] )) { - +zinit-message "{obj}Spawning the next{num}" \ - "${OPTS[value]}{obj} concurrent update jobs" \ - "({msg2}${tpe}{obj}){…}{rst}" - } + (( unpacked[3] & 0x1 )) && builtin print -n " ${ZINIT[col-error]}[disabled]${ZINIT[col-rst]}" + (( unpacked[3] & 0x2 )) && builtin print -n " ${ZINIT[col-error]}[unknown file, clean with cclear]${ZINIT[col-rst]}" + (( unpacked[3] & 0x4 )) && builtin print -n " ${ZINIT[col-error]}[stray, clean with cclear]${ZINIT[col-rst]}" + builtin print + done } # ]]] -# FUNCTION: .zinit-show-zstatus [[[ -# Shows Zinit status, i.e. number of loaded plugins, -# of available completions, etc. +# FUNCTION: .zinit-show-debug-report [[[ +# Displays dtrace report (data recorded in interactive session). # # User-action entry point. -.zinit-show-zstatus() { - builtin setopt localoptions nullglob extendedglob nokshglob noksharrays +.zinit-show-debug-report() { + .zinit-show-report "_dtrace/_dtrace" +} # ]]] +# FUNCTION: .zinit-show-report [[[ +# Displays report of the plugin given. +# +# $1 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin) +# $2 - plugin (only when $1 - i.e. user - given) +.zinit-show-report() { + setopt localoptions extendedglob warncreateglobal typesetsilent noksharrays + .zinit-any-to-user-plugin "$1" "$2" + local user="${reply[-2]}" plugin="${reply[-1]}" uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" - local infoc="${ZINIT[col-info2]}" + # Allow debug report + if [[ "$user/$plugin" != "_dtrace/_dtrace" ]]; then + .zinit-exists-message "$user" "$plugin" || return 1 + fi - +zinit-message "Zinit's main directory: {file}${ZINIT[HOME_DIR]}{rst}" - +zinit-message "Zinit's binary directory: {file}${ZINIT[BIN_DIR]}{rst}" - +zinit-message "Plugin directory: {file}${ZINIT[PLUGINS_DIR]}{rst}" - +zinit-message "Completions directory: {file}${ZINIT[COMPLETIONS_DIR]}{rst}" + # Print title + builtin printf "${ZINIT[col-title]}Report for${ZINIT[col-rst]} %s%s plugin\n"\ + "${user:+${ZINIT[col-uname]}$user${ZINIT[col-rst]}}${${user:#(%|/)*}:+/}"\ + "${ZINIT[col-pname]}$plugin${ZINIT[col-rst]}" - # Without _zlocal/zinit - +zinit-message "Loaded plugins: {num}$(( ${#ZINIT_REGISTERED_PLUGINS[@]} - 1 )){rst}" + # Print "----------" + local msg="Report for $user${${user:#(%|/)*}:+/}$plugin plugin" + builtin print -- "${ZINIT[col-bar]}${(r:${#msg}::-:)tmp__}${ZINIT[col-rst]}" - # Count light-loaded plugins - integer light=0 - local s - for s in "${(@v)ZINIT[(I)STATES__*]}"; do - [[ "$s" = 1 ]] && (( light ++ )) - done - # Without _zlocal/zinit - +zinit-message "Light loaded: {num}$(( light - 1 )){rst}" + local -A map + map=( + Error: "${ZINIT[col-error]}" + Warning: "${ZINIT[col-error]}" + Note: "${ZINIT[col-note]}" + ) + # Print report gathered via shadowing + () { + setopt localoptions extendedglob + builtin print -rl -- "${(@)${(f@)ZINIT_REPORTS[$uspl2]}/(#b)(#s)([^[:space:]]##)([[:space:]]##)/${map[${match[1]}]:-${ZINIT[col-keyword]}}${match[1]}${ZINIT[col-rst]}${match[2]}}" + } - # Downloaded plugins, without _zlocal/zinit, custom - typeset -a plugins - plugins=( "${ZINIT[PLUGINS_DIR]}"/*(DN) ) - +zinit-message "Downloaded plugins: {num}$(( ${#plugins} - 1 )){rst}" + # Print report gathered via $functions-diffing + REPLY="" + .zinit-diff-functions-compute "$uspl2" + .zinit-format-functions "$uspl2" + [[ -n "$REPLY" ]] && builtin print "${ZINIT[col-p]}Functions created:${ZINIT[col-rst]}"$'\n'"$REPLY" - # Number of enabled completions, with _zlocal/zinit - typeset -a completions - completions=( "${ZINIT[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc(DN) ) - +zinit-message "Enabled completions: {num}${#completions[@]}{rst}" + # Print report gathered via $options-diffing + REPLY="" + .zinit-diff-options-compute "$uspl2" + .zinit-format-options "$uspl2" + [[ -n "$REPLY" ]] && builtin print "${ZINIT[col-p]}Options changed:${ZINIT[col-rst]}"$'\n'"$REPLY" - # Number of disabled completions, with _zlocal/zinit - completions=( "${ZINIT[COMPLETIONS_DIR]}"/[^_.]*~*.zwc(DN) ) - +zinit-message "Disabled completions: {num}${#completions[@]}{rst}" + # Print report gathered via environment diffing + REPLY="" + .zinit-diff-env-compute "$uspl2" + .zinit-format-env "$uspl2" "1" + [[ -n "$REPLY" ]] && builtin print "${ZINIT[col-p]}PATH elements added:${ZINIT[col-rst]}"$'\n'"$REPLY" - # Number of completions existing in all plugins - completions=( "${ZINIT[PLUGINS_DIR]}"/*/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) ) - +zinit-message "Completions available overall: {num}${#completions[@]}{rst}" + REPLY="" + .zinit-format-env "$uspl2" "2" + [[ -n "$REPLY" ]] && builtin print "${ZINIT[col-p]}FPATH elements added:${ZINIT[col-rst]}"$'\n'"$REPLY" - # Enumerate snippets loaded - # }, ${infoc}{rst}", j:, :, {msg}"$'\e[0m, +zinit-message h - +zinit-message -n "Snippets loaded: " - local sni - for sni in ${(onv)ZINIT_SNIPPETS[@]}; do - +zinit-message -n "{url}${sni% <[^>]#>}{rst} ${(M)sni%<[^>]##>}, " - done - [[ -z $sni ]] && builtin print -n " " - builtin print '\b\b ' + # Print report gathered via parameter diffing + .zinit-diff-parameter-compute "$uspl2" + .zinit-format-parameter "$uspl2" + [[ -n "$REPLY" ]] && builtin print "${ZINIT[col-p]}Variables added or redefined:${ZINIT[col-rst]}"$'\n'"$REPLY" - # Number of compiled plugins - typeset -a matches m - integer count=0 - matches=( ${ZINIT[PLUGINS_DIR]}/*/*.zwc(DN) ) + # Print what completions plugin has + .zinit-find-completions-of-plugin "$user" "$plugin" + typeset -a completions + completions=( "${reply[@]}" ) - local cur_plugin="" uspl1 - for m in "${matches[@]}"; do - uspl1="${${m:h}:t}" + if [[ "${#completions[@]}" -ge "1" ]]; then + builtin print "${ZINIT[col-p]}Completions:${ZINIT[col-rst]}" + .zinit-check-which-completions-are-installed "${completions[@]}" + typeset -a installed + installed=( "${reply[@]}" ) - if [[ "$cur_plugin" != "$uspl1" ]]; then - (( count ++ )) - cur_plugin="$uspl1" - fi - done + .zinit-check-which-completions-are-enabled "${completions[@]}" + typeset -a enabled + enabled=( "${reply[@]}" ) - +zinit-message "Compiled plugins: {num}$count{rst}" + integer count="${#completions[@]}" idx + for (( idx=1; idx <= count; idx ++ )); do + builtin print -n "${completions[idx]:t}" + if [[ "${installed[idx]}" != "1" ]]; then + builtin print -n " ${ZINIT[col-uninst]}[not installed]${ZINIT[col-rst]}" + else + if [[ "${enabled[idx]}" = "1" ]]; then + builtin print -n " ${ZINIT[col-info]}[enabled]${ZINIT[col-rst]}" + else + builtin print -n " ${ZINIT[col-error]}[disabled]${ZINIT[col-rst]}" + fi + fi + builtin print + done + builtin print + fi } # ]]] # FUNCTION: .zinit-show-times [[[ # Shows loading times of all loaded plugins. @@ -2189,118 +2126,129 @@ ZINIT[EXTENDED_GLOB]="" done builtin print "Total: $sum sec" } # ]]] -# FUNCTION: .zinit-list-bindkeys [[[ -.zinit-list-bindkeys() { - local uspl2 uspl2col sw first=1 - local -a string_widget +# FUNCTION: .zinit-show-zstatus [[[ +# Shows Zinit status, i.e. number of loaded plugins, +# of available completions, etc. +# +# User-action entry point. +.zinit-show-zstatus() { + builtin setopt localoptions nullglob extendedglob nokshglob noksharrays - # KSH_ARRAYS immunity - integer correct=0 - [[ -o "KSH_ARRAYS" ]] && correct=1 + local infoc="${ZINIT[col-info2]}" - for uspl2 in "${(@ko)ZINIT[(I)BINDKEYS__*]}"; do - [[ -z "${ZINIT[$uspl2]}" ]] && continue + +zinit-message "Zinit's main directory: {file}${ZINIT[HOME_DIR]}{rst}" + +zinit-message "Zinit's binary directory: {file}${ZINIT[BIN_DIR]}{rst}" + +zinit-message "Plugin directory: {file}${ZINIT[PLUGINS_DIR]}{rst}" + +zinit-message "Completions directory: {file}${ZINIT[COMPLETIONS_DIR]}{rst}" - (( !first )) && builtin print - first=0 + # Without _zlocal/zinit + +zinit-message "Loaded plugins: {num}$(( ${#ZINIT_REGISTERED_PLUGINS[@]} - 1 )){rst}" - uspl2="${uspl2#BINDKEYS__}" + # Count light-loaded plugins + integer light=0 + local s + for s in "${(@v)ZINIT[(I)STATES__*]}"; do + [[ "$s" = 1 ]] && (( light ++ )) + done + # Without _zlocal/zinit + +zinit-message "Light loaded: {num}$(( light - 1 )){rst}" - .zinit-any-colorify-as-uspl2 "$uspl2" - uspl2col="$REPLY" - builtin print "$uspl2col" + # Downloaded plugins, without _zlocal/zinit, custom + typeset -a plugins + plugins=( "${ZINIT[PLUGINS_DIR]}"/*(DN) ) + +zinit-message "Downloaded plugins: {num}$(( ${#plugins} - 1 )){rst}" - string_widget=( "${(z@)ZINIT[BINDKEYS__$uspl2]}" ) - for sw in "${(Oa)string_widget[@]}"; do - [[ -z "$sw" ]] && continue - # Remove one level of quoting to split using (z) - sw="${(Q)sw}" - typeset -a sw_arr - sw_arr=( "${(z@)sw}" ) + # Number of enabled completions, with _zlocal/zinit + typeset -a completions + completions=( "${ZINIT[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc(DN) ) + +zinit-message "Enabled completions: {num}${#completions[@]}{rst}" - # Remove one level of quoting to pass to bindkey - local sw_arr1="${(Q)sw_arr[1-correct]}" # Keys - local sw_arr2="${(Q)sw_arr[2-correct]}" # Widget - local sw_arr3="${(Q)sw_arr[3-correct]}" # Optional -M or -A or -N - local sw_arr4="${(Q)sw_arr[4-correct]}" # Optional map name - local sw_arr5="${(Q)sw_arr[5-correct]}" # Optional -R (not with -A, -N) + # Number of disabled completions, with _zlocal/zinit + completions=( "${ZINIT[COMPLETIONS_DIR]}"/[^_.]*~*.zwc(DN) ) + +zinit-message "Disabled completions: {num}${#completions[@]}{rst}" - if [[ "$sw_arr3" = "-M" && "$sw_arr5" != "-R" ]]; then - builtin print "bindkey $sw_arr1 $sw_arr2 ${ZINIT[col-info]}for keymap $sw_arr4${ZINIT[col-rst]}" - elif [[ "$sw_arr3" = "-M" && "$sw_arr5" = "-R" ]]; then - builtin print "${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey $sw_arr1 $sw_arr2 ${ZINIT[col-info]}mapped to $sw_arr4${ZINIT[col-rst]}" - elif [[ "$sw_arr3" != "-M" && "$sw_arr5" = "-R" ]]; then - builtin print "${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey $sw_arr1 $sw_arr2" - elif [[ "$sw_arr3" = "-A" ]]; then - builtin print "Override of keymap \`main'" - elif [[ "$sw_arr3" = "-N" ]]; then - builtin print "New keymap \`$sw_arr4'" - else - builtin print "bindkey $sw_arr1 $sw_arr2" - fi - done + # Number of completions existing in all plugins + completions=( "${ZINIT[PLUGINS_DIR]}"/*/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) ) + +zinit-message "Completions available overall: {num}${#completions[@]}{rst}" + + # Enumerate snippets loaded + # }, ${infoc}{rst}", j:, :, {msg}"$'\e[0m, +zinit-message h + +zinit-message -n "Snippets loaded: " + local sni + for sni in ${(onv)ZINIT_SNIPPETS[@]}; do + +zinit-message -n "{url}${sni% <[^>]#>}{rst} ${(M)sni%<[^>]##>}, " done -} # ]]] -# FUNCTION: .zinit-compiled [[[ -# Displays list of plugins that are compiled. -# -# User-action entry point. -.zinit-compiled() { - builtin setopt localoptions nullglob + [[ -z $sni ]] && builtin print -n " " + builtin print '\b\b ' + # Number of compiled plugins typeset -a matches m + integer count=0 matches=( ${ZINIT[PLUGINS_DIR]}/*/*.zwc(DN) ) - if [[ "${#matches[@]}" -eq "0" ]]; then - builtin print "No compiled plugins" - return 0 - fi - - local cur_plugin="" uspl1 file user plugin + local cur_plugin="" uspl1 for m in "${matches[@]}"; do - file="${m:t}" uspl1="${${m:h}:t}" - .zinit-any-to-user-plugin "$uspl1" - user="${reply[-2]}" plugin="${reply[-1]}" if [[ "$cur_plugin" != "$uspl1" ]]; then - [[ -n "$cur_plugin" ]] && builtin print # newline - .zinit-any-colorify-as-uspl2 "$user" "$plugin" - builtin print -r -- "$REPLY:" + (( count ++ )) cur_plugin="$uspl1" fi - - builtin print "$file" done + + +zinit-message "Compiled plugins: {num}$count{rst}" } # ]]] -# FUNCTION: .zinit-compile-uncompile-all [[[ -# Compiles or uncompiles all existing (on disk) plugins. + +# FUNCTION: .zinit-stress [[[ +# Compiles plugin with various options on and off to see +# how well the code is written. The options are: +# +# NO_SHORT_LOOPS, IGNORE_BRACES, IGNORE_CLOSE_BRACES, SH_GLOB, +# CSH_JUNKIE_QUOTES, NO_MULTI_FUNC_DEF. # # User-action entry point. -.zinit-compile-uncompile-all() { - builtin setopt localoptions nullglob +# +# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) +# $2 - plugin (only when $1 - i.e. user - given) +.zinit-stress() { + .zinit-any-to-user-plugin "$1" "$2" + local user="${reply[-2]}" plugin="${reply[-1]}" - local compile="$1" + .zinit-exists-physically-message "$user" "$plugin" || return 1 - typeset -a plugins - plugins=( "${ZINIT[PLUGINS_DIR]}"/*(DN) ) + .zinit-first "$1" "$2" || { + builtin print "${ZINIT[col-error]}No source file found, cannot stress${ZINIT[col-rst]}" + return 1 + } - local p user plugin - for p in "${plugins[@]}"; do - [[ "${p:t}" = "custom" || "${p:t}" = "_local---zinit" ]] && continue + local pdir_path="${reply[-2]}" fname="${reply[-1]}" - .zinit-any-to-user-plugin "${p:t}" - user="${reply[-2]}" plugin="${reply[-1]}" + integer compiled=1 + [[ -e "${fname}.zwc" ]] && command rm -f "${fname}.zwc" || compiled=0 - .zinit-any-colorify-as-uspl2 "$user" "$plugin" - builtin print -r -- "$REPLY:" + local -a ZINIT_STRESS_TEST_OPTIONS + ZINIT_STRESS_TEST_OPTIONS=( + "NO_SHORT_LOOPS" "IGNORE_BRACES" "IGNORE_CLOSE_BRACES" + "SH_GLOB" "CSH_JUNKIE_QUOTES" "NO_MULTI_FUNC_DEF" + ) - if [[ "$compile" = "1" ]]; then - .zinit-compile-plugin "$user" "$plugin" - else - .zinit-uncompile-plugin "$user" "$plugin" "1" - fi - done + ( + builtin emulate -LR ksh ${=${options[xtrace]:#off}:+-o xtrace} + builtin unsetopt shglob kshglob + for i in "${ZINIT_STRESS_TEST_OPTIONS[@]}"; do + builtin setopt "$i" + builtin print -n "Stress-testing ${fname:t} for option $i " + zcompile -UR "$fname" 2>/dev/null && { + builtin print "[${ZINIT[col-success]}Success${ZINIT[col-rst]}]" + } || { + builtin print "[${ZINIT[col-failure]}Fail${ZINIT[col-rst]}]" + } + builtin unsetopt "$i" + done + ) + + command rm -f "${fname}.zwc" + (( compiled )) && zcompile -U "$fname" } # ]]] # FUNCTION: .zinit-uncompile-plugin [[[ # Uncompiles given plugin. @@ -2337,1029 +2285,1154 @@ ZINIT[EXTENDED_GLOB]="" command rm -f "$m" done } # ]]] - -# FUNCTION: .zinit-show-completions [[[ -# Display installed (enabled and disabled), completions. Detect -# stray and improper ones. -# -# Completions live even when plugin isn't loaded - if they are -# installed and enabled. +# FUNCTION: .zinit-unload [[[ +# 1. call the zsh plugin's standard *_plugin_unload function +# 2. call the code provided by the zsh plugin's standard @zsh-plugin-run-at-update +# 3. delete bindkeys (...) +# 4. delete zstyles +# 5. restore options +# 6. remove aliases +# 7. restore zle state +# 8. unfunction functions (created by plugin) +# 9. clean-up fpath and path +# 10. delete created variables +# 11. forget the plugin # -# User-action entry point. -.zinit-show-completions() { - builtin setopt localoptions nullglob extendedglob nokshglob noksharrays - local count="${1:-3}" - - typeset -a completions - completions=( "${ZINIT[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc "${ZINIT[COMPLETIONS_DIR]}"/[^_.]*~*.zwc ) - - local cpath c o s group - - # Prepare readlink command for establishing - # completion's owner - .zinit-prepare-readlink - local rdlink="$REPLY" +# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) +# $2 - plugin (only when $1 - i.e. user - given) +.zinit-unload() { + .zinit-any-to-user-plugin "$1" "$2" + local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" user="${reply[-2]}" plugin="${reply[-1]}" quiet="${${3:+1}:-0}" + local k - float flmax=${#completions} flcur=0 - typeset -F1 flper + .zinit-any-colorify-as-uspl2 "$uspl2" + (( quiet )) || builtin print -r -- "${ZINIT[col-bar]}---${ZINIT[col-rst]} Unloading plugin: $REPLY ${ZINIT[col-bar]}---${ZINIT[col-rst]}" - local -A owner_to_group - local -a packs splitted + local ___dir + [[ "$user" = "%" ]] && ___dir="$plugin" || ___dir="${ZINIT[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}" - integer disabled unknown stray - for cpath in "${completions[@]}"; do - c="${cpath:t}" - [[ "${c#_}" = "${c}" ]] && disabled=1 || disabled=0 - c="${c#_}" + # KSH_ARRAYS immunity + integer correct=0 + [[ -o "KSH_ARRAYS" ]] && correct=1 - # This will resolve completion's symlink to obtain - # information about the repository it comes from, i.e. - # about user and plugin, taken from directory name - .zinit-get-completion-owner "$cpath" "$rdlink" - [[ "$REPLY" = "[unknown]" ]] && unknown=1 || unknown=0 - o="$REPLY" + # Allow unload for debug user + if [[ "$uspl2" != "_dtrace/_dtrace" ]]; then + .zinit-exists-message "$1" "$2" || return 1 + fi - # If we successfully read a symlink (unknown == 0), test if it isn't broken - stray=0 - if (( unknown == 0 )); then - [[ ! -f "$cpath" ]] && stray=1 - fi + .zinit-any-colorify-as-uspl2 "$1" "$2" + local uspl2col="$REPLY" - s=$(( 1*disabled + 2*unknown + 4*stray )) + # Store report of the plugin in variable LASTREPORT + typeset -g LASTREPORT + LASTREPORT=`.zinit-show-report "$1" "$2"` - owner_to_group[${o}--$s]+="$c;" - group="${owner_to_group[${o}--$s]%;}" - splitted=( "${(s:;:)group}" ) + # Call the Zsh Plugin's Standard *_plugin_unload function + (( ${+functions[${plugin}_plugin_unload]} )) && ${plugin}_plugin_unload - if [[ "${#splitted}" -ge "$count" ]]; then - packs+=( "${(q)group//;/, } ${(q)o} ${(q)s}" ) - unset "owner_to_group[${o}--$s]" - fi + # Call the code provided by the Zsh Plugin's Standard @zsh-plugin-run-at-update + local -a tmp + local -A sice + tmp=( "${(z@)ZINIT_SICE[$uspl2]}" ) + (( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) && sice=( "${(Q)tmp[@]}" ) || sice=() - (( ++ flcur )) - flper=$(( flcur / flmax * 100 )) - builtin print -u 2 -n -- "\r${flper}% " - done + if [[ -n ${sice[ps-on-unload]} ]]; then + (( quiet )) || builtin print -r "Running plugin's provided unload code: ${ZINIT[col-info]}${sice[ps-on-unload][1,50]}${sice[ps-on-unload][51]:+…}${ZINIT[col-rst]}" + local ___oldcd="$PWD" + () { setopt localoptions noautopushd; builtin cd -q "$___dir"; } + eval "${sice[ps-on-unload]}" + () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; } + fi - for o in "${(k)owner_to_group[@]}"; do - group="${owner_to_group[$o]%;}" - s="${o##*--}" - o="${o%--*}" - packs+=( "${(q)group//;/, } ${(q)o} ${(q)s}" ) - done - packs=( "${(on)packs[@]}" ) + # 1. Delete done bindkeys + typeset -a string_widget + string_widget=( "${(z)ZINIT[BINDKEYS__$uspl2]}" ) + local sw + for sw in "${(Oa)string_widget[@]}"; do + [[ -z "$sw" ]] && continue + # Remove one level of quoting to split using (z) + sw="${(Q)sw}" + typeset -a sw_arr + sw_arr=( "${(z)sw}" ) - builtin print -u 2 # newline after percent + # Remove one level of quoting to pass to bindkey + local sw_arr1="${(Q)sw_arr[1-correct]}" # Keys + local sw_arr2="${(Q)sw_arr[2-correct]}" # Widget + local sw_arr3="${(Q)sw_arr[3-correct]}" # Optional previous-bound widget + local sw_arr4="${(Q)sw_arr[4-correct]}" # Optional -M or -A or -N + local sw_arr5="${(Q)sw_arr[5-correct]}" # Optional map name + local sw_arr6="${(Q)sw_arr[6-correct]}" # Optional -R (not with -A, -N) - # Find longest completion name - integer longest=0 - local -a unpacked - for c in "${packs[@]}"; do - unpacked=( "${(Q@)${(z@)c}}" ) - [[ "${#unpacked[1]}" -gt "$longest" ]] && longest="${#unpacked[1]}" + if [[ "$sw_arr4" = "-M" && "$sw_arr6" != "-R" ]]; then + if [[ -n "$sw_arr3" ]]; then + () { + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} + (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3 ${ZINIT[col-info]}in map ${ZINIT[col-rst]}$sw_arr5" + } + bindkey -M "$sw_arr5" "$sw_arr1" "$sw_arr3" + else + (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2 ${ZINIT[col-info]}in map ${ZINIT[col-rst]}$sw_arr5" + bindkey -M "$sw_arr5" -r "$sw_arr1" + fi + elif [[ "$sw_arr4" = "-M" && "$sw_arr6" = "-R" ]]; then + if [[ -n "$sw_arr3" ]]; then + (( quiet )) || builtin print -r "Restoring ${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3 ${ZINIT[col-info]}in map ${ZINIT[col-rst]}$sw_arr5" + bindkey -RM "$sw_arr5" "$sw_arr1" "$sw_arr3" + else + (( quiet )) || builtin print -r "Deleting ${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2 ${ZINIT[col-info]}in map ${ZINIT[col-rst]}$sw_arr5" + bindkey -M "$sw_arr5" -Rr "$sw_arr1" + fi + elif [[ "$sw_arr4" != "-M" && "$sw_arr6" = "-R" ]]; then + if [[ -n "$sw_arr3" ]]; then + (( quiet )) || builtin print -r "Restoring ${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3" + bindkey -R "$sw_arr1" "$sw_arr3" + else + (( quiet )) || builtin print -r "Deleting ${ZINIT[col-info]}range${ZINIT[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2" + bindkey -Rr "$sw_arr1" + fi + elif [[ "$sw_arr4" = "-A" ]]; then + (( quiet )) || builtin print -r "Linking backup-\`main' keymap \`$sw_arr5' back to \`main'" + bindkey -A "$sw_arr5" "main" + elif [[ "$sw_arr4" = "-N" ]]; then + (( quiet )) || builtin print -r "Deleting keymap \`$sw_arr5'" + bindkey -D "$sw_arr5" + else + if [[ -n "$sw_arr3" ]]; then + () { + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} + (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3" + } + bindkey "$sw_arr1" "$sw_arr3" + else + (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2" + bindkey -r "$sw_arr1" + fi + fi done - for c in "${packs[@]}"; do - unpacked=( "${(Q@)${(z@)c}}" ) # TODO: ${(Q)${(z@)c}[@]} ? + # 2. Delete created Zstyles - .zinit-any-colorify-as-uspl2 "$unpacked[2]" - builtin print -n "${(r:longest+1:: :)unpacked[1]} $REPLY" + typeset -a pattern_style + pattern_style=( "${(z)ZINIT[ZSTYLES__$uspl2]}" ) + local ps + for ps in "${(Oa)pattern_style[@]}"; do + [[ -z "$ps" ]] && continue + # Remove one level of quoting to split using (z) + ps="${(Q)ps}" + typeset -a ps_arr + ps_arr=( "${(z)ps}" ) - (( unpacked[3] & 0x1 )) && builtin print -n " ${ZINIT[col-error]}[disabled]${ZINIT[col-rst]}" - (( unpacked[3] & 0x2 )) && builtin print -n " ${ZINIT[col-error]}[unknown file, clean with cclear]${ZINIT[col-rst]}" - (( unpacked[3] & 0x4 )) && builtin print -n " ${ZINIT[col-error]}[stray, clean with cclear]${ZINIT[col-rst]}" - builtin print - done -} # ]]] -# FUNCTION: .zinit-clear-completions [[[ -# Delete stray and improper completions. -# -# Completions live even when plugin isn't loaded - if they are -# installed and enabled. -# -# User-action entry point. -.zinit-clear-completions() { - builtin setopt localoptions nullglob extendedglob nokshglob noksharrays + # Remove one level of quoting to pass to zstyle + local ps_arr1="${(Q)ps_arr[1-correct]}" + local ps_arr2="${(Q)ps_arr[2-correct]}" - typeset -a completions - completions=( "${ZINIT[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc "${ZINIT[COMPLETIONS_DIR]}"/[^_.]*~*.zwc ) + (( quiet )) || builtin print "Deleting zstyle $ps_arr1 $ps_arr2" - # Find longest completion name - local cpath c - integer longest=0 - for cpath in "${completions[@]}"; do - c="${cpath:t}" - c="${c#_}" - [[ "${#c}" -gt "$longest" ]] && longest="${#c}" + zstyle -d "$ps_arr1" "$ps_arr2" done - .zinit-prepare-readlink - local rdlink="$REPLY" - - integer disabled unknown stray - for cpath in "${completions[@]}"; do - c="${cpath:t}" - [[ "${c#_}" = "${c}" ]] && disabled=1 || disabled=0 - c="${c#_}" + # 3. Restore changed options + # paranoid, don't want bad key/value pair error + .zinit-diff-options-compute "$uspl2" + integer empty=0 + .zinit-save-set-extendedglob + [[ "${ZINIT[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1 + .zinit-restore-extendedglob - # This will resolve completion's symlink to obtain - # information about the repository it comes from, i.e. - # about user and plugin, taken from directory name - .zinit-get-completion-owner "$cpath" "$rdlink" - [[ "$REPLY" = "[unknown]" ]] && unknown=1 || unknown=0 - .zinit-any-colorify-as-uspl2 "$REPLY" + if (( empty != 1 )); then + typeset -A opts + opts=( "${(z)ZINIT[OPTIONS__$uspl2]}" ) + for k in "${(kon)opts[@]}"; do + # Internal options + [[ "$k" = "physical" ]] && continue - # If we successfully read a symlink (unknown == 0), test if it isn't broken - stray=0 - if (( unknown == 0 )); then - [[ ! -f "$cpath" ]] && stray=1 - fi + if [[ "${opts[$k]}" = "on" ]]; then + (( quiet )) || builtin print "Setting option $k" + builtin setopt "$k" + else + (( quiet )) || builtin print "Unsetting option $k" + builtin unsetopt "$k" + fi + done + fi - if (( unknown == 1 || stray == 1 )); then - builtin print -n "Removing completion: ${(r:longest+1:: :)c} $REPLY" - (( disabled )) && builtin print -n " ${ZINIT[col-error]}[disabled]${ZINIT[col-rst]}" - (( unknown )) && builtin print -n " ${ZINIT[col-error]}[unknown file]${ZINIT[col-rst]}" - (( stray )) && builtin print -n " ${ZINIT[col-error]}[stray]${ZINIT[col-rst]}" - builtin print - command rm -f "$cpath" - fi - done -} # ]]] -# FUNCTION: .zinit-search-completions [[[ -# While .zinit-show-completions() shows what completions are -# installed, this functions searches through all plugin dirs -# showing what's available in general (for installation). -# -# User-action entry point. -.zinit-search-completions() { - builtin setopt localoptions nullglob extendedglob nokshglob noksharrays + # 4. Delete aliases + typeset -a aname_avalue + aname_avalue=( "${(z)ZINIT[ALIASES__$uspl2]}" ) + local nv + for nv in "${(Oa)aname_avalue[@]}"; do + [[ -z "$nv" ]] && continue + # Remove one level of quoting to split using (z) + nv="${(Q)nv}" + typeset -a nv_arr + nv_arr=( "${(z)nv}" ) - typeset -a plugin_paths - plugin_paths=( "${ZINIT[PLUGINS_DIR]}"/*(DN) ) + # Remove one level of quoting to pass to unalias + local nv_arr1="${(Q)nv_arr[1-correct]}" + local nv_arr2="${(Q)nv_arr[2-correct]}" + local nv_arr3="${(Q)nv_arr[3-correct]}" - # Find longest plugin name. Things are ran twice here, first pass - # is to get longest name of plugin which is having any completions - integer longest=0 - typeset -a completions - local pp - for pp in "${plugin_paths[@]}"; do - completions=( "$pp"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) ) - if [[ "${#completions[@]}" -gt 0 ]]; then - local pd="${pp:t}" - [[ "${#pd}" -gt "$longest" ]] && longest="${#pd}" + if [[ "$nv_arr3" = "-s" ]]; then + if [[ -n "$nv_arr2" ]]; then + (( quiet )) || builtin print "Restoring ${ZINIT[col-info]}suffix${ZINIT[col-rst]} alias ${nv_arr1}=${nv_arr2}" + alias "$nv_arr1" &> /dev/null && unalias -s -- "$nv_arr1" + alias -s -- "${nv_arr1}=${nv_arr2}" + else + (( quiet )) || alias "$nv_arr1" &> /dev/null && { + builtin print "Removing ${ZINIT[col-info]}suffix${ZINIT[col-rst]} alias ${nv_arr1}" + unalias -s -- "$nv_arr1" + } + fi + elif [[ "$nv_arr3" = "-g" ]]; then + if [[ -n "$nv_arr2" ]]; then + (( quiet )) || builtin print "Restoring ${ZINIT[col-info]}global${ZINIT[col-rst]} alias ${nv_arr1}=${nv_arr2}" + alias "$nv_arr1" &> /dev/null && unalias -g -- "$nv_arr1" + alias -g -- "${nv_arr1}=${nv_arr2}" + else + (( quiet )) || alias "$nv_arr1" &> /dev/null && { + builtin print "Removing ${ZINIT[col-info]}global${ZINIT[col-rst]} alias ${nv_arr1}" + unalias -- "${(q)nv_arr1}" + } + fi + else + if [[ -n "$nv_arr2" ]]; then + (( quiet )) || builtin print "Restoring alias ${nv_arr1}=${nv_arr2}" + alias "$nv_arr1" &> /dev/null && unalias -- "$nv_arr1" + alias -- "${nv_arr1}=${nv_arr2}" + else + (( quiet )) || alias "$nv_arr1" &> /dev/null && { + builtin print "Removing alias ${nv_arr1}" + unalias -- "$nv_arr1" + } + fi fi done - builtin print "${ZINIT[col-info]}[+]${ZINIT[col-rst]} is installed, ${ZINIT[col-p]}[-]${ZINIT[col-rst]} uninstalled, ${ZINIT[col-error]}[+-]${ZINIT[col-rst]} partially installed" + # + # 5. Restore Zle state + # - local c - for pp in "${plugin_paths[@]}"; do - completions=( "$pp"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) ) + local -a keys + keys=( "${(@on)ZINIT[(I)TIME_<->_*]}" ) + integer keys_size=${#keys} + () { + setopt localoptions extendedglob noksharrays typesetsilent + typeset -a restore_widgets skip_delete + local wid + restore_widgets=( "${(z)ZINIT[WIDGETS_SAVED__$uspl2]}" ) + for wid in "${(Oa)restore_widgets[@]}"; do + [[ -z "$wid" ]] && continue + wid="${(Q)wid}" + typeset -a orig_saved + orig_saved=( "${(z)wid}" ) - if [[ "${#completions[@]}" -gt 0 ]]; then - # Array of completions, e.g. ( _cp _xauth ) - completions=( "${completions[@]:t}" ) + local tpe="${orig_saved[1]}" + local orig_saved1="${(Q)orig_saved[2]}" # Original widget + local comp_wid="${(Q)orig_saved[3]}" + local orig_saved2="${(Q)orig_saved[4]}" # Saved target function + local orig_saved3="${(Q)orig_saved[5]}" # Saved previous $widget's contents - # Detect if the completions are installed - integer all_installed="${#completions[@]}" - for c in "${completions[@]}"; do - if [[ -e "${ZINIT[COMPLETIONS_DIR]}/$c" || -e "${ZINIT[COMPLETIONS_DIR]}/${c#_}" ]]; then - (( all_installed -- )) + local found_time_key="${keys[(r)TIME_<->_${uspl2//\//---}]}" to_process_plugin + integer found_time_idx=0 idx=0 + to_process_plugin="" + [[ "$found_time_key" = (#b)TIME_(<->)_* ]] && found_time_idx="${match[1]}" + if (( found_time_idx )); then # Must be true + for (( idx = found_time_idx + 1; idx <= keys_size; ++ idx )); do + found_time_key="${keys[(r)TIME_${idx}_*]}" + local oth_uspl2="" + [[ "$found_time_key" = (#b)TIME_${idx}_(*) ]] && oth_uspl2="${match[1]//---//}" + local -a entry_splitted + entry_splitted=( "${(z@)ZINIT[WIDGETS_SAVED__$oth_uspl2]}" ) + integer found_idx="${entry_splitted[(I)(-N|-C)\ $orig_saved1\\\ *]}" + local -a entry_splitted2 + entry_splitted2=( "${(z@)ZINIT[BINDKEYS__$oth_uspl2]}" ) + integer found_idx2="${entry_splitted2[(I)*\ $orig_saved1\ *]}" + if (( found_idx || found_idx2 )) + then + # Skip multiple loads of the same plugin + # TODO: fully handle multiple plugin loads + if [[ "$oth_uspl2" != "$uspl2" ]]; then + to_process_plugin="$oth_uspl2" + # only the first one is needed + break + fi + fi + done + if [[ -n "$to_process_plugin" ]]; then + if (( !found_idx && !found_idx2 )); then + (( quiet )) || builtin print "Problem (1) during handling of widget \`$orig_saved1' (contents: $orig_saved2)" + continue + fi + (( quiet )) || builtin print "Chaining widget \`$orig_saved1' to plugin $oth_uspl2" + local -a oth_orig_saved + if (( found_idx )) { + oth_orig_saved=( "${(z)${(Q)entry_splitted[found_idx]}}" ) + local oth_fun="${oth_orig_saved[4]}" + # below is wrong because we don't want to call other plugins function at any moment + # oth_orig_saved[2]="${(q)orig_saved2}" + oth_orig_saved[5]="${(q)orig_saved3}" # chain up the widget + entry_splitted[found_idx]="${(q)${(j: :)oth_orig_saved}}" + ZINIT[WIDGETS_SAVED__$oth_uspl2]="${(j: :)entry_splitted}" + } else { + oth_orig_saved=( "${(z)${(Q)entry_splitted2[found_idx2]}}" ) + local oth_fun="${widgets[${oth_orig_saved[3]}]#*:}" + } + integer idx="${functions[$orig_saved2][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}" + if (( idx <= ${#functions[$orig_saved2]} )) + then + local prefix_X="${match[1]#\{}" + [[ $prefix_X != \$* ]] && prefix_X="${prefix_X%\}}" + idx="${functions[$oth_fun][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}" + if (( idx <= ${#functions[$oth_fun]} )); then + match[1]="${match[1]#\{}" + [[ ${match[1]} != \$* ]] && match[1]="${match[1]%\}}" + eval "local oth_prefix_uspl2_X=\"${match[1]}\"" + if [[ "${widgets[$prefix_X]}" = builtin ]]; then + (( quiet )) || builtin print "Builtin-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" + zle -A ".${prefix_X#.}" "$oth_prefix_uspl2_X" + elif [[ "${widgets[$prefix_X]}" = completion:* ]]; then + (( quiet )) || builtin print "Chain*-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" + zle -C "$oth_prefix_uspl2_X" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}" + else + (( quiet )) || builtin print "Chain-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" + zle -N "$oth_prefix_uspl2_X" "${widgets[$prefix_X]#user:}" + fi + fi + # The alternate method + # skip_delete+=( "${match[1]}" ) + # functions[$oth_fun]="${functions[$oth_fun]//[^\{[:space:]]#$orig_saved1/${match[1]}}" + fi + else + (( quiet )) || builtin print "Restoring Zle widget $orig_saved1" + if [[ "$orig_saved3" = builtin ]]; then + zle -A ".$orig_saved1" "$orig_saved1" + elif [[ "$orig_saved3" = completion:* ]]; then + zle -C "$orig_saved1" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}" + else + zle -N "$orig_saved1" "${orig_saved3#user:}" + fi fi - done - - if [[ "$all_installed" -eq "${#completions[@]}" ]]; then - builtin print -n "${ZINIT[col-p]}[-]${ZINIT[col-rst]} " - elif [[ "$all_installed" -eq "0" ]]; then - builtin print -n "${ZINIT[col-info]}[+]${ZINIT[col-rst]} " else - builtin print -n "${ZINIT[col-error]}[+-]${ZINIT[col-rst]} " + (( quiet )) || builtin print "Problem (2) during handling of widget \`$orig_saved1' (contents: $orig_saved2)" fi + done + } - # Convert directory name to colorified $user/$plugin - .zinit-any-colorify-as-uspl2 "${pp:t}" - - # Adjust for escape code (nasty, utilizes fact that - # ${ZINIT[col-rst]} is used twice, so as a $ZINIT_COL) - integer adjust_ec=$(( ${#ZINIT[col-rst]} * 2 + ${#ZINIT[col-uname]} + ${#ZINIT[col-pname]} )) - - builtin print "${(r:longest+adjust_ec:: :)REPLY} ${(j:, :)completions}" + typeset -a delete_widgets + delete_widgets=( "${(z)ZINIT[WIDGETS_DELETE__$uspl2]}" ) + local wid + for wid in "${(Oa)delete_widgets[@]}"; do + [[ -z "$wid" ]] && continue + wid="${(Q)wid}" + if [[ -n "${skip_delete[(r)$wid]}" ]]; then + builtin print "Would delete $wid" + continue fi + if [[ "${ZINIT_ZLE_HOOKS_LIST[$wid]}" = "1" ]]; then + (( quiet )) || builtin print "Removing Zle hook \`$wid'" + else + (( quiet )) || builtin print "Removing Zle widget \`$wid'" + fi + zle -D "$wid" done -} # ]]] -# FUNCTION: .zinit-cenable [[[ -# Disables given installed completion. -# -# User-action entry point. -# -# $1 - e.g. "_mkdir" or "mkdir" -.zinit-cenable() { - local c="$1" - c="${c#_}" - - local cfile="${ZINIT[COMPLETIONS_DIR]}/_${c}" - local bkpfile="${cfile:h}/$c" - - if [[ ! -e "$cfile" && ! -e "$bkpfile" ]]; then - builtin print "${ZINIT[col-error]}No such completion \`$c'${ZINIT[col-rst]}" - return 1 - fi - # Check if there is no backup file - # This is treated as if the completion is already enabled - if [[ ! -e "$bkpfile" ]]; then - builtin print "Completion ${ZINIT[col-info]}$c${ZINIT[col-rst]} already enabled" - - .zinit-check-comp-consistency "$cfile" "$bkpfile" 0 - return 1 - fi - - # Disabled, but completion file already exists? - if [[ -e "$cfile" ]]; then - builtin print "${ZINIT[col-error]}Warning: completion's file \`${cfile:t}' exists, will overwrite${ZINIT[col-rst]}" - builtin print "${ZINIT[col-error]}Completion is actually enabled and will re-enable it again${ZINIT[col-rst]}" - .zinit-check-comp-consistency "$cfile" "$bkpfile" 1 - command rm -f "$cfile" - else - .zinit-check-comp-consistency "$cfile" "$bkpfile" 0 - fi + # 6. Unfunction + .zinit-diff-functions-compute "$uspl2" + typeset -a func + func=( "${(z)ZINIT[FUNCTIONS__$uspl2]}" ) + local f + for f in "${(on)func[@]}"; do + [[ -z "$f" ]] && continue + f="${(Q)f}" + (( quiet )) || builtin print "Deleting function $f" + (( ${+functions[$f]} )) && unfunction -- "$f" + (( ${+precmd_functions} )) && precmd_functions=( ${precmd_functions[@]:#$f} ) + (( ${+preexec_functions} )) && preexec_functions=( ${preexec_functions[@]:#$f} ) + (( ${+chpwd_functions} )) && chpwd_functions=( ${chpwd_functions[@]:#$f} ) + (( ${+periodic_functions} )) && periodic_functions=( ${periodic_functions[@]:#$f} ) + (( ${+zshaddhistory_functions} )) && zshaddhistory_functions=( ${zshaddhistory_functions[@]:#$f} ) + (( ${+zshexit_functions} )) && zshexit_functions=( ${zshexit_functions[@]:#$f} ) + done - # Enable - command mv "$bkpfile" "$cfile" # move completion's backup file created when disabling + # 7. Clean up FPATH and PATH + .zinit-diff-env-compute "$uspl2" + # iterate over $path elements and skip those that were added by the plugin + typeset -a new elem p + elem=( "${(z)ZINIT[PATH__$uspl2]}" ) + for p in "${path[@]}"; do + if [[ -z "${elem[(r)${(q)p}]}" ]] { + new+=( "$p" ) + } else { + (( quiet )) || builtin print "Removing PATH element ${ZINIT[col-info]}$p${ZINIT[col-rst]}" + [[ -d "$p" ]] || (( quiet )) || builtin print "${ZINIT[col-error]}Warning:${ZINIT[col-rst]} it didn't exist on disk" + } + done + path=( "${new[@]}" ) - # Prepare readlink command for establishing completion's owner - .zinit-prepare-readlink - # Get completion's owning plugin - .zinit-get-completion-owner-uspl2col "$cfile" "$REPLY" + # The same for $fpath + elem=( "${(z)ZINIT[FPATH__$uspl2]}" ) + new=( ) + for p ( "${fpath[@]}" ) { + if [[ -z "${elem[(r)${(q)p}]}" ]] { + new+=( "$p" ) + } else { + (( quiet )) || builtin print "Removing FPATH element ${ZINIT[col-info]}$p${ZINIT[col-rst]}" + [[ -d "$p" ]] || (( quiet )) || builtin print "${ZINIT[col-error]}Warning:${ZINIT[col-rst]} it didn't exist on disk" + } + } + fpath=( "${new[@]}" ) - builtin print "Enabled ${ZINIT[col-info]}$c${ZINIT[col-rst]} completion belonging to $REPLY" + # 8. Delete created variables + .zinit-diff-parameter-compute "$uspl2" + empty=0 + .zinit-save-set-extendedglob + [[ "${ZINIT[PARAMETERS_POST__$uspl2]}" != *[$'! \t']* ]] && empty=1 + .zinit-restore-extendedglob - return 0 -} # ]]] -# FUNCTION: .zinit-cdisable [[[ -# Enables given installed completion. -# -# User-action entry point. -# -# $1 - e.g. "_mkdir" or "mkdir" -.zinit-cdisable() { - local c="$1" - c="${c#_}" + if (( empty != 1 )); then + typeset -A elem_pre elem_post + elem_pre=( "${(z)ZINIT[PARAMETERS_PRE__$uspl2]}" ) + elem_post=( "${(z)ZINIT[PARAMETERS_POST__$uspl2]}" ) - local cfile="${ZINIT[COMPLETIONS_DIR]}/_${c}" - local bkpfile="${cfile:h}/$c" + # Find variables created or modified + local wl found + local -a whitelist + whitelist=( "${(@Q)${(z@)ZINIT[ENV-WHITELIST]}}" ) + for k in "${(k)elem_post[@]}"; do + k="${(Q)k}" + local v1="${(Q)elem_pre[$k]}" + local v2="${(Q)elem_post[$k]}" - if [[ ! -e "$cfile" && ! -e "$bkpfile" ]]; then - builtin print "${ZINIT[col-error]}No such completion \`$c'${ZINIT[col-rst]}" - return 1 - fi + # "" means a variable was deleted, not created/changed + if [[ $v2 != '""' ]]; then + # Don't unset readonly variables + [[ ${(tP)k} == *-readonly(|-*) ]] && continue - # Check if it's already disabled - # Not existing "$cfile" says that - if [[ ! -e "$cfile" ]]; then - builtin print "Completion ${ZINIT[col-info]}$c${ZINIT[col-rst]} already disabled" + # Don't unset arrays managed by add-zsh-hook, also ignore a few special parameters + # TODO: remember and remove hooks + case "$k" in + (chpwd_functions|precmd_functions|preexec_functions|periodic_functions|zshaddhistory_functions|zshexit_functions|zsh_directory_name_functions) + continue + (path|PATH|fpath|FPATH) + continue; + ;; + esac - .zinit-check-comp-consistency "$cfile" "$bkpfile" 0 - return 1 + # Don't unset redefined variables, only newly defined "" means variable didn't exist before plugin load (didn't have a type). + # Do an exception for the prompt variables + if [[ $v1 = '""' || ( $k = (RPROMPT|RPS1|RPS2|PROMPT|PS1|PS2|PS3|PS4) && $v1 != $v2 ) ]]; then + found=0 + for wl in "${whitelist[@]}"; do + if [[ "$k" = ${~wl} ]]; then + found=1 + break + fi + done + if (( !found )); then + (( quiet )) || builtin print "Unsetting variable $k" + # checked that 4.3.17 does support "--"; cannot be parameter starting with "-" but let's defensively use "--" here + unset -- "$k" + else + builtin print "Skipping unset of variable $k (whitelist)" + fi + fi + fi + done fi - # No disable, but bkpfile exists? - if [[ -e "$bkpfile" ]]; then - builtin print "${ZINIT[col-error]}Warning: completion's backup file \`${bkpfile:t}' already exists, will overwrite${ZINIT[col-rst]}" - .zinit-check-comp-consistency "$cfile" "$bkpfile" 1 - command rm -f "$bkpfile" + # 9. Forget the plugin + if [[ "$uspl2" = "_dtrace/_dtrace" ]]; then + .zinit-clear-debug-report + (( quiet )) || builtin print "dtrace report saved to \$LASTREPORT" else - .zinit-check-comp-consistency "$cfile" "$bkpfile" 0 + (( quiet )) || builtin print "Unregistering plugin $uspl2col" + .zinit-unregister-plugin "$user" "$plugin" "${sice[teleid]}" + zsh_loaded_plugins[${zsh_loaded_plugins[(i)$user${${user:#(%|/)*}:+/}$plugin]}]=() # Support Zsh plugin standard + .zinit-clear-report-for "$user" "$plugin" + (( quiet )) || builtin print "Plugin's report saved to \$LASTREPORT" fi - - # Disable - command mv "$cfile" "$bkpfile" - - # Prepare readlink command for establishing completion's owner - .zinit-prepare-readlink - # Get completion's owning plugin - .zinit-get-completion-owner-uspl2col "$bkpfile" "$REPLY" - - builtin print "Disabled ${ZINIT[col-info]}$c${ZINIT[col-rst]} completion belonging to $REPLY" - - return 0 } # ]]] -# FUNCTION: .zinit-cd [[[ -# Jumps to plugin's directory (in Zinit's home directory). -# -# User-action entry point. -# -# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) -# $2 - plugin (only when $1 - i.e. user - given) -.zinit-cd() { +# FUNCTION: .zinit-update-all-parallel [[[ +.zinit-update-all-parallel() { builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - builtin setopt extendedglob warncreateglobal typesetsilent rcquotes - - .zinit-get-path "$1" "$2" && { - if [[ -e $REPLY ]]; then - builtin pushd $REPLY - else - +zinit-message "No such plugin or snippet" - return 1 - fi - builtin print - } || { - +zinit-message "No such plugin or snippet" - return 1 - } -} # ]]] -# FUNCTION: .zinit-run-delete-hooks [[[ -.zinit-run-delete-hooks() { - # Call make uninstall if it's available - local make_path=$5/Makefile - [[ -f $make_path ]] && \ - grep '^uninstall:' $make_path &>/dev/null && \ - { +zinit-message {pre}Running {cmd}make uninstall{pre}{…} - make -C "$make_path:h" uninstall;} - - if [[ -n ${ICE[atdelete]} ]]; then - .zinit-countdown "atdelete" && ( (( ${+ICE[nocd]} == 0 )) && \ - { builtin cd -q "$5" && eval "${ICE[atdelete]}"; ((1)); } || \ - eval "${ICE[atdelete]}" ) - fi + setopt extendedglob warncreateglobal typesetsilent \ + noshortloops nomonitor nonotify - local -a arr - local key + local id_as repo snip uspl user plugin PUDIR="$(mktemp -d)" - # Run annexes' atdelete hooks - reply=( - ${(on)ZINIT_EXTS2[(I)zinit hook:atdelete-pre <->]} - ${(on)ZINIT_EXTS[(I)z-annex hook:atdelete-<-> <->]} - ${(on)ZINIT_EXTS2[(I)zinit hook:atdelete-post <->]} - ) - for key in "${reply[@]}"; do - arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) - "${arr[5]}" "$1" "$2" $3 "$4" "$5" "${${key##(zinit|z-annex) hook:}%% <->}" delete:TODO - done -} # ]]] -# FUNCTION: .zinit-delete [[[ -# Deletes plugin's or snippet's directory (in Zinit's home directory). -# -# User-action entry point. -# -# $1 - snippet URL or plugin spec (4 formats: user---plugin, user/plugin, user, plugin) -# $2 - plugin (only when $1 - i.e. user - given) -.zinit-delete() { - builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - setopt extendedglob warncreateglobal typesetsilent + local -A PUAssocArray map + map=( / -- "=" -EQ- "?" -QM- "&" -AMP- : - ) + local -a files + integer main_counter counter PUPDATE=1 - local -a opts match mbegin mend - local MATCH; integer MBEGIN MEND _retval + files=( ${ZINIT[SNIPPETS_DIR]}/**/(._zinit|._zplugin)/mode(ND) ) + main_counter=${#files} + if (( OPTS[opt_-s,--snippets] || !OPTS[opt_-l,--plugins] )) { + for snip ( "${files[@]}" ) { + main_counter=main_counter-1 + # The continue may cause the tail of processes to fall-through to the following plugins-specific `wait' + # Should happen only in a very special conditions + # TODO handle this + [[ ! -f ${snip:h}/url ]] && continue + [[ -f ${snip:h}/id-as ]] && \ + id_as="$(<${snip:h}/id-as)" || \ + id_as= - # Parse options - .zinit-parse-opts delete "$@" - builtin set -- "${reply[@]}" - if (( $@[(I)-*] || OPTS[opt_-h,--help] )) { +zinit-prehelp-usage-message delete $___opt_map[delete] $@; return 1; } + counter+=1 + local ef_id="${id_as:-$(<${snip:h}/url)}" + local PUFILEMAIN=${${ef_id#/}//(#m)[\/=\?\&:]/${map[$MATCH]}} + local PUFILE=$PUDIR/${counter}_$PUFILEMAIN.out - local the_id="$1${${1:#(%|/)*}:+${2:+/}}$2" + .zinit-update-or-status-snippet "$st" "$ef_id" &>! $PUFILE & - # -a/--all given? - if (( OPTS[opt_-a,--all] )); then - .zinit-confirm "Prune all plugins in \`${ZINIT[PLUGINS_DIR]}'"\ -"and snippets in \`${ZINIT[SNIPPETS_DIR]}'?" \ -"command rm -rf ${${ZINIT[PLUGINS_DIR]%%[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcEFG312}/*~*/_local---zinit(ND) "\ -"${${ZINIT[SNIPPETS_DIR]%%[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcEFG312}/*~*/plugins(ND)" - return $? - fi + PUAssocArray[$!]=$PUFILE - # -c/--clean given? - if (( OPTS[opt_-c,--clean] )) { - .zinit-confirm "Prune ${ZINIT[col-info]}CURRENTLY NOT LOADED${ZINIT[col-rst]}"\ -" plugins in $ZINIT[col-file]$ZINIT[PLUGINS_DIR]%f%b"\ -" and snippets in $ZINIT[col-file]$ZINIT[SNIPPETS_DIR]%f%b?" \ -" # Delete unloaded snippets -local -aU loadedsnips todelete final_todelete -loadedsnips=( \${\${ZINIT_SNIPPETS[@]% <*>}/(#m)*/\$(.zinit-get-object-path snippet \"\$MATCH\" && builtin print -rn \$REPLY; )} ) -local dir=\${\${ZINIT[SNIPPETS_DIR]%%[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/xyzcba231} -todelete=( \$dir/*/*/*(ND/) \$dir/*/*(ND/) \$dir/*(ND/) ) -final_todelete=( \${todelete[@]:#*/(\${(~j:|:)loadedsnips}|*/plugins|._backup|._zinit|.svn|.git)(|/*)} ) -final_todelete=( \${final_todelete[@]//(#m)*/\$( .zinit-get-object-path snippet \"\${\${\${MATCH##\${dir}[/[:space:]]#}/(#i)(#b)(http(s|)|ftp(s|)|ssh|rsync)--/\${match[1]##--}://}//--//}\" && builtin print -r -- \$REPLY)} ) -final_todelete=( \${final_todelete[@]:#(\${(~j:|:)loadedsnips}|*/plugins|*/._backup|*/._zinit|*/.svn|*/.git)(|/*)} ) -todelete=( \${\${\${(@)\${(@)final_todelete##\$dir/#}//(#i)(#m)(http(s|)|ftp(s|)|ssh|rsync)--/\${MATCH%--}://}//--//}//(#b)(*)\/([^\/]##)(#e)/\$match[1]/\$ZINIT[col-file]\$match[2]\$ZINIT[col-rst]} ) -todelete=( \${todelete[@]//(#m)(#s)[^\/]##(#e)/\$ZINIT[col-file]\$MATCH\$ZINIT[col-rst]} ) -final_todelete=( \${\${\${(@)\${(@)final_todelete##\$dir/#}//(#i)(#m)(http(s|)|ftp(s|)|ssh|rsync)--/\${MATCH%--}://}//--//}//(#b)(*)\/([^\/]##)(#e)/\$match[1]/\$match[2]} ) -builtin print; print -Prln \"\$ZINIT[col-obj]Deleting the following \"\ -\"\$ZINIT[col-file]\${#todelete}\$ZINIT[col-msg2] UNLOADED\$ZINIT[col-obj] snippets:%f%b\" \ - \$todelete \"%f%b\" -sleep 3 -local snip -for snip ( \$final_todelete ) { zinit delete -q -y \$snip; _retval+=\$?; } -builtin print -Pr \"\$ZINIT[col-obj]Done (with the exit code: \$_retval).%f%b\" - -# Next delete unloaded plugins -local -a dirs -dirs=( \${\${ZINIT[PLUGINS_DIR]%%[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcEFG312}/*~*/(\${(~j:|:)\${ZINIT_REGISTERED_PLUGINS[@]//\//---}})(ND/) ) -dirs=( \${(@)\${dirs[@]##\$ZINIT[PLUGINS_DIR]/#}//---//} ) -builtin print -Prl \"\" \"\$ZINIT[col-obj]Deleting the following \"\ -\"\$ZINIT[col-file]\${#dirs}\$ZINIT[col-msg2] UNLOADED\$ZINIT[col-obj] plugins:%f%b\" \ -\${\${dirs//(#b)(*)(\/([^\/]##))(#e)/\${\${match[2]:+\$ZINIT[col-uname]\$match[1]\$ZINIT[col-rst]/\$ZINIT[col-pname]\$match[3]\$ZINIT[col-rst]}:-\$ZINIT[col-pname]\$match[1]}}//(#b)(^\$ZINIT[col-uname])(*)/\$ZINIT[col-pname]\$match[1]} -sleep 3 -for snip ( \$dirs ) { zinit delete -q -y \$snip; _retval+=\$?; } -builtin print -Pr \"\$ZINIT[col-obj]Done (with the exit code: \$_retval).%f%b\"" - return _retval + .zinit-wait-for-update-jobs snippets + } } - local -A ICE2 - local local_dir filename is_snippet - - .zinit-compute-ice "$the_id" "pack" \ - ICE2 local_dir filename is_snippet || return 1 - - if [[ "$local_dir" != /* ]] - then - builtin print "Obtained a risky, not-absolute path ($local_dir), aborting" - return 1 - fi - - ICE2[teleid]="${ICE2[teleid]:-${ICE2[id-as]}}" - - local -a files - files=( "$local_dir"/*.(zsh|sh|bash|ksh)(DN:t) - "$local_dir"/*(*DN:t) "$local_dir"/*(@DN:t) "$local_dir"/*(.DN:t) - "$local_dir"/*~*/.(_zinit|svn|git)(/DN:t) "$local_dir"/*(=DN:t) - "$local_dir"/*(pDN:t) "$local_dir"/*(%DN:t) - ) - (( !${#files} )) && files=( "no files?" ) - files=( ${(@)files[1,4]} ${files[4]+more…} ) + counter=0 + PUAssocArray=() - # Make the ices available for the hooks. - local -A ICE - ICE=( "${(kv)ICE2[@]}" ) + if (( OPTS[opt_-l,--plugins] || !OPTS[opt_-s,--snippets] )) { + local -a files2 + files=( ${ZINIT[PLUGINS_DIR]}/*(ND/) ) - if (( is_snippet )); then - if [[ "${+ICE2[svn]}" = "1" ]] { - if [[ -e "$local_dir" ]] - then - .zinit-confirm "Delete $local_dir? (it holds: ${(j:, :)${(@u)files}})" \ - ".zinit-run-delete-hooks snippet \"${ICE2[teleid]}\" \"\" \"$the_id\" \ - \"$local_dir\"; \ - command rm -rf ${(q)${${local_dir:#[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcYZX321}}" - else - builtin print "No such snippet" - return 1 - fi - } else { - if [[ -e "$local_dir" ]]; then - .zinit-confirm "Delete $local_dir? (it holds: ${(j:, :)${(@u)files}})" \ - ".zinit-run-delete-hooks snippet \"${ICE2[teleid]}\" \"\" \"$the_id\" \ - \"$local_dir\"; command rm -rf \ - ${(q)${${local_dir:#[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcYZX321}}" - else - builtin print "No such snippet" - return 1 - fi - } - else - .zinit-any-to-user-plugin "${ICE2[teleid]}" - if [[ -e "$local_dir" ]]; then - .zinit-confirm "Delete $local_dir? (it holds: ${(j:, :)${(@u)files}})" \ - ".zinit-run-delete-hooks plugin \"${reply[-2]}\" \"${reply[-1]}\" \"$the_id\" \ - \"$local_dir\"; \ - command rm -rf ${(q)${${local_dir:#[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcYZX321}}" - else - builtin print -r -- "No such plugin or snippet" - return 1 - fi - fi + # Pre-process plugins + for repo ( $files ) { + uspl=${repo:t} + # Two special cases + [[ $uspl = custom || $uspl = _local---zinit ]] && continue - return 0 -} # ]]] -# FUNCTION: .zinit-confirm [[[ -# Prints given question, waits for "y" key, evals -# given expression if "y" obtained -# -# $1 - question -# $2 - expression -.zinit-confirm() { - if (( OPTS[opt_-y,--yes] )); then - integer retval - eval "$2"; retval=$? - (( OPTS[opt_-q,--quiet] )) || builtin print "\nDone (action executed, exit code: $retval)" - else - builtin print -Pr -- "$1" - builtin print "[yY/n…]" - local ans - if [[ -t 0 ]] { - read -q ans - } else { - read -k1 -u0 ans - } - if [[ "$ans" = "y" ]] { - eval "$2" - builtin print "\nDone (action executed, exit code: $?)" - } else { - builtin print "\nBreak, no action" - return 1 + # Check if repository has a remote set + if [[ -f $repo/.git/config ]] { + local -a config + config=( ${(f)"$(<$repo/.git/config)"} ) + if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]] { + continue + } + } + + .zinit-any-to-user-plugin "$uspl" + local user=${reply[-2]} plugin=${reply[-1]} + + # Must be a git repository or a binary release + if [[ ! -d $repo/.git && ! -f $repo/._zinit/is_release ]] { + continue + } + files2+=( $repo ) } - fi - return 0 -} # ]]] -# FUNCTION: .zinit-changes [[[ -# Shows `git log` of given plugin. -# -# User-action entry point. -# -# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) -# $2 - plugin (only when $1 - i.e. user - given) -.zinit-changes() { - .zinit-any-to-user-plugin "$1" "$2" - local user="${reply[-2]}" plugin="${reply[-1]}" - .zinit-exists-physically-message "$user" "$plugin" || return 1 + main_counter=${#files2} + for repo ( "${files2[@]}" ) { + main_counter=main_counter-1 - ( - builtin cd -q "${ZINIT[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}" && \ - command git log -p --graph --decorate --date=relative -C -M - ) -} # ]]] -# FUNCTION: .zinit-recently [[[ -# Shows plugins that obtained commits in specified past time. -# -# User-action entry point. -# -# $1 - time spec, e.g. "1 week" -.zinit-recently() { - builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - builtin setopt nullglob extendedglob warncreateglobal \ - typesetsilent noshortloops + uspl=${repo:t} + id_as=${uspl//---//} - local IFS=. - local gitout - local timespec=${*// ##/.} - timespec=${timespec//.##/.} - [[ -z $timespec ]] && timespec=1.week + counter+=1 + local PUFILEMAIN=${${id_as#/}//(#m)[\/=\?\&:]/${map[$MATCH]}} + local PUFILE=$PUDIR/${counter}_$PUFILEMAIN.out - typeset -a plugins - plugins=( ${ZINIT[PLUGINS_DIR]}/*(DN-/) ) + .zinit-any-colorify-as-uspl2 "$uspl" + +zinit-message "Updating $REPLY{…}" >! $PUFILE - local p uspl1 - for p in ${plugins[@]}; do - uspl1=${p:t} - [[ $uspl1 = custom || $uspl1 = _local---zinit ]] && continue + .zinit-any-to-user-plugin "$uspl" + local user=${reply[-2]} plugin=${reply[-1]} - pushd "$p" >/dev/null || continue - if [[ -d .git ]]; then - gitout=`command git log --all --max-count=1 --since=$timespec 2>/dev/null` - if [[ -n $gitout ]]; then - .zinit-any-colorify-as-uspl2 "$uspl1" - builtin print -r -- "$REPLY" - fi - fi - popd >/dev/null - done + .zinit-update-or-status update "$user" "$plugin" &>>! $PUFILE & + + PUAssocArray[$!]=$PUFILE + + .zinit-wait-for-update-jobs plugins + + } + } + # Shouldn't happen + # (( ${#PUAssocArray} > 0 )) && wait ${(k)PUAssocArray} } # ]]] -# FUNCTION: .zinit-create [[[ -# Creates a plugin, also on Github (if not "_local/name" plugin). +# FUNCTION: .zinit-update-or-status [[[ +# Updates (git pull) or does `git status' for given plugin. # # User-action entry point. # -# $1 - (optional) plugin spec (4 formats: user---plugin, user/plugin, user, plugin) -# $2 - (optional) plugin (only when $1 - i.e. user - given) -.zinit-create() { +# $1 - "status" for status, other for update +# $2 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin) +# $3 - plugin (only when $1 - i.e. user - given) +.zinit-update-or-status() { + # Set the localtraps option. builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - setopt localoptions extendedglob warncreateglobal typesetsilent \ - noshortloops rcquotes + setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops - .zinit-any-to-user-plugin "$1" "$2" - local user="${reply[-2]}" plugin="${reply[-1]}" + local -a arr + ZINIT[first-plugin-mark]=${${ZINIT[first-plugin-mark]:#init}:-1} + ZINIT[-r/--reset-opt-hook-has-been-run]=0 - if (( ${+commands[curl]} == 0 || ${+commands[git]} == 0 )); then - builtin print "${ZINIT[col-error]}curl and git are needed${ZINIT[col-rst]}" - return 1 + # Deliver and withdraw the `m` function when finished. + .zinit-set-m-func set + trap ".zinit-set-m-func unset" EXIT + + integer retval hook_rc was_snippet + .zinit-two-paths "$2${${2:#(%|/)*}:+${3:+/}}$3" + if [[ -d ${reply[-4]} || -d ${reply[-2]} ]]; then + .zinit-update-or-status-snippet "$1" "$2${${2:#(%|/)*}:+${3:+/}}$3" + retval=$? + was_snippet=1 fi - # Read whether to create under organization - local isorg - vared -cp 'Create under an organization? (y/n): ' isorg + .zinit-any-to-user-plugin "$2" "$3" + local user=${reply[-2]} plugin=${reply[-1]} st=$1 \ + local_dir filename is_snippet key \ + id_as="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" + local -A ice - if [[ $isorg = (y|yes) ]]; then - local org="$user" - vared -cp "Github organization name: " org + if (( was_snippet )) { + .zinit-exists-physically "$user" "$plugin" || return $retval + .zinit-any-colorify-as-uspl2 "$2" "$3" + (( !OPTS[opt_-q,--quiet] )) && \ + +zinit-message "{msg2}Updating also \`$REPLY{rst}{msg2}'" \ + "plugin (already updated a snippet of the same name){…}{rst}" + } else { + .zinit-exists-physically-message "$user" "$plugin" || return 1 + } + + if [[ $st = status ]]; then + ( builtin cd -q ${ZINIT[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}; command git status; ) + return $retval fi - # Read user - local compcontext="user:User Name:(\"$USER\" \"$user\")" - vared -cp "Github user name or just \"_local\" (or leave blank, for an userless plugin): " user + command rm -f ${TMPDIR:-${TMPDIR:-/tmp}}/zinit-execs.$$.lst ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.installed_comps.$$.lst \ + ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.skipped_comps.$$.lst ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.compiled.$$.lst - # Read plugin - unset compcontext - vared -cp 'Plugin name: ' plugin + # A flag for the annexes. 0 – no new commits, 1 - run-atpull mode, + # 2 – full update/there are new commits to download, 3 - full but + # a forced download (i.e.: the medium doesn't allow to peek update) + ZINIT[annex-multi-flag:pull-active]=0 - if [[ "$plugin" = "_unknown" ]]; then - builtin print "${ZINIT[col-error]}No plugin name entered${ZINIT[col-rst]}" - return 1 - fi + (( ${#ICE[@]} > 0 )) && { ZINIT_SICE[$user${${user:#(%|/)*}:+/}$plugin]=""; local nf="-nftid"; } - plugin="${plugin//[^a-zA-Z0-9_]##/-}" - .zinit-any-colorify-as-uspl2 "${${${(M)isorg:#(y|yes)}:+$org}:-$user}" "$plugin" - local uspl2col="$REPLY" - builtin print "Plugin is $uspl2col" + .zinit-compute-ice "$user${${user:#(%|/)*}:+/}$plugin" "pack$nf" \ + ice local_dir filename is_snippet || return 1 - if .zinit-exists-physically "${${${(M)isorg:#(y|yes)}:+$org}:-$user}" "$plugin"; then - builtin print "${ZINIT[col-error]}Repository${ZINIT[col-rst]} $uspl2col ${ZINIT[col-error]}already exists locally${ZINIT[col-rst]}" - return 1 - fi + .zinit-any-to-user-plugin ${ice[teleid]:-$id_as} + user=${reply[1]} plugin=${reply[2]} - builtin cd -q "${ZINIT[PLUGINS_DIR]}" + local repo="${${${(M)id_as#%}:+${id_as#%}}:-${ZINIT[PLUGINS_DIR]}/${id_as//\//---}}" - if [[ "$user" != "_local" && -n "$user" ]]; then - builtin print "${ZINIT[col-info]}Creating Github repository${ZINIT[col-rst]}" - if [[ $isorg = (y|yes) ]]; then - curl --silent -u "$user" https://api.github.com/orgs/$org/repos -d '{"name":"'"$plugin"'"}' >/dev/null - else - curl --silent -u "$user" https://api.github.com/user/repos -d '{"name":"'"$plugin"'"}' >/dev/null - fi - command git clone "https://github.com/${${${(M)isorg:#(y|yes)}:+$org}:-$user}/${plugin}.git" "${${${(M)isorg:#(y|yes)}:+$org}:-$user}---${plugin//\//---}" || { - builtin print "${ZINIT[col-error]}Creation of remote repository $uspl2col ${ZINIT[col-error]}failed${ZINIT[col-rst]}" - builtin print "${ZINIT[col-error]}Bad credentials?${ZINIT[col-rst]}" + # Run annexes' preinit hooks + local -a arr + reply=( + ${(on)ZINIT_EXTS2[(I)zinit hook:preinit-pre <->]} + ${(on)ZINIT_EXTS[(I)z-annex hook:preinit-<-> <->]} + ${(on)ZINIT_EXTS2[(I)zinit hook:preinit-post <->]} + ) + for key in "${reply[@]}"; do + arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) + "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" ${${key##(zinit|z-annex) hook:}%% <->} update || \ + return $(( 10 - $? )) + done + + # Check if repository has a remote set, if it is _local + if [[ -f $local_dir/.git/config ]]; then + local -a config + config=( ${(f)"$(<$local_dir/.git/config)"} ) + if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]]; then + (( !OPTS[opt_-q,--quiet] )) && { + .zinit-any-colorify-as-uspl2 "$id_as" + [[ $id_as = _local/* ]] && builtin print -r -- "Skipping local plugin $REPLY" || \ + builtin print -r -- "$REPLY doesn't have a remote set, will not fetch" + } return 1 + fi + fi + + command rm -f $local_dir/.zinit_lastupd + + if (( 1 )); then + if [[ -z ${ice[is_release]} && ${ice[from]} = (gh-r|github-rel|cygwin) ]] { + ice[is_release]=true } - builtin cd -q "${${${(M)isorg:#(y|yes)}:+$org}:-$user}---${plugin//\//---}" - command git config credential.https://github.com.username "${user}" - else - builtin print "${ZINIT[col-info]}Creating local git repository${${user:+.}:-, ${ZINIT[col-pname]}free-style, without the \"_local/\" part${ZINIT[col-info]}.}${ZINIT[col-rst]}" - command mkdir "${user:+${user}---}${plugin//\//---}" - builtin cd -q "${user:+${user}---}${plugin//\//---}" - command git init || { - builtin print "Git repository initialization failed, aborting" - return 1 + + integer count is_release=0 + for (( count = 1; count <= 5; ++ count )) { + if (( ${+ice[is_release${count:#1}]} )) { + is_release=1 + } + } + + (( ${+functions[.zinit-setup-plugin-dir]} )) || builtin source ${ZINIT[BIN_DIR]}"/zinit-install.zsh" + if [[ $ice[from] == (gh-r|github-rel) ]] { + { + ICE=( "${(kv)ice[@]}" ) + .zinit-get-latest-gh-r-url-part "$user" "$plugin" || return $? + } always { + ICE=() + } + } else { + REPLY="" + } + + if (( is_release )) { + count=0 + for REPLY ( $reply ) { + count+=1 + local version=${REPLY/(#b)(\/[^\/]##)(#c4,4)\/([^\/]##)*/${match[2]}} + if [[ ${ice[is_release${count:#1}]} = $REPLY ]] { + (( ${+ice[run-atpull]} || OPTS[opt_-u,--urge] )) && \ + ZINIT[annex-multi-flag:pull-active]=1 || \ + ZINIT[annex-multi-flag:pull-active]=0 + } else { + ZINIT[annex-multi-flag:pull-active]=2 + break + } + } + if (( ZINIT[annex-multi-flag:pull-active] <= 1 && !OPTS[opt_-q,--quiet] )) { + +zinit-message "{info}[{pre}${ice[from]}{info}]{rst} latest version ({version}${version}{rst}) already installed" + } } - fi - local user_name="$(command git config user.name 2>/dev/null)" - local year="${$(command date "+%Y"):-2020}" + if (( 1 )) { + if (( ZINIT[annex-multi-flag:pull-active] >= 1 )) { + if (( OPTS[opt_-q,--quiet] && !PUPDATE )) { + .zinit-any-colorify-as-uspl2 "$id_as" + (( ZINIT[first-plugin-mark] )) && { + ZINIT[first-plugin-mark]=0 + } || builtin print + builtin print "\rUpdating $REPLY" + } - command cat >! "${plugin:t}.plugin.zsh" <]} + ${${(M)ICE[atpull]#\!}:+${(on)ZINIT_EXTS[(I)z-annex hook:\!atpull-<-> <->]}} + ${(on)ZINIT_EXTS2[(I)zinit hook:e-\!atpull-post <->]} + ) + for key in "${reply[@]}"; do + arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) + "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zinit|z-annex) hook:}%% <->}" update:bin + hook_rc=$? + [[ "$hook_rc" -ne 0 ]] && { + # note: this will effectively return the last != 0 rc + retval="$hook_rc" + builtin print -Pr -- "${ZINIT[col-warn]}Warning:%f%b ${ZINIT[col-obj]}${arr[5]}${ZINIT[col-warn]} hook returned with ${ZINIT[col-obj]}${hook_rc}${ZINIT[col-rst]}" + } + done -# Copyright (c) $year $user_name + if (( ZINIT[annex-multi-flag:pull-active] >= 2 )) { + if ! .zinit-setup-plugin-dir "$user" "$plugin" "$id_as" release -u $version; then + ZINIT[annex-multi-flag:pull-active]=0 + fi + if (( OPTS[opt_-q,--quiet] != 1 )) { + builtin print + } + } + ICE=() + } + } -# According to the Zsh Plugin Standard: -# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html + if [[ -d $local_dir/.git ]] && ( builtin cd -q $local_dir ; git show-ref --verify --quiet refs/heads/main ); then + local main_branch=main + else + local main_branch=master + fi -0=\${\${ZERO:-\${0:#\$ZSH_ARGZERO}}:-\${(%):-%N}} -0=\${\${(M)0:#/*}:-\$PWD/\$0} + if (( ! is_release )) { + ( builtin cd -q "$local_dir" || return 1 + integer had_output=0 + local IFS=$'\n' + command git fetch --quiet && \ + command git --no-pager log --color --date=short --pretty=format:'%Cgreen%cd %h %Creset%s%n' ..FETCH_HEAD | \ + while read line; do + [[ -n ${line%%[[:space:]]##} ]] && { + [[ $had_output -eq 0 ]] && { + had_output=1 + if (( OPTS[opt_-q,--quiet] && !PUPDATE )) { + .zinit-any-colorify-as-uspl2 "$id_as" + (( ZINIT[first-plugin-mark] )) && { + ZINIT[first-plugin-mark]=0 + } || builtin print + builtin print "Updating $REPLY" + } + } + builtin print $line + } + done | \ + command tee .zinit_lastupd | \ + .zinit-pager & -# Then \${0:h} to get plugin's directory + integer pager_pid=$! + { sleep 20 && kill -9 $pager_pid 2>/dev/null 1>&2; } &! + { wait $pager_pid; } > /dev/null 2>&1 -if [[ \${zsh_loaded_plugins[-1]} != */${plugin:t} && -z \${fpath[(r)\${0:h}]} ]] { - fpath+=( "\${0:h}" ) -} + local -a log + { log=( ${(@f)"$(<$local_dir/.zinit_lastupd)"} ); } 2>/dev/null + command rm -f $local_dir/.zinit_lastupd -# Standard hash for plugins, to not pollute the namespace -typeset -gA Plugins -Plugins[${${(U)plugin:t}//-/_}_DIR]="\${0:h}" + if [[ ${#log} -gt 0 ]] { + ZINIT[annex-multi-flag:pull-active]=2 + } else { + if (( ${+ice[run-atpull]} || OPTS[opt_-u,--urge] )) { + ZINIT[annex-multi-flag:pull-active]=1 -autoload -Uz template-script + # Handle the snippet/plugin boundary in the messages + if (( OPTS[opt_-q,--quiet] && !PUPDATE )) { + .zinit-any-colorify-as-uspl2 "$id_as" + (( ZINIT[first-plugin-mark] )) && { + ZINIT[first-plugin-mark]=0 + } || builtin print + builtin print "\rUpdating $REPLY" + } + } else { + ZINIT[annex-multi-flag:pull-active]=0 + } + } -# Use alternate vim marks [[[ and ]]] as the original ones can -# confuse nested substitutions, e.g.: \${\${\${VAR}}} + if (( ZINIT[annex-multi-flag:pull-active] >= 1 )) { + ICE=( "${(kv)ice[@]}" ) + # Run annexes' atpull hooks (the before atpull-ice ones). + # The regular Git-plugins block. + reply=( + ${(on)ZINIT_EXTS2[(I)zinit hook:e-\!atpull-pre <->]} + ${${(M)ICE[atpull]#\!}:+${(on)ZINIT_EXTS[(I)z-annex hook:\!atpull-<-> <->]}} + ${(on)ZINIT_EXTS2[(I)zinit hook:e-\!atpull-post <->]} + ) + for key in "${reply[@]}"; do + arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) + "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zinit|z-annex) hook:}%% <->}" update:git + hook_rc=$? + [[ "$hook_rc" -ne 0 ]] && { + # note: this will effectively return the last != 0 rc + retval="$hook_rc" + builtin print -Pr -- "${ZINIT[col-warn]}Warning:%f%b ${ZINIT[col-obj]}${arr[5]}${ZINIT[col-warn]} hook returned with ${ZINIT[col-obj]}${hook_rc}${ZINIT[col-rst]}" + } + done + ICE=() + (( ZINIT[annex-multi-flag:pull-active] >= 2 )) && command git pull --no-stat ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} |& command grep -E -v '(FETCH_HEAD|up.to.date\.|From.*://)' + } + return ${ZINIT[annex-multi-flag:pull-active]} + ) + ZINIT[annex-multi-flag:pull-active]=$? + } -# vim:ft=zsh:tw=80:sw=4:sts=4:et:foldmarker=[[[,]]] -EOF + if [[ -d $local_dir/.git ]]; then + ( + builtin cd -q "$local_dir" # || return 1 - don't return, maybe it's some hook's logic + if (( OPTS[opt_-q,--quiet] )) { + command git pull --recurse-submodules ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} &> /dev/null + } else { + command git pull --recurse-submodules ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} |& command grep -E -v '(FETCH_HEAD|up.to.date\.|From.*://)' + } + ) + fi + if [[ -n ${(v)ice[(I)(mv|cp|atpull|ps-on-update|cargo)]} || $+ice[sbin]$+ice[make]$+ice[extract]$+ice[configure] -ne 0 ]] { + if (( !OPTS[opt_-q,--quiet] && ZINIT[annex-multi-flag:pull-active] == 1 )) { + +zinit-message -n "{pre}[update]{msg3} Continuing with the update because " + (( ${+ice[run-atpull]} )) && \ + +zinit-message "{ice}run-atpull{apo}''{msg3} ice given.{rst}" || \ + +zinit-message "{opt}-u{msg3}/{opt}--urge{msg3} given.{rst}" + } + } - builtin print -r -- "# $plugin" >! "README.md" - command cp -vf "${ZINIT[BIN_DIR]}/LICENSE" LICENSE - command cp -vf "${ZINIT[BIN_DIR]}/share/template-plugin/zsh.gitignore" .gitignore - command cp -vf "${ZINIT[BIN_DIR]}/share/template-plugin/template-script" . + # Any new commits? + if (( ZINIT[annex-multi-flag:pull-active] >= 1 )) { + ICE=( "${(kv)ice[@]}" ) + # Run annexes' atpull hooks (the before atpull[^!]…-ice ones). + # Block common for Git and gh-r plugins. + reply=( + ${(on)ZINIT_EXTS2[(I)zinit hook:no-e-\!atpull-pre <->]} + ${${ICE[atpull]:#\!*}:+${(on)ZINIT_EXTS[(I)z-annex hook:\!atpull-<-> <->]}} + ${(on)ZINIT_EXTS2[(I)zinit hook:no-e-\!atpull-post <->]} + ) + for key in "${reply[@]}"; do + arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) + "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zinit|z-annex) hook:}%% <->}" update + hook_rc="$?" + [[ "$hook_rc" -ne 0 ]] && { + # note: this will effectively return the last != 0 rc + retval="$hook_rc" + builtin print -Pr -- "${ZINIT[col-warn]}Warning:%f%b ${ZINIT[col-obj]}${arr[5]}${ZINIT[col-warn]} hook returned with ${ZINIT[col-obj]}${hook_rc}${ZINIT[col-rst]}" + } + done - command sed -i -e "s/MY_PLUGIN_DIR/${${(U)plugin:t}//-/_}_DIR/g" template-script - command sed -i -e "s/USER_NAME/$user_name/g" template-script - command sed -i -e "s/YEAR/$year/g" template-script + # Run annexes' atpull hooks (the after atpull-ice ones). + # Block common for Git and gh-r plugins. + reply=( + ${(on)ZINIT_EXTS2[(I)zinit hook:atpull-pre <->]} + ${(on)ZINIT_EXTS[(I)z-annex hook:atpull-<-> <->]} + ${(on)ZINIT_EXTS2[(I)zinit hook:atpull-post <->]} + ) + for key in "${reply[@]}"; do + arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) + "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zinit|z-annex) hook:}%% <->}" update + hook_rc="$?" + [[ "$hook_rc" -ne 0 ]] && { + # note: this will effectively return the last != 0 rc + retval="$hook_rc" + builtin print -Pr -- "${ZINIT[col-warn]}Warning:%f%b ${ZINIT[col-obj]}${arr[5]}${ZINIT[col-warn]} hook returned with ${ZINIT[col-obj]}${hook_rc}${ZINIT[col-rst]}" + } + done + ICE=() + } - if [[ "$user" != "_local" && -n "$user" ]]; then - builtin print "Your repository is ready\!" - builtin print "An MIT LICENSE file has been placed - please review the " \ - "license terms to see if they fit your new project:" - builtin print "- https://choosealicense.com/" - builtin print "Remote repository $uspl2col set up as origin." - builtin print "You're in plugin's local folder, the files aren't added to git." - builtin print "Your next step after commiting will be:" - builtin print "git push -u origin master (or \`… -u origin main')" - else - builtin print "Created local $uspl2col plugin." - builtin print "You're in plugin's repository folder, the files aren't added to git." + # Store ices to disk at update of plugin + .zinit-store-ices "$local_dir/._zinit" ice "" "" "" "" fi -} # ]]] -# FUNCTION: .zinit-glance [[[ -# Shows colorized source code of plugin. Is able to use pygmentize, -# highlight, GNU source-highlight. -# -# User-action entry point. -# -# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) -# $2 - plugin (only when $1 - i.e. user - given) -.zinit-glance() { - .zinit-any-to-user-plugin "$1" "$2" - local user="${reply[-2]}" plugin="${reply[-1]}" - .zinit-exists-physically-message "$user" "$plugin" || return 1 + # Run annexes' atpull hooks (the `always' after atpull-ice ones) + # Block common for Git and gh-r plugins. + ICE=( "${(kv)ice[@]}" ) + reply=( + ${(on)ZINIT_EXTS2[(I)zinit hook:%atpull-pre <->]} + ${(on)ZINIT_EXTS[(I)z-annex hook:%atpull-<-> <->]} + ${(on)ZINIT_EXTS2[(I)zinit hook:%atpull-post <->]} + ) + for key in "${reply[@]}"; do + arr=( "${(Q)${(z@)ZINIT_EXTS[$key]:-$ZINIT_EXTS2[$key]}[@]}" ) + "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zinit|z-annex) hook:}%% <->}" update:$ZINIT[annex-multi-flag:pull-active] + hook_rc=$? + [[ "$hook_rc" -ne 0 ]] && { + # note: this will effectively return the last != 0 rc + retval="$hook_rc" + builtin print -Pr -- "${ZINIT[col-warn]}Warning:%f%b ${ZINIT[col-obj]}${arr[5]}${ZINIT[col-warn]} hook returned with ${ZINIT[col-obj]}${hook_rc}${ZINIT[col-rst]}" + } + done + ICE=() - .zinit-first "$1" "$2" || { - builtin print "${ZINIT[col-error]}No source file found, cannot glance${ZINIT[col-rst]}" - return 1 + typeset -ga INSTALLED_EXECS + { INSTALLED_EXECS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zinit-execs.$$.lst)}" ) } 2>/dev/null + + if [[ -e ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.skipped_comps.$$.lst || -e ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.installed_comps.$$.lst ]] { + typeset -ga INSTALLED_COMPS SKIPPED_COMPS + { INSTALLED_COMPS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zinit.installed_comps.$$.lst)}" ) } 2>/dev/null + { SKIPPED_COMPS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zinit.skipped_comps.$$.lst)}" ) } 2>/dev/null } - local fname="${reply[-1]}" - - integer has_256_colors=0 - [[ "$TERM" = xterm* || "$TERM" = "screen" ]] && has_256_colors=1 + if [[ -e ${TMPDIR:-${TMPDIR:-/tmp}}/zinit.compiled.$$.lst ]] { + typeset -ga ADD_COMPILED + { ADD_COMPILED=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zinit.compiled.$$.lst)}" ) } 2>/dev/null + } - { - if (( ${+commands[pygmentize]} )); then - builtin print "Glancing with ${ZINIT[col-info]}pygmentize${ZINIT[col-rst]}" - pygmentize -l bash -g "$fname" - elif (( ${+commands[highlight]} )); then - builtin print "Glancing with ${ZINIT[col-info]}highlight${ZINIT[col-rst]}" - if (( has_256_colors )); then - highlight -q --force -S sh -O xterm256 "$fname" - else - highlight -q --force -S sh -O ansi "$fname" - fi - elif (( ${+commands[source-highlight]} )); then - builtin print "Glancing with ${ZINIT[col-info]}source-highlight${ZINIT[col-rst]}" - source-highlight -fesc --failsafe -s zsh -o STDOUT -i "$fname" - else - cat "$fname" - fi - } | { - if [[ -t 1 ]]; then - .zinit-pager - else - cat - fi + if (( PUPDATE && ZINIT[annex-multi-flag:pull-active] > 0 )) { + builtin print ${ZINIT[annex-multi-flag:pull-active]} >! $PUFILE.ind } + + return $retval } # ]]] -# FUNCTION: .zinit-edit [[[ -# Runs $EDITOR on source of given plugin. If the variable is not -# set then defaults to `vim'. +# FUNCTION: .zinit-update-or-status-all [[[ +# Updates (git pull) or does `git status` for all existing plugins. +# This includes also plugins that are not loaded into Zsh (but exist +# on disk). Also updates (i.e. redownloads) snippets. # # User-action entry point. -# -# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) -# $2 - plugin (only when $1 - i.e. user - given) -.zinit-edit() { - local -A ICE2 - local local_dir filename is_snippet the_id="$1${${1:#(%|/)*}:+${2:+/}}$2" +.zinit-update-or-status-all() { + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops - .zinit-compute-ice "$the_id" "pack" \ - ICE2 local_dir filename is_snippet || return 1 + local -F2 SECONDS=0 - ICE2[teleid]="${ICE2[teleid]:-${ICE2[id-as]}}" + .zinit-self-update -q - if (( is_snippet )); then - if [[ ! -e "$local_dir" ]]; then - builtin print "No such snippet" - return 1 - fi - else - if [[ ! -e "$local_dir" ]]; then - builtin print -r -- "No such plugin or snippet" - return 1 - fi - fi + [[ $2 = restart ]] && \ + +zinit-message "{msg2}Restarting the update with the new codebase loaded.{rst}"$'\n' - "${EDITOR:-vim}" "$local_dir" - return 0 -} # ]]] -# FUNCTION: .zinit-stress [[[ -# Compiles plugin with various options on and off to see -# how well the code is written. The options are: -# -# NO_SHORT_LOOPS, IGNORE_BRACES, IGNORE_CLOSE_BRACES, SH_GLOB, -# CSH_JUNKIE_QUOTES, NO_MULTI_FUNC_DEF. -# -# User-action entry point. -# -# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) -# $2 - plugin (only when $1 - i.e. user - given) -.zinit-stress() { - .zinit-any-to-user-plugin "$1" "$2" - local user="${reply[-2]}" plugin="${reply[-1]}" + local file + integer sum el update_rc + for file ( "" -side -install -autoload ) { + .zinit-get-mtime-into "${ZINIT[BIN_DIR]}/zinit$file.zsh" el; sum+=el + } - .zinit-exists-physically-message "$user" "$plugin" || return 1 + # Reload Zinit? + if [[ $2 != restart ]] && (( ZINIT[mtime] + ZINIT[mtime-side] + + ZINIT[mtime-install] + ZINIT[mtime-autoload] != sum + )) { + +zinit-message "{msg2}Detected Zinit update in another session -" \ + "{pre}reloading Zinit{msg2}{…}{rst}" + source $ZINIT[BIN_DIR]/zinit.zsh + source $ZINIT[BIN_DIR]/zinit-side.zsh + source $ZINIT[BIN_DIR]/zinit-install.zsh + source $ZINIT[BIN_DIR]/zinit-autoload.zsh + for file ( "" -side -install -autoload ) { + .zinit-get-mtime-into "${ZINIT[BIN_DIR]}/zinit$file.zsh" "ZINIT[mtime$file]" + } + +zinit-message "%B{pname}Done.{rst}"$'\n' + .zinit-update-or-status-all "$1" restart + return $? + } - .zinit-first "$1" "$2" || { - builtin print "${ZINIT[col-error]}No source file found, cannot stress${ZINIT[col-rst]}" - return 1 + integer retval + + if (( OPTS[opt_-p,--parallel] )) && [[ $1 = update ]] { + (( !OPTS[opt_-q,--quiet] )) && \ + +zinit-message '{info2}Parallel Update Starts Now{…}{rst}' + .zinit-update-all-parallel + retval=$? + .zinit-compinit 1 1 &>/dev/null + rehash + if (( !OPTS[opt_-q,--quiet] )) { + +zinit-message "{msg2}The update took {obj}${SECONDS}{msg2} seconds{rst}" + } + return $retval } - local pdir_path="${reply[-2]}" fname="${reply[-1]}" + local st=$1 id_as repo snip pd user plugin + integer PUPDATE=0 - integer compiled=1 - [[ -e "${fname}.zwc" ]] && command rm -f "${fname}.zwc" || compiled=0 + local -A ICE - local -a ZINIT_STRESS_TEST_OPTIONS - ZINIT_STRESS_TEST_OPTIONS=( - "NO_SHORT_LOOPS" "IGNORE_BRACES" "IGNORE_CLOSE_BRACES" - "SH_GLOB" "CSH_JUNKIE_QUOTES" "NO_MULTI_FUNC_DEF" - ) - ( - builtin emulate -LR ksh ${=${options[xtrace]:#off}:+-o xtrace} - builtin unsetopt shglob kshglob - for i in "${ZINIT_STRESS_TEST_OPTIONS[@]}"; do - builtin setopt "$i" - builtin print -n "Stress-testing ${fname:t} for option $i " - zcompile -UR "$fname" 2>/dev/null && { - builtin print "[${ZINIT[col-success]}Success${ZINIT[col-rst]}]" - } || { - builtin print "[${ZINIT[col-failure]}Fail${ZINIT[col-rst]}]" - } - builtin unsetopt "$i" - done - ) + if (( OPTS[opt_-s,--snippets] || !OPTS[opt_-l,--plugins] )) { + local -a snipps + snipps=( ${ZINIT[SNIPPETS_DIR]}/**/(._zinit|._zplugin)(ND) ) - command rm -f "${fname}.zwc" - (( compiled )) && zcompile -U "$fname" -} # ]]] -# FUNCTION: .zinit-list-compdef-replay [[[ -# Shows recorded compdefs (called by plugins loaded earlier). -# Plugins often call `compdef' hoping for `compinit' being -# already ran. Zinit solves this by recording compdefs. -# -# User-action entry point. -.zinit-list-compdef-replay() { - builtin print "Recorded compdefs:" - local cdf - for cdf in "${ZINIT_COMPDEF_REPLAY[@]}"; do - builtin print "compdef ${(Q)cdf}" - done -} # ]]] -# FUNCTION: .zinit-ls [[[ -.zinit-ls() { - (( ${+commands[tree]} )) || { - builtin print "${ZINIT[col-error]}No \`tree' program, it is required by the subcommand \`ls\'${ZINIT[col-rst]}" - builtin print "Download from: http://mama.indstate.edu/users/ice/tree/" - builtin print "It is also available probably in all distributions and Homebrew, as package \`tree'" + [[ $st != status && ${OPTS[opt_-q,--quiet]} != 1 && -n $snipps ]] && \ + +zinit-message "{info}Note:{rst} updating also unloaded snippets" + + for snip ( ${ZINIT[SNIPPETS_DIR]}/**/(._zinit|._zplugin)/mode(D) ) { + [[ ! -f ${snip:h}/url ]] && continue + [[ -f ${snip:h}/id-as ]] && \ + id_as="$(<${snip:h}/id-as)" || \ + id_as= + .zinit-update-or-status-snippet "$st" "${id_as:-$(<${snip:h}/url)}" + ICE=() + } + [[ -n $snipps ]] && builtin print } - ( - setopt localoptions extendedglob nokshglob noksharrays - builtin cd -q "${ZINIT[SNIPPETS_DIR]}" - local -a list - local -x LANG=en_US.utf-8 - list=( "${(f@)"$(${=ZINIT[LIST_COMMAND]})"}" ) - # Oh-My-Zsh single file - list=( "${list[@]//(#b)(https--github.com--(ohmyzsh|robbyrussel)l--oh-my-zsh--raw--master(--)(#c0,1)(*))/$ZINIT[col-info]Oh-My-Zsh$ZINIT[col-error]${match[2]/--//}$ZINIT[col-pname]${match[3]//--/$ZINIT[col-error]/$ZINIT[col-pname]} $ZINIT[col-info](single-file)$ZINIT[col-rst] ${match[1]}}" ) - # Oh-My-Zsh SVN - list=( "${list[@]//(#b)(https--github.com--(ohmyzsh|robbyrussel)l--oh-my-zsh--trunk(--)(#c0,1)(*))/$ZINIT[col-info]Oh-My-Zsh$ZINIT[col-error]${match[2]/--//}$ZINIT[col-pname]${match[3]//--/$ZINIT[col-error]/$ZINIT[col-pname]} $ZINIT[col-info](SVN)$ZINIT[col-rst] ${match[1]}}" ) - # Prezto single file - list=( "${list[@]//(#b)(https--github.com--sorin-ionescu--prezto--raw--master(--)(#c0,1)(*))/$ZINIT[col-info]Prezto$ZINIT[col-error]${match[2]/--//}$ZINIT[col-pname]${match[3]//--/$ZINIT[col-error]/$ZINIT[col-pname]} $ZINIT[col-info](single-file)$ZINIT[col-rst] ${match[1]}}" ) - # Prezto SVN - list=( "${list[@]//(#b)(https--github.com--sorin-ionescu--prezto--trunk(--)(#c0,1)(*))/$ZINIT[col-info]Prezto$ZINIT[col-error]${match[2]/--//}$ZINIT[col-pname]${match[3]//--/$ZINIT[col-error]/$ZINIT[col-pname]} $ZINIT[col-info](SVN)$ZINIT[col-rst] ${match[1]}}" ) - # First-level names - list=( "${list[@]//(#b)(#s)(│   └──| └──| ├──|│   ├──) (*)/${match[1]} $ZINIT[col-p]${match[2]}$ZINIT[col-rst]}" ) + ICE=() - list[-1]+=", located at ZINIT[SNIPPETS_DIR], i.e. ${ZINIT[SNIPPETS_DIR]}" - builtin print -rl -- "${list[@]}" - ) -} # ]]] -# FUNCTION: .zinit-get-path [[[ -# Returns path of given ID-string, which may be a plugin-spec -# (like "user/plugin" or "user" "plugin"), an absolute path -# ("%" "/home/..." and also "%SNIPPETS/..." etc.), or a plugin -# nickname (i.e. id-as'' ice-mod), or a snippet nickname. -.zinit-get-path() { - builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - setopt extendedglob warncreateglobal typesetsilent noshortloops + if (( OPTS[opt_-s,--snippets] && !OPTS[opt_-l,--plugins] )) { + return + } - [[ $1 == % ]] && local id_as=%$2 || local id_as=$1${1:+/}$2 - .zinit-get-object-path snippet "$id_as" || \ - .zinit-get-object-path plugin "$id_as" + if [[ $st = status ]]; then + (( !OPTS[opt_-q,--quiet] )) && \ + +zinit-message "{info}Note:{rst} status done also for unloaded plugins" + else + (( !OPTS[opt_-q,--quiet] )) && \ + +zinit-message "{info}Note:{rst} updating also unloaded plugins" + fi - return $(( 1 - reply[3] )) -} # ]]] -# FUNCTION: .zinit-recall [[[ -.zinit-recall() { - builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - setopt extendedglob warncreateglobal typesetsilent noshortloops + ZINIT[first-plugin-mark]=init - local -A ice - local el val cand1 cand2 local_dir filename is_snippet + for repo in ${ZINIT[PLUGINS_DIR]}/*; do + pd=${repo:t} - local -a ice_order nval_ices output - ice_order=( - ${(s.|.)ZINIT[ice-list]} + # Two special cases + [[ $pd = custom || $pd = _local---zinit ]] && continue - # Include all additional ices – after - # stripping them from the possible: '' - ${(@)${(@Akons:|:u)${ZINIT_EXTS[ice-mods]//\'\'/}}/(#s)<->-/} - ) - nval_ices=( - ${(s.|.)ZINIT[nval-ice-list]} - # Include only those additional ices, - # don't have the '' in their name, i.e. - # aren't designed to hold value - ${(@)${(@)${(@Akons:|:u)ZINIT_EXTS[ice-mods]}:#*\'\'*}/(#s)<->-/} + .zinit-any-colorify-as-uspl2 "$pd" + + # Check if repository has a remote set + if [[ -f $repo/.git/config ]]; then + local -a config + config=( ${(f)"$(<$repo/.git/config)"} ) + if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]]; then + if (( !OPTS[opt_-q,--quiet] )) { + [[ $pd = _local---* ]] && \ + builtin print -- "\nSkipping local plugin $REPLY" || \ + builtin print "\n$REPLY doesn't have a remote set, will not fetch" + } + continue + fi + fi - # Must be last - svn - ) - .zinit-compute-ice "$1${${1:#(%|/)*}:+${2:+/}}$2" "pack" \ - ice local_dir filename is_snippet || return 1 + .zinit-any-to-user-plugin "$pd" + local user=${reply[-2]} plugin=${reply[-1]} - [[ -e $local_dir ]] && { - for el ( ${ice_order[@]} ) { - val="${ice[$el]}" - cand1="${(qqq)val}" - cand2="${(qq)val}" - if [[ -n "$val" ]] { - [[ "${cand1/\\\$/}" != "$cand1" || "${cand1/\\\!/}" != "$cand1" ]] && output+=( "$el$cand2" ) || output+=( "$el$cand1" ) - } elif [[ ${+ice[$el]} = 1 && -n "${nval_ices[(r)$el]}" ]] { - output+=( "$el" ) - } - } + # Must be a git repository or a binary release + if [[ ! -d $repo/.git && ! -f $repo/._zinit/is_release ]]; then + (( !OPTS[opt_-q,--quiet] )) && \ + builtin print "$REPLY: not a git repository" + continue + fi - if [[ ${#output} = 0 ]]; then - builtin print -zr "# No Ice modifiers" + if [[ $st = status ]]; then + builtin print "\nStatus for plugin $REPLY" + ( builtin cd -q "$repo"; command git status ) else - builtin print -zr "zinit ice ${output[*]}; zinit " + (( !OPTS[opt_-q,--quiet] )) && builtin print "Updating $REPLY" || builtin print -n . + .zinit-update-or-status update "$user" "$plugin" + update_rc=$? + [[ $update_rc -ne 0 ]] && { + +zinit-message "🚧{warn}Warning: {pid}${user}/${plugin} {warn}update returned {obj}$update_rc" + retval=$? + } fi - +zinit-deploy-message @rst - } || builtin print -r -- "No such plugin or snippet" + done + + .zinit-compinit 1 1 &>/dev/null + if (( !OPTS[opt_-q,--quiet] )) { + +zinit-message "{msg2}The update took {obj}${SECONDS}{msg2} seconds{rst}" + } + + return "$retval" } # ]]] -# FUNCTION: .zinit-module [[[ -# Function that has sub-commands passed as long-options (with two dashes, --). -# It's an attempt to plugin only this one function into `zinit' function -# defined in zinit.zsh, to not make this file longer than it's needed. -.zinit-module() { - if [[ "$1" = "build" ]]; then - .zinit-build-module "${@[2,-1]}" - elif [[ "$1" = "info" ]]; then - if [[ "$2" = "--link" ]]; then - builtin print -r "You can copy the error messages and submit" - builtin print -r "error-report at: https://github.com/zdharma-continuum/zinit-module/issues" +# FUNCTION: .zinit-update-or-status-snippet [[[ +# +# Implements update or status operation for snippet given by URL. +# +# $1 - "status" or "update" +# $2 - snippet URL +.zinit-update-or-status-snippet() { + local st="$1" URL="${2%/}" local_dir filename is_snippet + (( ${#ICE[@]} > 0 )) && { ZINIT_SICE[$URL]=""; local nf="-nftid"; } + local -A ICE2 + .zinit-compute-ice "$URL" "pack$nf" \ + ICE2 local_dir filename is_snippet || return 1 + + integer retval + + if [[ "$st" = "status" ]]; then + if (( ${+ICE2[svn]} )); then + builtin print -r -- "${ZINIT[col-info]}Status for ${${${local_dir:h}:t}##*--}/${local_dir:t}${ZINIT[col-rst]}" + ( builtin cd -q "$local_dir"; command svn status -vu ) + retval=$? + builtin print else - builtin print -r "To load the module, add following 2 lines to .zshrc, at top:" - builtin print -r " module_path+=( \"${ZINIT[MODULE_DIR]}/Src\" )" - builtin print -r " zmodload zdharma_continuum/zinit" - builtin print -r "" - builtin print -r "After loading, use command \`zpmod' to communicate with the module." - builtin print -r "See \`zpmod -h' for more information." + builtin print -r -- "${ZINIT[col-info]}Status for ${${local_dir:h}##*--}/$filename${ZINIT[col-rst]}" + ( builtin cd -q "$local_dir"; command ls -lth $filename ) + retval=$? + builtin print fi - elif [[ "$1" = (help|usage) ]]; then - builtin print -r "Usage: zinit module {build|info|help} [options]" - builtin print -r " zinit module build [--clean]" - builtin print -r " zinit module info [--link]" - builtin print -r "" - builtin print -r "To start using the zinit Zsh module run: \`zinit module build'" - builtin print -r "and follow the instructions. Option --clean causes \`make distclean'" - builtin print -r "to be run. To display the instructions on loading the module, run:" - builtin print -r "\`zinit module info'." + else + (( ${+functions[.zinit-setup-plugin-dir]} )) || builtin source ${ZINIT[BIN_DIR]}"/zinit-install.zsh" + ICE=( "${(kv)ICE2[@]}" ) + .zinit-update-snippet "${ICE2[teleid]:-$URL}" + retval=$? fi + + ICE=() + + if (( PUPDATE && ZINIT[annex-multi-flag:pull-active] > 0 )) { + builtin print ${ZINIT[annex-multi-flag:pull-active]} >! $PUFILE.ind + } + + return $retval } # ]]] -# FUNCTION: .zinit-build-module [[[ -# Performs ./configure && make on the module and displays information -# how to load the module in .zshrc. -.zinit-build-module() { - setopt localoptions localtraps - trap 'return 1' INT TERM - if command git -C "${ZINIT[MODULE_DIR]}" rev-parse 2>/dev/null; then - command git -C "${ZINIT[MODULE_DIR]}" clean -d -f -f - command git -C "${ZINIT[MODULE_DIR]}" reset --hard HEAD - command git -C "${ZINIT[MODULE_DIR]}" pull - else - command git clone "https://github.com/zdharma-continuum/zinit-module.git" "${ZINIT[MODULE_DIR]}" || { - builtin print "${ZINIT[col-error]}Failed to clone module repo${ZINIT[col-rst]}" - return 1 +# FUNCTION: .zinit-wait-for-update-jobs [[[ +.zinit-wait-for-update-jobs() { + local tpe=$1 + if (( counter > OPTS[value] || main_counter == 0 )) { + wait ${(k)PUAssocArray} + local ind_file + for ind_file ( ${^${(von)PUAssocArray}}.ind(DN.) ) { + command cat ${ind_file:r} + (( !OPTS[opt_-d,--debug] && !ZINIT[DEBUG_MODE] )) && \ + command rm -f $ind_file } - fi - ( builtin cd -q "${ZINIT[MODULE_DIR]}" - +zinit-message "{pname}== Building module zdharma-continuum/zinit-module, running: make clean, then ./configure and then make =={rst}" - +zinit-message "{pname}== The module sources are located at: "${ZINIT[MODULE_DIR]}" =={rst}" - if [[ -f Makefile ]] { - if [[ "$1" = "--clean" ]] { - noglob +zinit-message {p}-- make distclean --{rst} - make distclean - ((1)) - } else { - noglob +zinit-message {p}-- make clean --{rst} - make clean - } - } - noglob +zinit-message {p}-- ./configure --{rst} - CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O3" LDFLAGS=-L/usr/local/lib ./configure --disable-gdbm --without-tcsetpgrp && { - noglob +zinit-message {p}-- make --{rst} - if { make } { - [[ -f Src/zdharma_continuum/zinit.so ]] && cp -vf Src/zdharma_continuum/zinit.{so,bundle} - noglob +zinit-message "{info}Module has been built correctly.{rst}" - .zinit-module info - } else { - noglob +zinit-message "{error}Module didn't build.{rst} " - .zinit-module info --link - } - } - builtin print $EPOCHSECONDS >! "${ZINIT[MAN_DIR]}/COMPILED_AT" - ) + (( !OPTS[opt_-d,--debug] && !ZINIT[DEBUG_MODE] )) && \ + command rm -f ${(v)PUAssocArray} + counter=0 + PUAssocArray=() + } elif (( counter == 1 && !OPTS[opt_-q,--quiet] )) { + +zinit-message "{obj}Spawning the next{num}" \ + "${OPTS[value]}{obj} concurrent update jobs" \ + "({msg2}${tpe}{obj}){…}{rst}" + } } # ]]] - # FUNCTION: zi::version [[[ # Shows usage information. # @@ -3369,84 +3442,4 @@ zi::version() { return $? } # ]]] -# FUNCTION: .zinit-help [[[ -# Shows usage information. -# -# User-action entry point. -.zinit-help() { - builtin print -r -- "${ZINIT[col-p]}Usage${ZINIT[col-rst]}: -—— -h|--help|help – usage information -—— man – manual -—— version – display zinit version -—— self-update – updates and compiles Zinit -—— zstatus – overall Zinit statu—— 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 -—— load ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – load plugin, can also receive absolute local path -—— light [-b] ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – light plugin load, without reporting/tracking (-b – do track but bindkey-calls only) -—— unload ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – unload plugin loaded with \`zinit load ...', -q – quiet -—— snippet [-f] ${ZINIT[col-pname]}{url}${ZINIT[col-rst]} – source local or remote file (by direct URL), -f: force – don't use cache -—— ls – list snippets in formatted and colorized manner -—— ice – add ICE to next command, argument is e.g. from\"gitlab\" -—— 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 -—— 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) -—— report ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – show plugin's report (or all plugins' if ——all passed) -—— delete [--all|--clean] ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]}|URL – remove plugin or snippet from disk (good to forget wrongly passed ice-mods); --all – purge, --clean – delete plugins and snippets that are not loaded -—— loaded|list {keyword} – show what plugins are loaded (filter with \'keyword') -—— cd ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – cd into plugin's directory; also support snippets, if feed with URL -—— create ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – create plugin (also together with Github repository) -—— edit ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – edit plugin's file with \$EDITOR -—— glance ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – look at plugin's source (pygmentize, {,source-}highlight) -—— stress ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – test plugin for compatibility with set of options -—— changes ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – view plugin's git log -—— recently ${ZINIT[col-info]}[time-spec]${ZINIT[col-rst]} – show plugins that changed recently, argument is e.g. 1 month 2 days -—— clist|completions – list completions in use -—— cdisable ${ZINIT[col-info]}cname${ZINIT[col-rst]} – disable completion \`cname' -—— cenable ${ZINIT[col-info]}cname${ZINIT[col-rst]} – enable completion \`cname' -—— creinstall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – install completions for plugin, can also receive absolute local path; -q – quiet -—— cuninstall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – uninstall completions for plugin -—— csearch – search for available completions from any plugin -—— compinit – refresh installed completions -—— dtrace|dstart – start tracking what's going on in session -—— dstop – stop tracking what's going on in session -—— dunload – revert changes recorded between dstart and dstop -—— dreport – report what was going on in session -—— dclear – clear report of what was going on in session -—— compile ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – compile plugin (or all plugins if ——all passed) -—— uncompile ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – remove compiled version of plugin (or of all plugins if ——all passed) -—— compiled – list plugins that are compiled -—— cdlist – show compdef replay list -—— cdreplay [-q] – replay compdefs (to be done after compinit), -q – quiet -—— cdclear [-q] – clear compdef replay list, -q – quiet -—— srv {service-id} [cmd] – control a service, command can be: stop,start,restart,next,quit; \`next' moves the service to another Zshell -—— recall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]}|URL – fetch saved ice modifiers and construct \`zinit ice ...' command -—— env-whitelist [-v|-h] {env..} – allows to specify names (also patterns) of variables left unchanged during an unload. -v – verbose -—— bindkeys – lists bindkeys set up by each plugin -—— module – manage binary Zsh module shipped with Zinit, see \`zinit module help' -—— 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" - - integer idx - local type key - local -a arr - for type in subcommand hook; do - for (( idx=1; idx <= ZINIT_EXTS[seqno]; ++ idx )); do - key="${(k)ZINIT_EXTS[(r)$idx *]}" - [[ -z "$key" || "$key" != "z-annex $type:"* ]] && continue - arr=( "${(Q)${(z@)ZINIT_EXTS[$key]}[@]}" ) - (( ${+functions[${arr[6]}]} )) && { "${arr[6]}"; ((1)); } || \ - { builtin print -rl -- "(Couldn't find the help-handler \`${arr[6]}' of the z-annex \`${arr[3]}')"; } - 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[*]}" -} # ]]] - -# Local Variables: -# mode: Shell-Script -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: -# vim: ft=zsh sw=2 ts=2 et foldmarker=[[[,]]] foldmethod=marker +# vim: set fenc=utf8 ffs=unix foldmarker=[[[,]]] foldmethod=marker ft=zsh list et sts=2 sw=2 ts=2 tw=100: diff --git a/zinit-install.zsh b/zinit-install.zsh index c839483fa..42f628b23 100644 --- a/zinit-install.zsh +++ b/zinit-install.zsh @@ -357,8 +357,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { if [[ $site = */releases ]] { local tag_version=${ICE[ver]} if [[ -z $tag_version ]]; then - tag_version="$( { .zinit-download-file-stdout $site/latest || .zinit-download-file-stdout $site/latest 1; } 2>/dev/null | \ - command grep -m1 -o 'href=./'$user'/'$plugin'/releases/tag/[^"]\+')" + tag_version="$({.zinit-download-file-stdout $site/latest || .zinit-download-file-stdout $site/latest 1;} 2>/dev/null | command grep -i -m 1 -o 'href=./'$user'/'$plugin'/releases/tag/[^"]\+')" tag_version=${tag_version##*/} fi local url=$site/expanded_assets/$tag_version @@ -394,7 +393,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { command rm -f "${REPLY:t}.sig" fi - command mkdir -p ._zinit + command mkdir -p ._zinit && echo '*' > ._zinit/.gitignore [[ -d ._zinit ]] || return 2 builtin print -r -- $url >! ._zinit/url || return 3 builtin print -r -- ${REPLY} >! ._zinit/is_release${count:#1} || return 4 @@ -405,7 +404,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { return 1 } } elif [[ $site = cygwin ]] { - command mkdir -p "$local_path/._zinit" + command mkdir -p "$local_path/._zinit" && echo '*' > "$local_path/._zinit/.gitignore" [[ -d "$local_path" ]] || return 1 ( @@ -563,7 +562,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { # Symlink completions if they are not already there # either as completions (_fname) or as backups (fname) # OR - if its a reinstall - for c in "${completions[@]}"; do + for c in "${completions[@]:A}"; do cfile="${c:t}" bkpfile="${cfile#_}" if [[ ( -z ${already_symlinked[(r)*/$cfile]} || $reinstall = 1 ) && @@ -1548,7 +1547,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || { else local url=https://$urlpart fi - init_list=( ${(@f)"$( { .zinit-download-file-stdout $url || .zinit-download-file-stdout $url 1; } 2>/dev/null | command grep -o 'href=./'$user'/'$plugin'/releases/download/[^"]\+')"} ) + init_list=( ${(@f)"$( { .zinit-download-file-stdout $url || .zinit-download-file-stdout $url 1; } 2>/dev/null | command grep -i -o 'href=./'$user'/'$plugin'/releases/download/[^"]\+')"} ) init_list=(${init_list[@]#href=?}) bpicks=(${(s.;.)ICE[bpick]}) [[ -z $bpicks ]] && bpicks=("") diff --git a/zinit-side.zsh b/zinit-side.zsh index 7d47c189b..8c542a8d0 100644 --- a/zinit-side.zsh +++ b/zinit-side.zsh @@ -330,7 +330,7 @@ svn ) - command mkdir -p "$___pfx" + command mkdir -p "$___pfx" && echo '*' > "$___pfx/.gitignore" local ___key ___var_name # No nval_ices here for ___key in ${ice_order[@]:#(${(~j:|:)nval_ices[@]})} ${(s: :)___add_ices[@]}; do diff --git a/zinit.zsh b/zinit.zsh index 4f43a6dec..307f57709 100644 --- a/zinit.zsh +++ b/zinit.zsh @@ -1,4 +1,10 @@ -# Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors. +# +# zdharma-continuum/zinit/zinit.zsh +# Copyright (c) 2016-2021 Sebastian Gniazdowski +# Copyright (c) 2021-2023 zdharma-continuum +# Homepage: https://github.com/zdharma-continuum/zinit +# License: MIT License +# # # Main state variables. @@ -115,10 +121,11 @@ fpath|\ glance|\ help|\ ice|\ -light|list|load|loaded|ls|\ +light|load|\ man|module|\ +plugins|\ recall|recently|report|run|\ -self-update|snippet|srv|status|stress|\ +self-update|snippet|snippets|srv|status|stress|\ times|\ uncompile|unload|update|\ version|\ @@ -186,54 +193,45 @@ ZINIT_2MAP=( # Init [[[ zmodload zsh/zutil || { builtin print -P "%F{196}zsh/zutil module is required, aborting Zinit set up.%f"; return 1; } zmodload zsh/parameter || { builtin print -P "%F{196}zsh/parameter module is required, aborting Zinit set up.%f"; return 1; } -zmodload zsh/terminfo 2>/dev/null -zmodload zsh/termcap 2>/dev/null - -if [[ -z $SOURCED && ( ${+terminfo} -eq 1 && -n ${terminfo[colors]} ) || \ - ( ${+termcap} -eq 1 && -n ${termcap[Co]} ) -]] { - ZINIT+=( - # Old colors: 31m - col-pname $'\e[1;4m\e[32m' col-uname $'\e[1;4m\e[35m' col-keyword $'\e[32m' - col-note $'\e[38;5;148m' col-error $'\e[1m\e[38;5;204m' col-p $'\e[38;5;81m' - col-info $'\e[38;5;82m' col-info2 $'\e[38;5;227m' col-profile $'\e[38;5;148m' - col-uninst $'\e[38;5;118m' col-info3 $'\e[1m\e[38;5;227m' col-slight $'\e[38;5;230m' - col-failure $'\e[38;5;204m' col-happy $'\e[1m\e[38;5;82m' col-annex $'\e[38;5;153m' - col-id-as $'\e[4;38;5;220m' col-version $'\e[3;38;5;87m' - # The more recent, fresh ones: - col-pre $'\e[38;5;135m' col-msg $'\e[0m' col-msg2 $'\e[38;5;172m' - col-obj $'\e[38;5;218m' col-obj2 $'\e[38;5;118m' col-file $'\e[3;38;5;117m' - col-dir $'\e[3;38;5;153m' col-func $'\e[38;5;219m' - col-url $'\e[38;5;75m' col-meta $'\e[38;5;57m' col-meta2 $'\e[38;5;147m' - col-data $'\e[38;5;82m' col-data2 $'\e[38;5;117m' col-hi $'\e[1m\e[38;5;183m' - col-var $'\e[38;5;81m' col-glob $'\e[38;5;227m' col-ehi $'\e[1m\e[38;5;210m' - col-cmd $'\e[38;5;82m' col-ice $'\e[38;5;39m' col-nl $'\n' - col-txt $'\e[38;5;254m' col-num $'\e[3;38;5;155m' col-term $'\e[38;5;185m' - col-warn $'\e[38;5;214m' col-ok $'\e[38;5;220m' col-time $'\e[38;5;220m' - col-apo $'\e[1;38;5;45m' col-aps $'\e[38;5;117m' - col-quo $'\e[1;38;5;33m' col-quos $'\e[1;38;5;160m' - col-bapo $'\e[1;38;5;220m' col-baps $'\e[1;38;5;82m' - col-faint $'\e[38;5;238m' col-opt $'\e[38;5;219m' col-lhi $'\e[38;5;81m' - col-flag $'\e[1;3;38;5;79m' col-pkg $'\e[1;3;38;5;27m' - col-tab $' \t ' col-msg3 $'\e[38;5;238m' col-b-lhi $'\e[1m\e[38;5;75m' - col-bar $'\e[38;5;82m' col-th-bar $'\e[38;5;82m' - col-… "${${${(M)LANG:#*UTF-8*}:+…}:-...}" col-ndsh "${${${(M)LANG:#*UTF-8*}:+–}:-}" - col-mdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+–}:--}"$'\e[0m' - col-mmdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+――}:--}"$'\e[0m' - col--… "${${${(M)LANG:#*UTF-8*}:+⋯⋯}:-···}" col-lr "${${${(M)LANG:#*UTF-8*}:+↔}:-"«-»"}" - col-↔ ${${${(M)LANG:#*UTF-8*}:+$'\e[38;5;82m↔\e[0m'}:-$'\e[38;5;82m«-»\e[0m'} - col-rst $'\e[0m' col-b $'\e[1m' col-nb $'\e[22m' - col-u $'\e[4m' col-it $'\e[3m' col-st $'\e[9m' - col-nu $'\e[24m' col-nit $'\e[23m' col-nst $'\e[29m' - col-bspc $'\b' col-b-warn $'\e[1;38;5;214m' col-u-warn $'\e[4;38;5;214m' - col-bcmd $'\e[38;5;220m' - ) - if [[ ( ${+terminfo} -eq 1 && ${terminfo[colors]} -ge 256 ) || \ - ( ${+termcap} -eq 1 && ${termcap[Co]} -ge 256 ) - ]] { - ZINIT+=( col-pname $'\e[1;4m\e[38;5;39m' col-uname $'\e[1;4m\e[38;5;207m' ) - } -} +zmodload zsh/term{cap,info} 2>/dev/null +autoload -Uz colors && colors + +if [[ -z $SOURCED && ( ${+terminfo} -eq 1 && -n ${terminfo[colors]} ) || ( ${+termcap} -eq 1 && -n ${termcap[Co]} ) ]]; then + ZINIT+=( + col-annex $'\e[38;5;153m' col-faint $'\e[38;5;238m' col-msg2 $'\e[38;5;172m' col-quo $'\e[1;38;5;33m' + col-apo $'\e[1;38;5;45m' col-file $'\e[3;38;5;117m' col-msg3 $'\e[38;5;238m' col-quos $'\e[1;38;5;160m' + col-aps $'\e[38;5;117m' col-flag $'\e[1;3;38;5;79m' col-nb $'\e[22m' col-rst $'\e[0m' + col-b $'\e[1m' col-func $'\e[38;5;219m' col-nit $'\e[23m' col-slight $'\e[38;5;230m' + col-b-lhi $'\e[1m\e[38;5;75m' col-glob $'\e[38;5;227m' col-nl $'\n' col-st $'\e[9m' + col-b-warn $'\e[1;38;5;214m' col-happy $'\e[1m\e[38;5;82m' col-note $'\e[38;5;148m' col-tab $' \t ' + col-bapo $'\e[1;38;5;220m' col-hi $'\e[1m\e[38;5;183m' col-nst $'\e[29m' col-term $'\e[38;5;185m' + col-baps $'\e[1;38;5;82m' col-ice $'\e[38;5;39m' col-nu $'\e[24m' col-th-bar $'\e[38;5;82m' + col-bar $'\e[38;5;82m' col-id-as $'\e[4;38;5;220m' col-num $'\e[3;38;5;155m' col-time $'\e[38;5;220m' + col-bcmd $'\e[38;5;220m' col-info $'\e[38;5;82m' col-obj $'\e[38;5;218m' col-txt $'\e[38;5;254m' + col-bspc $'\b' col-info2 $'\e[38;5;227m' col-obj2 $'\e[38;5;118m' col-u $'\e[4m' + col-cmd $'\e[38;5;82m' col-info3 $'\e[1m\e[38;5;227m' col-ok $'\e[38;5;220m' col-u-warn $'\e[4;38;5;214m' + col-data $'\e[38;5;82m' col-it $'\e[3m' col-opt $'\e[38;5;219m' col-uname $'\e[1;4m\e[35m' + col-data2 $'\e[38;5;117m' col-keyword $'\e[32m' col-p $'\e[38;5;81m' col-uninst $'\e[38;5;118m' + col-dir $'\e[3;38;5;153m' col-lhi $'\e[38;5;81m' col-pkg $'\e[1;3;38;5;27m' col-url $'\e[38;5;75m' + col-ehi $'\e[1m\e[38;5;210m' col-meta $'\e[38;5;57m' col-pname $'\e[1;4m\e[32m' col-var $'\e[38;5;81m' + col-error $'\e[1m\e[38;5;204m' col-meta2 $'\e[38;5;147m' col-pre $'\e[38;5;135m' col-version $'\e[3;38;5;87m' + col-failure $'\e[38;5;204m' col-msg $'\e[0m' col-profile $'\e[38;5;148m' col-warn $'\e[38;5;214m' + + col-i $'\e[0;32m'"==>"$'\e[0m' col-e $'\e[1;91m'"Error: "$'\e[0m' + col-m $'\e[0;35m'"==>"$'\e[0m' col-w $'\e[0;33m'"Warning: "$'\e[0m' + + col--… "${${${(M)LANG:#*UTF-8*}:+⋯⋯}:-···}" col-lr "${${${(M)LANG:#*UTF-8*}:+↔}:-"«-»"}" + col-ndsh "${${${(M)LANG:#*UTF-8*}:+–}:-}" col-… "${${${(M)LANG:#*UTF-8*}:+…}:-...}" + + col-mdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+–}:--}"$'\e[0m' + col-mmdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+――}:--}"$'\e[0m' + + col-↔ ${${${(M)LANG:#*UTF-8*}:+$'\e[38;5;82m↔\e[0m'}:-$'\e[38;5;82m«-»\e[0m'} + ) + if [[ ( ${+terminfo} -eq 1 && ${terminfo[colors]} -ge 256 ) || ( ${+termcap} -eq 1 && ${termcap[Co]} -ge 256 ) ]]; then + ZINIT+=( col-pname $'\e[1;4m\e[38;5;39m' col-uname $'\e[1;4m\e[38;5;207m' ) + fi +fi # Hooks typeset -gAH ZINIT_ZLE_HOOKS_LIST @@ -395,11 +393,11 @@ builtin setopt noaliases retval=$? } } else { - eval "function ${(q)func} { + functions[$func]=" local -a fpath fpath=( ${(qqq)PLUGIN_DIR} ${(qqq@)fpath_elements} ${(qqq@)fpath} ) builtin autoload -X ${(j: :)${(q-)opts[@]}} - }" + " retval=$? } else @@ -1204,8 +1202,7 @@ builtin setopt noaliases ___value=${___value//(#m)(%[a-zA-Z0-9]##%|\$ZPFX|\$\{ZPFX\})/${___subst_map[$MATCH]}} : ${(P)___var_name::=$___value} done -} -# ]]] +} # ]]] # FUNCTION: @zinit-register-annex [[[ # Registers the z-annex inside Zinit – i.e. an Zinit extension @zinit-register-annex() { @@ -2603,7 +2600,7 @@ zinit() { cmd="$1" if [[ $cmd == (times|unload|env-whitelist|update|snippet|load|light|cdreplay|\ -cdclear|delete) ]]; then +cdclear) ]]; then if (( $@[(I)-*] || OPTS[opt_-h,--help] )); then .zinit-parse-opts "$cmd" "$@" if (( OPTS[opt_-h,--help] )); then @@ -2924,6 +2921,10 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice (zstatus) .zinit-show-zstatus ;; + (delete) + shift + .zinit-delete "$@" + ;; (times) .zinit-show-times "${@[2-correct,-1]}" ;; @@ -2951,7 +2952,6 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice for REPLY ( ${(s.;.)ICE[has]} ) { (( ${+commands[$REPLY]} )) || return 1 } - shift .zinit-parse-opts update "$@" builtin set -- "${reply[@]}" @@ -2976,22 +2976,21 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice (report) if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 4; } - .zinit-show-all-reports + .zinit-show-all-reports else .zinit-show-report "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$? fi ;; - (loaded|list) - # Show list of loaded plugins. - .zinit-show-registered-plugins "$2" + (plugins) + .zinit-list-plugins "$2" + ;; + (snippets) + .zinit-list-snippets "$2" ;; - (clist|completions) - # Show installed, enabled or disabled, completions. - # Detect stray and improper ones. + (completions) # Show installed, enabled or disabled, completions and detect stray and improper ones .zinit-show-completions "$2" ;; - (cclear) - # Delete stray and improper completions. + (cclear) # Delete stray and improper completions. .zinit-clear-completions ;; (cdisable) @@ -3032,8 +3031,7 @@ 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's a - # reinstallation, thus every obstacle gets overwritten or removed. + # 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=$? [[ -z ${(M)4:#-[qQ]} ]] && +zinit-message "Initializing completion ({func}compinit{rst}){…}" @@ -3093,7 +3091,7 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice (cdlist) .zinit-list-compdef-replay ;; - (cd|delete|recall|edit|glance|changes|create|stress) + (cd|recall|edit|glance|changes|create|stress) .zinit-"$1" "${@[2-correct,-1]%%(///|//|/)}"; ___retval=$? ;; (recently) @@ -3106,10 +3104,6 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice (version) zi::version ;; - (ls) - shift - .zinit-ls "$@" - ;; (srv) () { setopt localoptions extendedglob warncreateglobal [[ ! -e ${ZINIT[SERVICES_DIR]}/"$2".fifo ]] && { builtin print "No such service: $2"; } || @@ -3125,16 +3119,16 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice .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 - } - ___retval=1 - ;; + 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 + } + ___retval=1 + ;; esac ;; esac @@ -3224,7 +3218,9 @@ zmodload zsh/zpty zsh/system 2>/dev/null zmodload -F zsh/stat b:zstat 2>/dev/null && ZINIT[HAVE_ZSTAT]=1 # code [[[ -builtin alias zpl=zinit zplg=zinit zi=zinit zini=zinit +if [[ -z $ZINIT[NO_ALIASES] ]]; then + builtin alias zpl=zinit zplg=zinit zi=zinit zini=zinit +fi .zinit-prepare-home