Simplify zsh completion
Completion file shouldn't be sourced. It should provide only completion code (source of _command) for command. It's task for package manager or user to put under $fpath.
This commit is contained in:
parent
7b2e60968b
commit
f89647bd19
@ -1,23 +1,16 @@
|
|||||||
#compdef $PROG
|
#compdef $PROG
|
||||||
|
|
||||||
_cli_zsh_autocomplete() {
|
local -a opts
|
||||||
|
local cur
|
||||||
|
cur=${words[-1]}
|
||||||
|
if [[ "$cur" == "-"* ]]; then
|
||||||
|
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
|
||||||
|
else
|
||||||
|
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
|
||||||
|
fi
|
||||||
|
|
||||||
local -a opts
|
if [[ "${opts[1]}" != "" ]]; then
|
||||||
local cur
|
_describe 'values' opts
|
||||||
cur=${words[-1]}
|
else
|
||||||
if [[ "$cur" == "-"* ]]; then
|
_files
|
||||||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
|
fi
|
||||||
else
|
|
||||||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${opts[1]}" != "" ]]; then
|
|
||||||
_describe 'values' opts
|
|
||||||
else
|
|
||||||
_files
|
|
||||||
fi
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
compdef _cli_zsh_autocomplete $PROG
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user