File tree 1 file changed +12
-1
lines changed 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -422,7 +422,18 @@ _cargo() {
422
422
423
423
_cargo_cmds() {
424
424
local -a commands
425
- commands=( ${${${(M)"${(f)$(cargo --list)}":# *}/ ##/}/ ##/:} )
425
+ # This uses Parameter Expansion Flags, which is an Zsh built-in features.
426
+ # See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
427
+ # and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion
428
+ #
429
+ # # How this work?
430
+ #
431
+ # First it splits the result of `cargo --list` at newline, then it removes the first line.
432
+ # Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]).
433
+ # Then it replaces those spaces between item and description with a `:`
434
+ #
435
+ # [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns
436
+ commands=( ${${${(M)"${(f)$(cargo --list)}":# *}/ ##/}/ ##/:} )
426
437
_describe 'command' commands
427
438
}
428
439
You can’t perform that action at this time.
0 commit comments