Skip to content

Commit 4471d7d

Browse files
committed
feat(zsh): improve completion matching and listing UX
- matcher-list: stage exact -> case-insensitive -> partial-after-separator -> substring matching, so completion loosens progressively - list-colors: colorize the completion list via LS_COLORS (vivid molokai) - descriptions/messages/warnings: colored, labelled group headings
1 parent 7a5f39d commit 4471d7d

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

.zsh/40_completions.zsh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,22 @@ zstyle ':completion:*' completer _expand _complete _match _approximate
77
# Approximate (typo-tolerant) matching: allow 1 error per 3 chars of the word,
88
# so short words (e.g. command names) stay strict and huge candidate sets don't blow up.
99
zstyle ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX + $#SUFFIX) / 3 )) numeric )'
10-
# Ignore case.
11-
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}'
10+
# Staged matching: exact -> case-insensitive -> partial-after-separator -> substring.
11+
# Tries each rule in order, only loosening when the previous yields no matches.
12+
zstyle ':completion:*' matcher-list \
13+
'' \
14+
'm:{a-zA-Z}={A-Za-z}' \
15+
'r:|[._-]=* r:|=*' \
16+
'l:|=* r:|=*'
1217
# Verbose output for completion listing.
1318
zstyle ':completion:*' verbose yes
19+
# Colorize the completion list using LS_COLORS (set in 30_colors.zsh via vivid).
20+
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
21+
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
22+
# Colored, labelled group headings / messages in the completion listing.
23+
zstyle ':completion:*:descriptions' format '%F{yellow}-- %d --%f'
24+
zstyle ':completion:*:messages' format '%F{cyan}-- %d --%f'
25+
zstyle ':completion:*:warnings' format '%F{red}-- no matches --%f'
1426
# All different types of matches displayed separately.
1527
zstyle ':completion:*' group-name ''
1628
# Make the completion menu selectable.

0 commit comments

Comments
 (0)