]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/ripgrep/_ripgrep
...
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / ripgrep / _ripgrep
1 #compdef rg
2
3 ##
4 # zsh completion function for ripgrep
5 #
6 # Run ci/test-complete after building to ensure that the options supported by
7 # this function stay in synch with the `rg` binary.
8 #
9 # For convenience, a completion reference guide is included at the bottom of
10 # this file.
11 #
12 # Originally based on code from the zsh-users project — see copyright notice
13 # below.
14
15 _rg() {
16   local curcontext=$curcontext no='!' descr ret=1
17   local -a context line state state_descr args tmp suf
18   local -A opt_args
19
20   # ripgrep has many options which negate the effect of a more common one — for
21   # example, `--no-column` to negate `--column`, and `--messages` to negate
22   # `--no-messages`. There are so many of these, and they're so infrequently
23   # used, that some users will probably find it irritating if they're completed
24   # indiscriminately, so let's not do that unless either the current prefix
25   # matches one of those negation options or the user has the `complete-all`
26   # style set. Note that this prefix check has to be updated manually to account
27   # for all of the potential negation options listed below!
28   if
29     # We also want to list all of these options during testing
30     [[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] ||
31     # (--[imnp]* => --ignore*, --messages, --no-*, --pcre2-unicode)
32     [[ $PREFIX$SUFFIX == --[imnp]* ]] ||
33     zstyle -t ":complete:$curcontext:*" complete-all
34   then
35     no=
36   fi
37
38   # We make heavy use of argument groups here to prevent the option specs from
39   # growing unwieldy. These aren't supported in zsh <5.4, though, so we'll strip
40   # them out below if necessary. This makes the exclusions inaccurate on those
41   # older versions, but oh well — it's not that big a deal
42   args=(
43     + '(exclusive)' # Misc. fully exclusive options
44     '(: * -)'{-h,--help}'[display help information]'
45     '(: * -)'{-V,--version}'[display version information]'
46     '(: * -)'--pcre2-version'[print the version of PCRE2 used by ripgrep, if available]'
47
48     + '(buffered)' # buffering options
49     '--line-buffered[force line buffering]'
50     $no"--no-line-buffered[don't force line buffering]"
51     '--block-buffered[force block buffering]'
52     $no"--no-block-buffered[don't force block buffering]"
53
54     + '(case)' # Case-sensitivity options
55     {-i,--ignore-case}'[search case-insensitively]'
56     {-s,--case-sensitive}'[search case-sensitively]'
57     {-S,--smart-case}'[search case-insensitively if pattern is all lowercase]'
58
59     + '(context-a)' # Context (after) options
60     '(context-c)'{-A+,--after-context=}'[specify lines to show after each match]:number of lines'
61
62     + '(context-b)' # Context (before) options
63     '(context-c)'{-B+,--before-context=}'[specify lines to show before each match]:number of lines'
64
65     + '(context-c)' # Context (combined) options
66     '(context-a context-b)'{-C+,--context=}'[specify lines to show before and after each match]:number of lines'
67
68     + '(column)' # Column options
69     '--column[show column numbers for matches]'
70     $no"--no-column[don't show column numbers for matches]"
71
72     + '(count)' # Counting options
73     {-c,--count}'[only show count of matching lines for each file]'
74     '--count-matches[only show count of individual matches for each file]'
75     '--include-zero[include files with zero matches in summary]'
76
77     + '(encoding)' # Encoding options
78     {-E+,--encoding=}'[specify text encoding of files to search]: :_rg_encodings'
79     $no'--no-encoding[use default text encoding]'
80
81     + '(engine)' # Engine choice options
82     '--engine=[select which regex engine to use]:when:((
83       default\:"use default engine"
84       pcre2\:"identical to --pcre2"
85       auto\:"identical to --auto-hybrid-regex"
86     ))'
87
88     + file # File-input options
89     '(1)*'{-f+,--file=}'[specify file containing patterns to search for]: :_files'
90
91     + '(file-match)' # Files with/without match options
92     '(stats)'{-l,--files-with-matches}'[only show names of files with matches]'
93     '(stats)--files-without-match[only show names of files without matches]'
94
95     + '(file-name)' # File-name options
96     {-H,--with-filename}'[show file name for matches]'
97     {-I,--no-filename}"[don't show file name for matches]"
98
99     + '(file-system)' # File system options
100     "--one-file-system[don't descend into directories on other file systems]"
101     $no'--no-one-file-system[descend into directories on other file systems]'
102
103     + '(fixed)' # Fixed-string options
104     {-F,--fixed-strings}'[treat pattern as literal string instead of regular expression]'
105     $no"--no-fixed-strings[don't treat pattern as literal string]"
106
107     + '(follow)' # Symlink-following options
108     {-L,--follow}'[follow symlinks]'
109     $no"--no-follow[don't follow symlinks]"
110
111     + glob # File-glob options
112     '*'{-g+,--glob=}'[include/exclude files matching specified glob]:glob'
113     '*--iglob=[include/exclude files matching specified case-insensitive glob]:glob'
114
115     + '(glob-case-insensitive)' # File-glob case sensitivity options
116     '--glob-case-insensitive[treat -g/--glob patterns case insensitively]'
117     $no'--no-glob-case-insensitive[treat -g/--glob patterns case sensitively]'
118
119     + '(heading)' # Heading options
120     '(pretty-vimgrep)--heading[show matches grouped by file name]'
121     "(pretty-vimgrep)--no-heading[don't show matches grouped by file name]"
122
123     + '(hidden)' # Hidden-file options
124     {-.,--hidden}'[search hidden files and directories]'
125     $no"--no-hidden[don't search hidden files and directories]"
126
127     + '(hybrid)' # hybrid regex options
128     '--auto-hybrid-regex[dynamically use PCRE2 if necessary]'
129     $no"--no-auto-hybrid-regex[don't dynamically use PCRE2 if necessary]"
130
131     + '(ignore)' # Ignore-file options
132     "(--no-ignore-global --no-ignore-parent --no-ignore-vcs --no-ignore-dot)--no-ignore[don't respect ignore files]"
133     $no'(--ignore-global --ignore-parent --ignore-vcs --ignore-dot)--ignore[respect ignore files]'
134
135     + '(ignore-file-case-insensitive)' # Ignore-file case sensitivity options
136     '--ignore-file-case-insensitive[process ignore files case insensitively]'
137     $no'--no-ignore-file-case-insensitive[process ignore files case sensitively]'
138
139     + '(ignore-exclude)' # Local exclude (ignore)-file options
140     "--no-ignore-exclude[don't respect local exclude (ignore) files]"
141     $no'--ignore-exclude[respect local exclude (ignore) files]'
142
143     + '(ignore-global)' # Global ignore-file options
144     "--no-ignore-global[don't respect global ignore files]"
145     $no'--ignore-global[respect global ignore files]'
146
147     + '(ignore-parent)' # Parent ignore-file options
148     "--no-ignore-parent[don't respect ignore files in parent directories]"
149     $no'--ignore-parent[respect ignore files in parent directories]'
150
151     + '(ignore-vcs)' # VCS ignore-file options
152     "--no-ignore-vcs[don't respect version control ignore files]"
153     $no'--ignore-vcs[respect version control ignore files]'
154
155     + '(require-git)' # git specific settings
156     "--no-require-git[don't require git repository to respect gitignore rules]"
157     $no'--require-git[require git repository to respect gitignore rules]'
158
159     + '(ignore-dot)' # .ignore options
160     "--no-ignore-dot[don't respect .ignore files]"
161     $no'--ignore-dot[respect .ignore files]'
162
163     + '(ignore-files)' # custom global ignore file options
164     "--no-ignore-files[don't respect --ignore-file flags]"
165     $no'--ignore-files[respect --ignore-file files]'
166
167     + '(json)' # JSON options
168     '--json[output results in JSON Lines format]'
169     $no"--no-json[don't output results in JSON Lines format]"
170
171     + '(line-number)' # Line-number options
172     {-n,--line-number}'[show line numbers for matches]'
173     {-N,--no-line-number}"[don't show line numbers for matches]"
174
175     + '(line-terminator)' # Line-terminator options
176     '--crlf[use CRLF as line terminator]'
177     $no"--no-crlf[don't use CRLF as line terminator]"
178     '(text)--null-data[use NUL as line terminator]'
179
180     + '(max-columns-preview)' # max column preview options
181     '--max-columns-preview[show preview for long lines (with -M)]'
182     $no"--no-max-columns-preview[don't show preview for long lines (with -M)]"
183
184     + '(max-depth)' # Directory-depth options
185     '--max-depth=[specify max number of directories to descend]:number of directories'
186     '!--maxdepth=:number of directories'
187
188     + '(messages)' # Error-message options
189     '(--no-ignore-messages)--no-messages[suppress some error messages]'
190     $no"--messages[don't suppress error messages affected by --no-messages]"
191
192     + '(messages-ignore)' # Ignore-error message options
193     "--no-ignore-messages[don't show ignore-file parse error messages]"
194     $no'--ignore-messages[show ignore-file parse error messages]'
195
196     + '(mmap)' # mmap options
197     '--mmap[search using memory maps when possible]'
198     "--no-mmap[don't search using memory maps]"
199
200     + '(multiline)' # Multiline options
201     {-U,--multiline}'[permit matching across multiple lines]'
202     $no'(multiline-dotall)--no-multiline[restrict matches to at most one line each]'
203
204     + '(multiline-dotall)' # Multiline DOTALL options
205     '(--no-multiline)--multiline-dotall[allow "." to match newline (with -U)]'
206     $no"(--no-multiline)--no-multiline-dotall[don't allow \".\" to match newline (with -U)]"
207
208     + '(only)' # Only-match options
209     {-o,--only-matching}'[show only matching part of each line]'
210
211     + '(passthru)' # Pass-through options
212     '(--vimgrep)--passthru[show both matching and non-matching lines]'
213     '!(--vimgrep)--passthrough'
214
215     + '(pcre2)' # PCRE2 options
216     {-P,--pcre2}'[enable matching with PCRE2]'
217     $no'(pcre2-unicode)--no-pcre2[disable matching with PCRE2]'
218
219     + '(pcre2-unicode)' # PCRE2 Unicode options
220     $no'(--no-pcre2 --no-pcre2-unicode)--pcre2-unicode[enable PCRE2 Unicode mode (with -P)]'
221     '(--no-pcre2 --pcre2-unicode)--no-pcre2-unicode[disable PCRE2 Unicode mode (with -P)]'
222
223     + '(pre)' # Preprocessing options
224     '(-z --search-zip)--pre=[specify preprocessor utility]:preprocessor utility:_command_names -e'
225     $no'--no-pre[disable preprocessor utility]'
226
227     + pre-glob # Preprocessing glob options
228     '*--pre-glob[include/exclude files for preprocessing with --pre]'
229
230     + '(pretty-vimgrep)' # Pretty/vimgrep display options
231     '(heading)'{-p,--pretty}'[alias for --color=always --heading -n]'
232     '(heading passthru)--vimgrep[show results in vim-compatible format]'
233
234     + regexp # Explicit pattern options
235     '(1 file)*'{-e+,--regexp=}'[specify pattern]:pattern'
236
237     + '(replace)' # Replacement options
238     {-r+,--replace=}'[specify string used to replace matches]:replace string'
239
240     + '(sort)' # File-sorting options
241     '(threads)--sort=[sort results in ascending order (disables parallelism)]:sort method:((
242       none\:"no sorting"
243       path\:"sort by file path"
244       modified\:"sort by last modified time"
245       accessed\:"sort by last accessed time"
246       created\:"sort by creation time"
247     ))'
248     '(threads)--sortr=[sort results in descending order (disables parallelism)]:sort method:((
249       none\:"no sorting"
250       path\:"sort by file path"
251       modified\:"sort by last modified time"
252       accessed\:"sort by last accessed time"
253       created\:"sort by creation time"
254     ))'
255     '!(threads)--sort-files[sort results by file path (disables parallelism)]'
256
257     + '(stats)' # Statistics options
258     '(--files file-match)--stats[show search statistics]'
259     $no"--no-stats[don't show search statistics]"
260
261     + '(text)' # Binary-search options
262     {-a,--text}'[search binary files as if they were text]'
263     "--binary[search binary files, don't print binary data]"
264     $no"--no-binary[don't search binary files]"
265     $no"(--null-data)--no-text[don't search binary files as if they were text]"
266
267     + '(threads)' # Thread-count options
268     '(sort)'{-j+,--threads=}'[specify approximate number of threads to use]:number of threads'
269
270     + '(trim)' # Trim options
271     '--trim[trim any ASCII whitespace prefix from each line]'
272     $no"--no-trim[don't trim ASCII whitespace prefix from each line]"
273
274     + type # Type options
275     '*'{-t+,--type=}'[only search files matching specified type]: :_rg_types'
276     '*--type-add=[add new glob for specified file type]: :->typespec'
277     '*--type-clear=[clear globs previously defined for specified file type]: :_rg_types'
278     # This should actually be exclusive with everything but other type options
279     '(: *)--type-list[show all supported file types and their associated globs]'
280     '*'{-T+,--type-not=}"[don't search files matching specified file type]: :_rg_types"
281
282     + '(word-line)' # Whole-word/line match options
283     {-w,--word-regexp}'[only show matches surrounded by word boundaries]'
284     {-x,--line-regexp}'[only show matches surrounded by line boundaries]'
285
286     + '(unicode)' # Unicode options
287     $no'--unicode[enable Unicode mode]'
288     '--no-unicode[disable Unicode mode]'
289
290     + '(zip)' # Compression options
291     '(--pre)'{-z,--search-zip}'[search in compressed files]'
292     $no"--no-search-zip[don't search in compressed files]"
293
294     + misc # Other options — no need to separate these at the moment
295     '(-b --byte-offset)'{-b,--byte-offset}'[show 0-based byte offset for each matching line]'
296     '--color=[specify when to use colors in output]:when:((
297       never\:"never use colors"
298       auto\:"use colors or not based on stdout, TERM, etc."
299       always\:"always use colors"
300       ansi\:"always use ANSI colors (even on Windows)"
301     ))'
302     '*--colors=[specify color and style settings]: :->colorspec'
303     '--context-separator=[specify string used to separate non-continuous context lines in output]:separator'
304     $no"--no-context-separator[don't print context separators]"
305     '--debug[show debug messages]'
306     '--field-context-separator[set string to delimit fields in context lines]'
307     '--field-match-separator[set string to delimit fields in matching lines]'
308     '--trace[show more verbose debug messages]'
309     '--dfa-size-limit=[specify upper size limit of generated DFA]:DFA size (bytes)'
310     "(1 stats)--files[show each file that would be searched (but don't search)]"
311     '*--ignore-file=[specify additional ignore file]:ignore file:_files'
312     '(-v --invert-match)'{-v,--invert-match}'[invert matching]'
313     '(-M --max-columns)'{-M+,--max-columns=}'[specify max length of lines to print]:number of bytes'
314     '(-m --max-count)'{-m+,--max-count=}'[specify max number of matches per file]:number of matches'
315     '--max-filesize=[specify size above which files should be ignored]:file size (bytes)'
316     "--no-config[don't load configuration files]"
317     '(-0 --null)'{-0,--null}'[print NUL byte after file names]'
318     '--path-separator=[specify path separator to use when printing file names]:separator'
319     '(-q --quiet)'{-q,--quiet}'[suppress normal output]'
320     '--regex-size-limit=[specify upper size limit of compiled regex]:regex size (bytes)'
321     '*'{-u,--unrestricted}'[reduce level of "smart" searching]'
322
323     + operand # Operands
324     '(--files --type-list file regexp)1: :_guard "^-*" pattern'
325     '(--type-list)*: :_files'
326   )
327
328   # This is used with test-complete to verify that there are no options
329   # listed in the help output that aren't also defined here
330   [[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] && {
331     print -rl - $args
332     return 0
333   }
334
335   # Strip out argument groups where unsupported (see above)
336   [[ $ZSH_VERSION == (4|5.<0-3>)(.*)# ]] &&
337   args=( ${(@)args:#(#i)(+|[a-z0-9][a-z0-9_-]#|\([a-z0-9][a-z0-9_-]#\))} )
338
339   _arguments -C -s -S : $args && ret=0
340
341   case $state in
342     colorspec)
343       if [[ ${IPREFIX#--*=}$PREFIX == [^:]# ]]; then
344         suf=( -qS: )
345         tmp=(
346           'column:specify coloring for column numbers'
347           'line:specify coloring for line numbers'
348           'match:specify coloring for match text'
349           'path:specify coloring for file names'
350         )
351         descr='color/style type'
352       elif [[ ${IPREFIX#--*=}$PREFIX == (column|line|match|path):[^:]# ]]; then
353         suf=( -qS: )
354         tmp=(
355           'none:clear color/style for type'
356           'bg:specify background color'
357           'fg:specify foreground color'
358           'style:specify text style'
359         )
360         descr='color/style attribute'
361       elif [[ ${IPREFIX#--*=}$PREFIX == [^:]##:(bg|fg):[^:]# ]]; then
362         tmp=( black blue green red cyan magenta yellow white )
363         descr='color name or r,g,b'
364       elif [[ ${IPREFIX#--*=}$PREFIX == [^:]##:style:[^:]# ]]; then
365         tmp=( {,no}bold {,no}intense {,no}underline )
366         descr='style name'
367       else
368         _message -e colorspec 'no more arguments'
369       fi
370
371       (( $#tmp )) && {
372         compset -P '*:'
373         _describe -t colorspec $descr tmp $suf && ret=0
374       }
375       ;;
376
377     typespec)
378       if compset -P '[^:]##:include:'; then
379         _sequence -s , _rg_types && ret=0
380       # @todo This bit in particular could be better, but it's a little
381       # complex, and attempting to solve it seems to run us up against a crash
382       # bug — zsh # 40362
383       elif compset -P '[^:]##:'; then
384         _message 'glob or include directive' && ret=1
385       elif [[ ! -prefix *:* ]]; then
386         _rg_types -qS : && ret=0
387       fi
388       ;;
389   esac
390
391   return ret
392 }
393
394 # Complete encodings
395 _rg_encodings() {
396   local -a expl
397   local -aU _encodings
398
399   # This is impossible to read, but these encodings rarely if ever change, so it
400   # probably doesn't matter. They are derived from the list given here:
401   # https://encoding.spec.whatwg.org/#concept-encoding-get
402   _encodings=(
403     {{,us-}ascii,arabic,chinese,cyrillic,greek{,8},hebrew,korean}
404     logical visual mac {,cs}macintosh x-mac-{cyrillic,roman,ukrainian}
405     866 ibm{819,866} csibm866
406     big5{,-hkscs} {cn-,cs}big5 x-x-big5
407     cp{819,866,125{0..8}} x-cp125{0..8}
408     csiso2022{jp,kr} csiso8859{6,8}{e,i}
409     csisolatin{{1..6},9} csisolatin{arabic,cyrillic,greek,hebrew}
410     ecma-{114,118} asmo-708 elot_928 sun_eu_greek
411     euc-{jp,kr} x-euc-jp cseuckr cseucpkdfmtjapanese
412     {,x-}gbk csiso58gb231280 gb18030 {,cs}gb2312 gb_2312{,-80} hz-gb-2312
413     iso-2022-{cn,cn-ext,jp,kr}
414     iso8859{,-}{{1..11},13,14,15}
415     iso-8859-{{1..11},{6,8}-{e,i},13,14,15,16} iso_8859-{{1..9},15}
416     iso_8859-{1,2,6,7}:1987 iso_8859-{3,4,5,8}:1988 iso_8859-9:1989
417     iso-ir-{58,100,101,109,110,126,127,138,144,148,149,157}
418     koi{,8,8-r,8-ru,8-u,8_r} cskoi8r
419     ks_c_5601-{1987,1989} ksc{,_}5691 csksc56011987
420     latin{1..6} l{{1..6},9}
421     shift{-,_}jis csshiftjis {,x-}sjis ms_kanji ms932
422     utf{,-}8 utf-16{,be,le} unicode-1-1-utf-8
423     windows-{31j,874,949,125{0..8}} dos-874 tis-620 ansi_x3.4-1968
424     x-user-defined auto none
425   )
426
427   _wanted encodings expl encoding compadd -a "$@" - _encodings
428 }
429
430 # Complete file types
431 _rg_types() {
432   local -a expl
433   local -aU _types
434
435   _types=( ${(@)${(f)"$( _call_program types rg --type-list )"}%%:*} )
436
437   _wanted types expl 'file type' compadd -a "$@" - _types
438 }
439
440 _rg "$@"
441
442 ################################################################################
443 # ZSH COMPLETION REFERENCE
444 #
445 # For the convenience of developers who aren't especially familiar with zsh
446 # completion functions, a brief reference guide follows. This is in no way
447 # comprehensive; it covers just enough of the basic structure, syntax, and
448 # conventions to help someone make simple changes like adding new options. For
449 # more complete documentation regarding zsh completion functions, please see the
450 # following:
451 #
452 # * http://zsh.sourceforge.net/Doc/Release/Completion-System.html
453 # * https://github.com/zsh-users/zsh/blob/master/Etc/completion-style-guide
454 #
455 # OVERVIEW
456 #
457 # Most zsh completion functions are defined in terms of `_arguments`, which is a
458 # shell function that takes a series of argument specifications. The specs for
459 # `rg` are stored in an array, which is common for more complex functions; the
460 # elements of the array are passed to `_arguments` on invocation.
461 #
462 # ARGUMENT-SPECIFICATION SYNTAX
463 #
464 # The following is a contrived example of the argument specs for a simple tool:
465 #
466 #   '(: * -)'{-h,--help}'[display help information]'
467 #   '(-q -v --quiet --verbose)'{-q,--quiet}'[decrease output verbosity]'
468 #   '!(-q -v --quiet --verbose)--silent'
469 #   '(-q -v --quiet --verbose)'{-v,--verbose}'[increase output verbosity]'
470 #   '--color=[specify when to use colors]:when:(always never auto)'
471 #   '*:example file:_files'
472 #
473 # Although there may appear to be six specs here, there are actually nine; we
474 # use brace expansion to combine specs for options that go by multiple names,
475 # like `-q` and `--quiet`. This is customary, and ties in with the fact that zsh
476 # merges completion possibilities together when they have the same description.
477 #
478 # The first line defines the option `-h`/`--help`. With most tools, it isn't
479 # useful to complete anything after `--help` because it effectively overrides
480 # all others; the `(: * -)` at the beginning of the spec tells zsh not to
481 # complete any other operands (`:` and `*`) or options (`-`) after this one has
482 # been used. The `[...]` at the end associates a description with `-h`/`--help`;
483 # as mentioned, zsh will see the identical descriptions and merge these options
484 # together when offering completion possibilities.
485 #
486 # The next line defines `-q`/`--quiet`. Here we don't want to suppress further
487 # completions entirely, but we don't want to offer `-q` if `--quiet` has been
488 # given (since they do the same thing), nor do we want to offer `-v` (since it
489 # doesn't make sense to be quiet and verbose at the same time). We don't need to
490 # tell zsh not to offer `--quiet` a second time, since that's the default
491 # behaviour, but since this line expands to two specs describing `-q` *and*
492 # `--quiet` we do need to explicitly list all of them here.
493 #
494 # The next line defines a hidden option `--silent` — maybe it's a deprecated
495 # synonym for `--quiet`. The leading `!` indicates that zsh shouldn't offer this
496 # option during completion. The benefit of providing a spec for an option that
497 # shouldn't be completed is that, if someone *does* use it, we can correctly
498 # suppress completion of other options afterwards.
499 #
500 # The next line defines `-v`/`--verbose`; this works just like `-q`/`--quiet`.
501 #
502 # The next line defines `--color`. In this example, `--color` doesn't have a
503 # corresponding short option, so we don't need to use brace expansion. Further,
504 # there are no other options it's exclusive with (just itself), so we don't need
505 # to define those at the beginning. However, it does take a mandatory argument.
506 # The `=` at the end of `--color=` indicates that the argument may appear either
507 # like `--color always` or like `--color=always`; this is how most GNU-style
508 # command-line tools work. The corresponding short option would normally use `+`
509 # — for example, `-c+` would allow either `-c always` or `-calways`. For this
510 # option, the arguments are known ahead of time, so we can simply list them in
511 # parentheses at the end (`when` is used as the description for the argument).
512 #
513 # The last line defines an operand (a non-option argument). In this example, the
514 # operand can be used any number of times (the leading `*`), and it should be a
515 # file path, so we tell zsh to call the `_files` function to complete it. The
516 # `example file` in the middle is the description to use for this operand; we
517 # could use a space instead to accept the default provided by `_files`.
518 #
519 # GROUPING ARGUMENT SPECIFICATIONS
520 #
521 # Newer versions of zsh support grouping argument specs together. All specs
522 # following a `+` and then a group name are considered to be members of the
523 # named group. Grouping is useful mostly for organisational purposes; it makes
524 # the relationship between different options more obvious, and makes it easier
525 # to specify exclusions.
526 #
527 # We could rewrite our example above using grouping as follows:
528 #
529 #   '(: * -)'{-h,--help}'[display help information]'
530 #   '--color=[specify when to use colors]:when:(always never auto)'
531 #   '*:example file:_files'
532 #   + '(verbosity)'
533 #   {-q,--quiet}'[decrease output verbosity]'
534 #   '!--silent'
535 #   {-v,--verbose}'[increase output verbosity]'
536 #
537 # Here we take advantage of a useful feature of spec grouping — when the group
538 # name is surrounded by parentheses, as in `(verbosity)`, it tells zsh that all
539 # of the options in that group are exclusive with each other. As a result, we
540 # don't need to manually list out the exclusions at the beginning of each
541 # option.
542 #
543 # Groups can also be referred to by name in other argument specs; for example:
544 #
545 #   '(xyz)--aaa' '*: :_files'
546 #   + xyz --xxx --yyy --zzz
547 #
548 # Here we use the group name `xyz` to tell zsh that `--xxx`, `--yyy`, and
549 # `--zzz` are not to be completed after `--aaa`. This makes the exclusion list
550 # much more compact and reusable.
551 #
552 # CONVENTIONS
553 #
554 # zsh completion functions generally adhere to the following conventions:
555 #
556 # * Use two spaces for indentation
557 # * Combine specs for options with different names using brace expansion
558 # * In combined specs, list the short option first (as in `{-a,--text}`)
559 # * Use `+` or `=` as described above for options that take arguments
560 # * Provide a description for all options, option-arguments, and operands
561 # * Capitalise/punctuate argument descriptions as phrases, not complete
562 #   sentences — 'display help information', never 'Display help information.'
563 #   (but still capitalise acronyms and proper names)
564 # * Write argument descriptions as verb phrases — 'display x', 'enable y',
565 #   'use z'
566 # * Word descriptions to make it clear when an option expects an argument;
567 #   usually this is done with the word 'specify', as in 'specify x' or
568 #   'use specified x')
569 # * Write argument descriptions as tersely as possible — for example, articles
570 #   like 'a' and 'the' should be omitted unless it would be confusing
571 #
572 # Other conventions currently used by this function:
573 #
574 # * Order argument specs alphabetically by group name, then option name
575 # * Group options that are directly related, mutually exclusive, or frequently
576 #   referenced by other argument specs
577 # * Use only characters in the set [a-z0-9_-] in group names
578 # * Order exclusion lists as follows: short options, long options, groups
579 # * Use American English in descriptions
580 # * Use 'don't' in descriptions instead of 'do not'
581 # * Word descriptions for related options as similarly as possible. For example,
582 #   `--foo[enable foo]` and `--no-foo[disable foo]`, or `--foo[use foo]` and
583 #   `--no-foo[don't use foo]`
584 # * Word descriptions to make it clear when an option only makes sense with
585 #   another option, usually by adding '(with -x)' to the end
586 # * Don't quote strings or variables unnecessarily. When quotes are required,
587 #   prefer single-quotes to double-quotes
588 # * Prefix option specs with `$no` when the option serves only to negate the
589 #   behaviour of another option that must be provided explicitly by the user.
590 #   This prevents rarely used options from cluttering up the completion menu
591 ################################################################################
592
593 # ------------------------------------------------------------------------------
594 # Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users
595 # All rights reserved.
596 #
597 # Redistribution and use in source and binary forms, with or without
598 # modification, are permitted provided that the following conditions are met:
599 #     * Redistributions of source code must retain the above copyright
600 #       notice, this list of conditions and the following disclaimer.
601 #     * Redistributions in binary form must reproduce the above copyright
602 #       notice, this list of conditions and the following disclaimer in the
603 #       documentation and/or other materials provided with the distribution.
604 #     * Neither the name of the zsh-users nor the
605 #       names of its contributors may be used to endorse or promote products
606 #       derived from this software without specific prior written permission.
607 #
608 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
609 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
610 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
611 # DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
612 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
613 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
614 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
615 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
616 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
617 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
618 # ------------------------------------------------------------------------------
619 # Description
620 # -----------
621 #
622 #  Completion script for ripgrep
623 #
624 # ------------------------------------------------------------------------------
625 # Authors
626 # -------
627 #
628 #  * arcizan <ghostrevery@gmail.com>
629 #  * MaskRay <i@maskray.me>
630 #
631 # ------------------------------------------------------------------------------
632
633 # Local Variables:
634 # mode: shell-script
635 # coding: utf-8-unix
636 # indent-tabs-mode: nil
637 # sh-indentation: 2
638 # sh-basic-offset: 2
639 # End:
640 # vim: ft=zsh sw=2 ts=2 et