Skip to content

Commit a8ed44c

Browse files
committed
support custom cargo-* command zsh tab completion
1 parent 0806953 commit a8ed44c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/etc/_cargo

+13-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
typeset -A opt_args
44
autoload -U regexp-replace
55

6+
zstyle -T ':completion:*:*:cargo:*' tag-order && \
7+
zstyle ':completion:*:*:cargo:*' tag-order 'common-commands'
8+
69
_cargo() {
710

811
_arguments \
@@ -11,10 +14,14 @@ _arguments \
1114
'(- 1 *)'{-v,--verbose}'[use verbose output]' \
1215
'(- 1 *)'--color'[colorization option]' \
1316
'(- 1 *)'{-V,--version}'[show version information]' \
14-
'1: :_cargo_cmds' \
17+
'1: :->command' \
1518
'*:: :->args'
1619

1720
case $state in
21+
command)
22+
_alternative 'common-commands:common:_cargo_cmds' 'all-commands:all:_cargo_all_cmds'
23+
;;
24+
1825
args)
1926
case $words[1] in
2027
bench)
@@ -431,8 +438,12 @@ local -a commands;commands=(
431438
'version:show version information'
432439
'yank:remove pushed file from index'
433440
)
434-
_describe 'command' commands
441+
_describe -t common-commands 'common commands' commands
442+
}
435443

444+
_cargo_all_cmds(){
445+
local -a commands;commands=($(cargo --list))
446+
_describe -t all-commands 'all commands' commands
436447
}
437448

438449

0 commit comments

Comments
 (0)