forked from zdharma-continuum/zinit
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_zinit
369 lines (363 loc) · 11.9 KB
/
_zinit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
#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: