diff options
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Base/_default | 10 | ||||
-rw-r--r-- | Completion/Base/_value | 30 | ||||
-rw-r--r-- | Completion/Builtins/_vars_eq | 8 | ||||
-rw-r--r-- | Completion/Builtins/_zstyle | 10 |
4 files changed, 47 insertions, 11 deletions
diff --git a/Completion/Base/_default b/Completion/Base/_default index e5091a544..8176f392c 100644 --- a/Completion/Base/_default +++ b/Completion/Base/_default @@ -12,10 +12,16 @@ if { zstyle -s ":completion:${curcontext}:" use-compctl ctl || compcall "$opt[@]" || return 0 fi -_files && return 0 +_files "$@" && return 0 # magicequalsubst allows arguments like <any-old-stuff>=~/foo to do # file name expansion after the =. In that case, it's natural to # allow completion to handle file names after any equals sign. -[[ -o magicequalsubst ]] && compset -P 1 '*=' && _files +if [[ -o magicequalsubst && "$PREFIX" = *\=* ]]; then + compstate[parameter]="${words[1]:t}-${PREFIX%%\=*}" + compset -P 1 '*=' + _value "$@" +else + return 1 +fi diff --git a/Completion/Base/_value b/Completion/Base/_value index e29c90e79..723285233 100644 --- a/Completion/Base/_value +++ b/Completion/Base/_value @@ -1,11 +1,32 @@ -#compdef -value- +#compdef -value- -array-value- _value () { - #_view_completion_parameters + # You can customize completion for different parameters by writing a + # function `_value:<name>'. + if (( $+functions[_value:$compstate[parameter]] )); then "_value:$compstate[parameter]" "$@" + elif [[ "$compstate[parameter]" != *-* && + "${(Pt)${compstate[parameter]}}" = assoc* ]]; then + if (( CURRENT & 1 )); then + _wanted association-keys expl 'association key' \ + compadd - "${(@kP)${compstate[parameter]}}" + else + compstate[parameter]="${compstate[parameter]}-${words[CURRENT-1]}" + _value "$@" + fi else - _default + local pats + + if { zstyle -a ":completion:${curcontext}:" assign-list pats && + [[ "$compstate[parameter]" = (${(j:|:)~pats}) ]] } || + [[ "$PREFIX$SUFFIX" = *:* ]]; then + compset -P '*:' + compset -S ':*' + _default -qS: "$@" + else + _default "$@" + fi fi } @@ -24,8 +45,11 @@ _value:LDFLAGS () { _files -/ "$@" elif compset -P '-R'; then compset -P '*:' + compset -S ':*' _files -/ -S/ -r ' :' "$@" else _default "$@" fi } + +_value "$@" diff --git a/Completion/Builtins/_vars_eq b/Completion/Builtins/_vars_eq index 9d7863ae6..1e8fa6d2b 100644 --- a/Completion/Builtins/_vars_eq +++ b/Completion/Builtins/_vars_eq @@ -1,9 +1,9 @@ #compdef declare export integer local readonly typeset -if compset -P '*=*:'; then - _default -elif compset -P '*='; then - _default +if [[ "$PREFIX" = *\=* ]]; then + compstate[parameter]="${PREFIX%%\=*}" + compset -P 1 '*=' + _value else _parameters -q -S '=' fi diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle index b19303300..5f078fddb 100644 --- a/Completion/Builtins/_zstyle +++ b/Completion/Builtins/_zstyle @@ -12,9 +12,10 @@ styles=( accept-exact c:bool add-space c:bool ambiguous c:bool - arguments c: + assign-list c: auto-description c: break-keys c: + command c:command completer c:completer completions c: condition c: @@ -38,7 +39,6 @@ styles=( insert-unambiguous c:bool last-prompt c:bool list c:listwhen - list-arguments c: list-colors c: list-packed c:bool list-rows-first c:bool @@ -235,6 +235,12 @@ while [[ -n $state ]]; do compadd - show menu ;; + command) + shift 3 words + (( CURRENT -= 3 )) + _normal + ;; + _*) ${=ostate} ;; |