diff options
Diffstat (limited to 'Completion/Builtins/_zstyle')
-rw-r--r-- | Completion/Builtins/_zstyle | 145 |
1 files changed, 108 insertions, 37 deletions
diff --git a/Completion/Builtins/_zstyle b/Completion/Builtins/_zstyle index f072f79ae..cd470598a 100644 --- a/Completion/Builtins/_zstyle +++ b/Completion/Builtins/_zstyle @@ -1,7 +1,8 @@ #compdef zstyle -local curcontext="$curcontext" state ostate line expl ctop -local nm=$compstat[nmatches] +local curcontext="$curcontext" state context ostate line expl ctop +local nm=$compstate[nmatches] mesg +typeset -A opt_args typeset -A styles # Assoc array of styles; the values give the possible top-level @@ -9,15 +10,18 @@ typeset -A styles # followed by a colon, followed by a state to enter, empty if none. styles=( accept-exact c:bool + add-space c:bool arguments c: auto-description c: - cache-path 'c:_path_files -/' + break c: completer c:completer completions c: condition c: - cursor c:bool + cursor c:cursor disable-stat c:bool + domains c: expand c: + file-patterns c:filepat format c: glob c: group-name c: @@ -26,8 +30,9 @@ styles=( hidden c:bool hosts c:_hosts hosts-ports c:host-port - hosts-ports-users c:host-port-user - ignored-suffixes c: + users-hosts-ports c:user-host-port + ignore-parents c:ignorepar + ignored-patterns c: insert-unambiguous c:bool last-prompt c:bool list c:listwhen @@ -36,21 +41,26 @@ styles=( list-packed c:bool list-rows-first c:bool local c: + matcher-list c: max-errors c: menu c:boolauto numbers c:bool original c:bool - path 'c:_path_files -/' + packageset c:packageset + path 'c:_wanted directories expl directory _path_files -/' ports c:_ports prefix-hidden c:bool prefix-needed c:bool prompt c: remove-all-dups c:bool + single-ignored c:single-ignored sort c:bool - tag-order c:tag special-dirs c:sdirs + squeeze-slashes c:bool stop c:stop + subst-glob-only c: substitute c: + tag-order c:tag users c:_users users-hosts c:user-host verbose c:bool @@ -83,9 +93,20 @@ while [[ -n $state ]]; do case "$ostate" in contexts) - if [[ $PREFIX != :*: ]]; then - _wanted contexts expl context && - compadd -P : -S : "$expl[@]" completion zftp + if _wanted contexts; then + if [[ $PREFIX != :*: ]]; then + _all_labels contexts expl context compadd -P : -S : completion zftp + elif [[ $PREFIX = :completion:* ]]; then + mesg='' + case "$PREFIX" in + :completion:[^:]#) mesg=function ;; + :completion:[^:]#:[^:]#) mesg=completer ;; + :completion:[^:]#:[^:]#:[^:]#) mesg='command or context' ;; + :completion:[^:]#:[^:]#:[^:]#:[^:]#) mesg=argument ;; + :completion:[^:]#:[^:]#:[^:]#:[^:]#:[^:]#) mesg=tag ;; + esac + [[ -n "$mesg" ]] && _message "$mesg" + fi fi ;; @@ -96,8 +117,8 @@ while [[ -n $state ]]; do else ctop=cz fi - _wanted styles expl style && - compadd "$expl[@]" - ${(k)styles[(R)[^:]#[$ctop][^:]#:*]} + _wanted styles expl style \ + compadd -M 'r:|-=* r:|=*' - ${(k)styles[(R)[^:]#[$ctop][^:]#:*]} ;; style-arg) @@ -105,66 +126,116 @@ while [[ -n $state ]]; do ;; bool) - _wanted values expl boolean && - compadd "$expl[@]" true false + _wanted values expl boolean compadd true false ;; boolauto) - _wanted values expl boolean && - compadd "$expl[@]" true false auto select + _wanted values expl boolean compadd true false auto select + ;; + + cursor) + if [[ "$words[2]" = *:completion:inc* ]]; then + _wanted values expl 'cursor positioning' compadd complete key default + elif [[ "$words[2]" = *:completion::* ]]; then + _wanted values expl 'cursor positioning' compadd true false + else + _wanted values expl 'cursor positioning' \ + compadd complete key default true false + fi ;; completer) - _wanted values expl completer && - compadd "$expl[@]" _complete _approximate _correct _match \ - _expand _list _menu _oldlist + _wanted values expl completer \ + compadd _complete _approximate _correct _match \ + _expand _list _menu _oldlist _next_tags ;; - host-port*) + user-host-port) + if [[ $PREFIX != *[@:]* ]]; then + _users -S @ + elif [[ $PREFIX = *[@:]*[[@:]* ]]; then + compset -P 2 '*[:@]' + _ports + else + compset -P 1 '*[:@]' + _hosts -S : + fi + ;; + + host-port) if [[ $PREFIX != *:* ]]; then _hosts -S : - elif [[ $ostate != *user || $PREFIX != *:*:* ]]; then + else compset -P 1 '*:' _ports - else - compset -P 2 '*:' - _users fi ;; listwhen) - _wanted values expl 'when to list completions' && - compadd "$expl[@]" always never sometimes + _wanted values expl 'when to list completions' \ + compadd always never sometimes + ;; + + packageset) + _wanted values expl 'default package set' \ + compadd available installed uninstalled ;; progress) - _wanted values expl 'progress meter style' && - compadd "$expl[@]" none bar percent + _wanted values expl 'progress meter style' \ + compadd none bar percent ;; sdirs) - _wanted values expl 'whether to complete . or ..' && - compadd "$expl[@]" true false .. + _wanted values expl 'whether to complete . or ..' \ + compadd true false .. ;; stop) - _wanted values expl 'when to insert matches' && - compadd "$expl[@]" true false verbose + _wanted values expl 'when to insert matches' \ + compadd true false verbose ;; tag) - _wanted tags expl tag && compadd "$expl[@]" - $taglist + compset -q + if compset -P '*:*:'; then + _message description + elif compset -P '*:'; then + _message 'tag alias' + else + _wanted tags expl tag compadd - $taglist + fi + ;; + + filepat) + if compset -P '*:*:'; then + _message description + elif compset -P '*:'; then + _message tag + else + _message 'glob patterns' + fi ;; user-host) - if [[ $PREFIX = *:* ]]; then - compset -P '*:' + if [[ $PREFIX = *[@:]* ]]; then + compset -P '*[@:]' _hosts else - _users + _users -S @ fi ;; + ignorepar) + _wanted values expl 'which parents to ignore' \ + compadd parent pwd .. directory + ;; + + single-ignored) + _wanted values expl 'how to handle a single ignored match' \ + compadd - show menu + ;; + _*) ${=ostate} ;; |