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