zdharma-continuum.zinit/_zinit
Vladislav Doster 9eee215e3f
feat: delete subcommand refactor
- `delete` subcommand can now take multiple arguments
- improved logic for `--all`, `--clean` flags
- improved log output
- now cleans up broken symlinks

```
zinit delete <Plugin> <Plugin> ...
```

Closes #57
Closes #239

Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
2023-04-02 04:38:38 -05:00

378 lines
12 KiB
Plaintext

#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
#
# 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 completions in use'
'compile:Compile plugin (or all plugins if --all passed)'
'compiled:List of compiled plugins'
'compinit:Refresh installed completions'
'completions:List completions in use'
'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'
'list:Show what plugins are loaded'
'load:Load plugin'
'loaded:Show what plugins are loaded'
'ls:List snippets in formatted and colorized manner'
'man:Display Zinit'\''s manpage'
'module:Manage binary Zsh module shipped with Zinit'
'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'
'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}"
} # ]]]
# 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
} # ]]]
# 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
} # ]]]
_zinit "$@"
#vim: filetype=zsh foldmarker=[[[,]]] foldmethod=marker shiftwidth=2 softtabstop=2 tabstop=2: