From: Andrew Lazarus Date: Wed, 8 Mar 2017 17:23:36 +0000 (-0800) Subject: support custom cargo-* command zsh tab completion X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~9^2~110^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a8ed44cf7e1b043c63640282006c180100e68399;p=cargo.git support custom cargo-* command zsh tab completion --- diff --git a/src/etc/_cargo b/src/etc/_cargo index d1b43182e..7e2d27d31 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -3,6 +3,9 @@ typeset -A opt_args autoload -U regexp-replace +zstyle -T ':completion:*:*:cargo:*' tag-order && \ + zstyle ':completion:*:*:cargo:*' tag-order 'common-commands' + _cargo() { _arguments \ @@ -11,10 +14,14 @@ _arguments \ '(- 1 *)'{-v,--verbose}'[use verbose output]' \ '(- 1 *)'--color'[colorization option]' \ '(- 1 *)'{-V,--version}'[show version information]' \ - '1: :_cargo_cmds' \ + '1: :->command' \ '*:: :->args' case $state in + command) + _alternative 'common-commands:common:_cargo_cmds' 'all-commands:all:_cargo_all_cmds' + ;; + args) case $words[1] in bench) @@ -431,8 +438,12 @@ local -a commands;commands=( 'version:show version information' 'yank:remove pushed file from index' ) -_describe 'command' commands +_describe -t common-commands 'common commands' commands +} +_cargo_all_cmds(){ +local -a commands;commands=($(cargo --list)) +_describe -t all-commands 'all commands' commands }