9538eae3d732f6c1e59136f0fb2dce7f98a129a1
- Author
- Jonathan <jonathan.klimt@rwth-aachen.de>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/ripgrep/README.md b/plugins/ripgrep/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..794b105eef107d71855a4d3a906c8fd7970cb301
4--- /dev/null
5+++ b/plugins/ripgrep/README.md
6@@ -0,0 +1,13 @@
7+# ripgrep
8+
9+This plugin adds completion for the text search tool [`ripgrep`](https://github.com/BurntSushi/ripgrep), also known as `rg`.
10+
11+To use it, add `ripgrep` to the plugins array in your zshrc file:
12+
13+```zsh
14+plugins=(... ripgrep)
15+```
16+
17+Completion is taken from the ripgrep release [`0.10.0`](https://github.com/BurntSushi/ripgrep/releases/tag/0.10.0).
18+
19+Updated on September 27th, 2018.
20diff --git a/plugins/ripgrep/_ripgrep b/plugins/ripgrep/_ripgrep
21new file mode 100644
22index 0000000000000000000000000000000000000000..53f135dde9fda080dee3766e05a7ffb974d885ce
23--- /dev/null
24+++ b/plugins/ripgrep/_ripgrep
25@@ -0,0 +1,433 @@
26+#compdef rg
27+
28+##
29+# zsh completion function for ripgrep
30+#
31+# Originally based on code from the zsh-users project — see copyright notice
32+# below.
33+
34+_rg() {
35+ local curcontext=$curcontext no='!' descr ret=1
36+ local -a context line state state_descr args tmp suf
37+ local -A opt_args
38+
39+ # ripgrep has many options which negate the effect of a more common one — for
40+ # example, `--no-column` to negate `--column`, and `--messages` to negate
41+ # `--no-messages`. There are so many of these, and they're so infrequently
42+ # used, that some users will probably find it irritating if they're completed
43+ # indiscriminately, so let's not do that unless either the current prefix
44+ # matches one of those negation options or the user has the `complete-all`
45+ # style set. Note that this prefix check has to be updated manually to account
46+ # for all of the potential negation options listed below!
47+ if
48+ # We also want to list all of these options during testing
49+ [[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] ||
50+ # (--[imnp]* => --ignore*, --messages, --no-*, --pcre2-unicode)
51+ [[ $PREFIX$SUFFIX == --[imnp]* ]] ||
52+ zstyle -t ":complete:$curcontext:*" complete-all
53+ then
54+ no=
55+ fi
56+
57+ # We make heavy use of argument groups here to prevent the option specs from
58+ # growing unwieldy. These aren't supported in zsh <5.4, though, so we'll strip
59+ # them out below if necessary. This makes the exclusions inaccurate on those
60+ # older versions, but oh well — it's not that big a deal
61+ args=(
62+ + '(exclusive)' # Misc. fully exclusive options
63+ '(: * -)'{-h,--help}'[display help information]'
64+ '(: * -)'{-V,--version}'[display version information]'
65+
66+ + '(buffered)' # buffering options
67+ '--line-buffered[force line buffering]'
68+ $no"--no-line-buffered[don't force line buffering]"
69+ '--block-buffered[force block buffering]'
70+ $no"--no-block-buffered[don't force block buffering]"
71+
72+ + '(case)' # Case-sensitivity options
73+ {-i,--ignore-case}'[search case-insensitively]'
74+ {-s,--case-sensitive}'[search case-sensitively]'
75+ {-S,--smart-case}'[search case-insensitively if pattern is all lowercase]'
76+
77+ + '(context-a)' # Context (after) options
78+ '(context-c)'{-A+,--after-context=}'[specify lines to show after each match]:number of lines'
79+
80+ + '(context-b)' # Context (before) options
81+ '(context-c)'{-B+,--before-context=}'[specify lines to show before each match]:number of lines'
82+
83+ + '(context-c)' # Context (combined) options
84+ '(context-a context-b)'{-C+,--context=}'[specify lines to show before and after each match]:number of lines'
85+
86+ + '(column)' # Column options
87+ '--column[show column numbers for matches]'
88+ $no"--no-column[don't show column numbers for matches]"
89+
90+ + '(count)' # Counting options
91+ {-c,--count}'[only show count of matching lines for each file]'
92+ '--count-matches[only show count of individual matches for each file]'
93+
94+ + '(encoding)' # Encoding options
95+ {-E+,--encoding=}'[specify text encoding of files to search]: :_rg_encodings'
96+ $no'--no-encoding[use default text encoding]'
97+
98+ + file # File-input options
99+ '(1)*'{-f+,--file=}'[specify file containing patterns to search for]: :_files'
100+
101+ + '(file-match)' # Files with/without match options
102+ '(stats)'{-l,--files-with-matches}'[only show names of files with matches]'
103+ '(stats)--files-without-match[only show names of files without matches]'
104+
105+ + '(file-name)' # File-name options
106+ {-H,--with-filename}'[show file name for matches]'
107+ "--no-filename[don't show file name for matches]"
108+
109+ + '(file-system)' # File system options
110+ "--one-file-system[don't descend into directories on other file systems]"
111+ $no'--no-one-file-system[descend into directories on other file systems]'
112+
113+ + '(fixed)' # Fixed-string options
114+ {-F,--fixed-strings}'[treat pattern as literal string instead of regular expression]'
115+ $no"--no-fixed-strings[don't treat pattern as literal string]"
116+
117+ + '(follow)' # Symlink-following options
118+ {-L,--follow}'[follow symlinks]'
119+ $no"--no-follow[don't follow symlinks]"
120+
121+ + glob # File-glob options
122+ '*'{-g+,--glob=}'[include/exclude files matching specified glob]:glob'
123+ '*--iglob=[include/exclude files matching specified case-insensitive glob]:glob'
124+