summarylogtreecommitdiffstats
path: root/watson.zsh-completion.patch
blob: e1a93db27243cc934ce46180094cb4e3eb624f0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
diff --git a/watson.zsh-completion b/watson.zsh-completion
index 3594054..fc65ba5 100644
--- a/watson.zsh-completion
+++ b/watson.zsh-completion
@@ -6,17 +6,20 @@ _watson_completion() {
     local -a response
     (( ! $+commands[watson] )) && return 1
 
-    response=("${(@f)$( env COMP_WORDS="${words[*]}" \
-                        COMP_CWORD=$((CURRENT-1)) \
-                        _WATSON_COMPLETE="complete_zsh" \
-                        watson )}")
+    response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _WATSON_COMPLETE=zsh_complete watson)}")
 
-    for key descr in ${(kv)response}; do
-      if [[ "$descr" == "_" ]]; then
-          completions+=("$key")
-      else
-          completions_with_descriptions+=("$key":"$descr")
-      fi
+    for type key descr in ${response}; do
+        if [[ "$type" == "plain" ]]; then
+            if [[ "$descr" == "_" ]]; then
+                completions+=("$key")
+            else
+                completions_with_descriptions+=("$key":"$descr")
+            fi
+        elif [[ "$type" == "dir" ]]; then
+            _path_files -/
+        elif [[ "$type" == "file" ]]; then
+            _path_files -f
+        fi
     done
 
     if [ -n "$completions_with_descriptions" ]; then
@@ -26,7 +29,7 @@ _watson_completion() {
     if [ -n "$completions" ]; then
         compadd -U -V unsorted -a completions
     fi
-    compstate[insert]="automenu"
 }
 
 compdef _watson_completion watson;
+