-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
_clang-format
217 lines (203 loc) · 11.8 KB
/
_clang-format
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#compdef clang-format
# -----------------------------------------------------------------------------
#
# Copyright 2016, The zsh-completions Authors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of que nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# -----------------------------------------------------------------------------
#
# clang-format version 14.0.4 (https://github.com/tru/llvm-release-build 686807a176470032c208f27da2cc31b1c10777c6)
#
# https://github.com/llvm/llvm-project/tree/llvmorg-14.0.4/clang/tools/clang-format
#
# -----------------------------------------------------------------------------
_clang-format() {
local context curcontext=$curcontext state line ret=1
declare -A opt_args
local -a _llvm_generic_options
_llvm_generic_options=(
"--help:Display available options"
"--help-hidden:Display all available options"
"--help-list:Display list of available options"
"--help-list-hidden:Display list of all available options"
"--print-all-options:Print all option values after command line parsing"
"--print-options:Print non-default options after command line parsing"
"--version:Display the version of this program"
)
_arguments -C \
"--Wclang-format-violations[Warnings about individual formatting changes needed. Used only with --dry-run or -n]" \
"--Werror[If set, changes formatting warnings to errors]" \
"--Wno-clang-format-violations[Do not warn about individual formatting changes needed. Used only with --dry-run or -n]" \
"--assume-filename=[Override filename used to determine the language. When reading from stdin, clang-format assumes this filename to determine the language.]:filename:_files" \
"--cursor=[The position of the cursor when invoking clang-format from an editor integration]:cursor position" \
{--dry-run,-n}"[If set, do not actually make the formatting changes]" \
"--dump-config[Dump configuration options to stdout and exit. Can be used with -style option.]" \
"--fallback-style=[The name of the predefined style used as a fallback in case clang-format is invoked with -style=file, but can not find the .clang-format file to use.]: :->fallbackstyle" \
"-i[Inplace edit <file>s, if specified.]" \
"--length=[Format a range of this length (in bytes). Multiple ranges can be formatted by specifying several -offset and -length pairs]:length in byte" \
"--lines=[format a range of lines (both 1-based). Multiple ranges can be formatted by specifying several -lines arguments.]: :->lines" \
"--offset=[Format a range starting at this byte offset.Multiple ranges can be formatted by specifying several -offset and -length pairs.]:byte offset" \
"--output-replacements-xml[Output replacements as XML.]" \
"--sort-includes[If set, overrides the include sorting behavior determined by the SortIncludes style flag]" \
"--style=[Coding style. Set coding style or -style=file or set specific parameters]:coding style:->style" \
"--verbose[If set, shows the list of processed files]" \
'*:file:_files' \
&& ret=0
_describe -t llvm_generic_options "LLVM generic options" _llvm_generic_options
local -a __builtin_styles
__builtin_styles=(
"LLVM:LLVM coding standards"
"Google:Google’s C++ style guide"
"Chromium:Chromium’s style guide"
"Mozilla:Mozilla’s style guide"
"WebKit:WebKit’s style guide"
)
case $state in
(style)
local -a __based_on_style
__based_on_style=($__builtin_styles)
__based_on_style+=("file:local .clang-format style")
# TODO(zchee): support -style="{BasedOnStyle: llvm, IndentWidth: 8}"
_describe -t based_on_style "BasedOnStyle" __based_on_style
;;
(fallbackstyle)
local -a __based_on_style_fallback
__based_on_style_fallback=($__builtin_styles)
__based_on_style_fallback+=("none:skip formatting")
# TODO(zchee): support -style="{BasedOnStyle: llvm, IndentWidth: 8}"
_describe -t based_on_style "BasedOnStyleFallback" __based_on_style_fallback
;;
(lines)
if ! compset -P "*:"; then
_arguments "*:start line"
else
_arguments "*:end line"
fi
;;
esac
return ret
}
_clang-format "$@"
# -----------------------------------------------------------------------------
#
# OVERVIEW: A tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
#
# If no arguments are specified, it formats the code from standard input
# and writes the result to the standard output.
# If <file>s are given, it reformats the files. If -i is specified
# together with <file>s, the files are edited in-place. Otherwise, the
# result is written to the standard output.
#
# USAGE: clang-format [options] [<file> ...]
#
# OPTIONS:
#
# Clang-format options:
#
# --Wclang-format-violations - Warnings about individual formatting changes needed. Used only with --dry-run or -n
# --Werror - If set, changes formatting warnings to errors
# --Wno-clang-format-violations - Do not warn about individual formatting changes needed. Used only with --dry-run or -n
# --Wno-error=<value> - If set don't error out on the specified warning type.
# =unknown - If set, unknown format options are only warned about.
# This can be used to enable formatting, even if the
# configuration contains unknown (newer) options.
# Use with caution, as this might lead to dramatically
# differing format depending on an option being
# supported or not.
# --assume-filename=<string> - Override filename used to determine the language.
# When reading from stdin, clang-format assumes this
# filename to determine the language.
# --cursor=<uint> - The position of the cursor when invoking
# clang-format from an editor integration
# --dry-run - If set, do not actually make the formatting changes
# --dump-config - Dump configuration options to stdout and exit.
# Can be used with -style option.
# --fallback-style=<string> - The name of the predefined style used as a
# fallback in case clang-format is invoked with
# -style=file, but can not find the .clang-format
# file to use.
# Use -fallback-style=none to skip formatting.
# --fcolor-diagnostics - If set, and on a color-capable terminal controls whether or not to print diagnostics in color
# --ferror-limit=<uint> - Set the maximum number of clang-format errors to emit before stopping (0 = no limit). Used only with --dry-run or -n
# --files=<string> - Provide a list of files to run clang-format
# --fno-color-diagnostics - If set, and on a color-capable terminal controls whether or not to print diagnostics in color
# -i - Inplace edit <file>s, if specified.
# --length=<uint> - Format a range of this length (in bytes).
# Multiple ranges can be formatted by specifying
# several -offset and -length pairs.
# When only a single -offset is specified without
# -length, clang-format will format up to the end
# of the file.
# Can only be used with one input file.
# --lines=<string> - <start line>:<end line> - format a range of
# lines (both 1-based).
# Multiple ranges can be formatted by specifying
# several -lines arguments.
# Can't be used with -offset and -length.
# Can only be used with one input file.
# -n - Alias for --dry-run
# --offset=<uint> - Format a range starting at this byte offset.
# Multiple ranges can be formatted by specifying
# several -offset and -length pairs.
# Can only be used with one input file.
# --output-replacements-xml - Output replacements as XML.
# --qualifier-alignment=<string> - If set, overrides the qualifier alignment style determined by the QualifierAlignment style flag
# --sort-includes - If set, overrides the include sorting behavior determined by the SortIncludes style flag
# --style=<string> - Coding style, currently supports:
# LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit.
# Use -style=file to load style configuration from
# .clang-format file located in one of the parent
# directories of the source file (or current
# directory for stdin).
# Use -style=file:<format_file_path> to explicitly specifythe configuration file.
# Use -style="{key: value, ...}" to set specific
# parameters, e.g.:
# -style="{BasedOnStyle: llvm, IndentWidth: 8}"
# --verbose - If set, shows the list of processed files
#
# Color Options:
#
# This option category has no options.
#
# General options:
#
# This option category has no options.
#
# Generic Options:
#
# --help - Display available options (--help-hidden for more)
# --help-hidden - Display all available options
# --help-list - Display list of available options (--help-list-hidden for more)
# --help-list-hidden - Display list of all available options
# --print-all-options - Print all option values after command line parsing
# --print-options - Print non-default options after command line parsing
# --version - Display the version of this program
#
# -----------------------------------------------------------------------------
# vim:ft=zsh:et:sts=2:sw=2