1
0
Fork 0
mirror of https://github.com/zdharma-continuum/zinit.git synced 2024-11-21 08:37:59 +01:00
zinit/_zinit
vladislav doster b7b8347cad
fix: compile command logic when using id-as ice (#619)
- Updated README.md `compiling` section
- Compile commands now work with `id-as` ice
- Compile command options added to tab completion  

Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
2024-03-03 23:43:48 -06:00

369 lines
12 KiB
Text

#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'
'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:Generate Zsh plugin boilerplate'
'creinstall:Install completions for plugin'
'csearch:Search for available completions from any plugin'
'cuninstall:Uninstall completions for plugin'
'debug:Functions for debugging Zinit'
'delete:Uninstall a plugin or snippet'
'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
} # ]]]
###
# Commands in the debug context
###
_zinit_debug_commands=(
'clear:Clear report of debug tracing session'
'report:Show report of debug tracing session'
'revert:Revert changes detected during debug tracing session'
'start:Start debug tracing session'
'status:Show current state of debug mode'
'stop:Stop debug tracing session'
)
# 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 )
builtin print -- "$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_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 \
'(-h --help)'{-h,--help}'[Show this help message]' \
'(-q --quiet)'{-q,--quiet}'[Make some output more quiet]' \
+ '(operation)' \
'(-a --all)'{-a,--all}'[Compile all plugins]' \
'*::installed:__zinit_installed' \
&& ret=0
} # ]]]
# FUNCTION: _zinit_create [[[
_zinit_create(){
_arguments \
'1:Plugin Name' && 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_delete [[[
_zinit_delete(){
_arguments \
{-d,--debug}'[Enable xtrace]' \
{-h,--help}'[Show this help message]' \
{-q,--quiet}'[Make some output more quiet]' \
{-y,--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]' \
&& ret=0
} # ]]]
_zinit_debug(){
_arguments \
'1: :_zinit_debug_cmds'
} # ]]]
# 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 \
'(-h --help)'{-h,--help}'[Show this help message]' \
'(-q --quiet)'{-q,--quiet}'[Make some output more quiet]' \
+ '(operation)' \
'(-a --all)'{-a,--all}'[Uncompile all plugins]' \
'*::installed:__zinit_installed' \
&& ret=0
} # ]]]
# 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
} # ]]]
(( $+functions[_zinit_debug_cmds] )) || _zinit_debug_cmds() {
_describe -t commands 'commands' _zinit_debug_commands "$@"
}
_zinit "$@"
#vim: filetype=zsh foldmarker=[[[,]]] foldmethod=marker shiftwidth=2 softtabstop=2 tabstop=2: