summary refs log tree commit diff
path: root/dot_local/share/zsh/completion
diff options
context:
space:
mode:
authorAlen <alen@dotfiles.xyz>2025-01-19 03:26:44 +0400
committerAlen <alen@dotfiles.xyz>2025-01-19 03:26:44 +0400
commit43c982798c902315aba2f8865d0407c6ff70a180 (patch)
tree469de00c188d60d2859066cfa94bf2880b16eb46 /dot_local/share/zsh/completion
parent6e8b63f101e056f80cf6b7d17d07161bead1ceeb (diff)
Add batch of zsh plugins and kitting out
Diffstat (limited to 'dot_local/share/zsh/completion')
-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'