summary refs log tree commit diff
path: root/dot_local/share/zsh/completion/completion.plugin.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'dot_local/share/zsh/completion/completion.plugin.zsh')
-rw-r--r--dot_local/share/zsh/completion/completion.plugin.zsh64
1 files changed, 64 insertions, 0 deletions
diff --git a/dot_local/share/zsh/completion/completion.plugin.zsh b/dot_local/share/zsh/completion/completion.plugin.zsh
new file mode 100644
index 0000000..97ada23
--- /dev/null
+++ b/dot_local/share/zsh/completion/completion.plugin.zsh
@@ -0,0 +1,64 @@
+# Completions
+zmodload -i zsh/complist
+
+unsetopt menu_complete   # do not autoselect the first completion entry
+setopt always_to_end     # Always place the cursor to the end of the word completed
+setopt list_packed       # The completion menu takes less space
+setopt auto_menu         # Display the completion menu after two use of the TAB key
+setopt complete_in_word  #  By default, the cursor goes at the end of the word when completion start. Setting this will not move the cursor and the completion will happen on both end of the word completed.
+
+# TODO: show paginated list on tab without prompt, but do not select first entry
+zstyle ':completion:*' menu yes select
+zstyle ':completion:*:default' select-prompt '%F{black}%K{cyan}line %l %p%f%k'
+zstyle ':completion:*:default' select-scroll 1
+
+bindkey -M menuselect '^f' vi-insert
+zstyle ':completion:*' special-dirs true
+zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
+zstyle ':completion:*' use-cache yes
+zstyle ':completion:*' cache-path ${XDG_CACHE_HOME:-${HOME}/.cache}/zsh/completions
+zstyle ':completion:*' single-ignored show
+zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm -w -w"
+
+# Group by descriptions and show description nme
+zstyle ':completion:*' group-name ''
+zstyle ':completion:*:*:*:*:descriptions' format '%F{cyan}%d%f'
+
+zstyle ':completion:*:*:*:*:corrections' format '%F{yellow}%d (errors: %e):%f'
+zstyle ':completion:*:messages' format '  %F{purple}-- %d --%f'
+zstyle ':completion:*:warnings' format '  %F{red}-- No matches found! --%f'
+
+zstyle ":completion:*" list-colors ${(s.:.)LS_COLORS}
+zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*( *[a-z])*=34=31=33'
+
+# Don't auto-complete uncommon/fake commands (WSL)
+zstyle ':completion:*:*:*:commands' ignored-patterns '*.dll' '*.DLL' '*.nls' '*.NLS' '*.mof' '*.MOF'
+
+# Don't autocomplete non-login users by default
+if [[ -f /etc/passwd ]]; then
+  # shellcheck disable=SC2046
+  zstyle ':completion:*:*:*:users' ignored-patterns $(grep -E '/(nologin|false)$' /etc/passwd | cut -d: -f1 | sort)
+else
+  zstyle ':completion:*:*:*:users' ignored-patterns '_*'
+fi
+
+# Ignore "private" functions
+zstyle ':completion:*:functions' ignored-patterns '_*' '.*'
+zstyle ':completion:*:widgets' ignored-patterns '_*' '.*'
+
+# TODO: check/review
+zstyle ':completion:*:paths' ignore-parents 'parent pwd directory'
+zstyle ':completion:*:paths' expand suffix
+zstyle ':completion:*:paths' list-suffixes yes
+zstyle ':completion:*:paths' path-completion no
+
+# TODO: complete hosts from history, .ssh/config, .ssh/known_hosts, /etc/hosts and .local/share/zsh/comphosts
+# zstyle -e ':completion:*' hosts ${KNOWN_HOSTS}
+
+# man completion
+zstyle ':completion:*' insert-sections yes
+zstyle ':completion:*' separate-sections yes
+
+# Needed for _gnu_generic to prevent descriptions from getting cropped.
+# TODO: Might be fixed in a future version of zsh.
+zstyle ':completion:*' command '- COLUMNS=999'