about summary refs log tree commit diff
path: root/Completion/Base
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Base')
-rw-r--r--Completion/Base/_default10
-rw-r--r--Completion/Base/_value30
2 files changed, 35 insertions, 5 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 "$@"