summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordana <dana@dana.is>2022-04-26 21:19:09 -0500
committerAndrew Gallant <jamslam@gmail.com>2023-07-08 18:52:42 -0400
commit2708f9e81d790b42783fbe6ee4f2dd6b5d091eb7 (patch)
tree1d4784bd98e3df7251b8aad7ace5de4e31d7ebc0
parentf3241fd657c83284f0ec17854e41cab9fe3ce446 (diff)
complete: add extra-verbose support to _rg_types
When the extra-verbose style is set for the types tag, completed types are displayed along with the patterns they correspond to. This can be enabled by e.g. adding the following to .zshrc: zstyle ':completion:*:rg:*:types' extra-verbose true This change also makes _rg_types use the actual rg specified on the command line to look up types, and it fixes a mangled complete-all style check Fixes #2195
-rw-r--r--CHANGELOG.md2
-rw-r--r--complete/_rg10
2 files changed, 9 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7e013675..2b7233a0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@ Unreleased changes. Release notes have not yet been written.
Feature enhancements:
* Added or improved file type filtering for Elixir, Fuchsia, Gentoo, GraphQL, USD, V
+* [FEATURE #2195](https://github.com/BurntSushi/ripgrep/issues/2195):
+ When `extra-verbose` mode is enabled in zsh, show extra file type info.
* [FEATURE #2409](https://github.com/BurntSushi/ripgrep/pull/2409):
Added installation instructions for `winget`.
diff --git a/complete/_rg b/complete/_rg
index 31bc697c..0af8d7af 100644
--- a/complete/_rg
+++ b/complete/_rg
@@ -30,7 +30,7 @@ _rg() {
[[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] ||
# (--[imnp]* => --ignore*, --messages, --no-*, --pcre2-unicode)
[[ $PREFIX$SUFFIX == --[imnp]* ]] ||
- zstyle -t ":complete:$curcontext:*" complete-all
+ zstyle -t ":completion:${curcontext}:" complete-all
then
no=
fi
@@ -432,9 +432,13 @@ _rg_types() {
local -a expl
local -aU _types
- _types=( ${(@)${(f)"$( _call_program types rg --type-list )"}%%:*} )
+ _types=( ${(@)${(f)"$( _call_program types $words[1] --type-list )"}//:[[:space:]]##/:} )
- _wanted types expl 'file type' compadd -a "$@" - _types
+ if zstyle -t ":completion:${curcontext}:types" extra-verbose; then
+ _describe -t types 'file type' _types
+ else
+ _wanted types expl 'file type' compadd "$@" - ${(@)_types%%:*}
+ fi
}
_rg "$@"