/
_clangd
358 lines (341 loc) · 21.4 KB
/
_clangd
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
#compdef clangd
# -----------------------------------------------------------------------------
#
# Copyright 2023, 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.
#
# -----------------------------------------------------------------------------
#
# clangd version 18.0.0 (https://github.com/llvm/llvm-project aac8acb11551225b6a8083102e828154e3e76e47)
# Features: mac+grpc+xpc
# Platform: x86_64-apple-darwin22.6.0#
#
# https://github.com/clangd/clangd/releases/tag/snapshot_20230806
#
# -----------------------------------------------------------------------------
function _clangd() {
local context curcontext=$curcontext state line expl ret=1
declare -A opt_args
local -a _llvm_generic_options
_llvm_generic_options=(
"(: -h --help)"{-h,--help}"[Display available options]"
"(: --help-hidden)--help-hidden[Display all available options]"
"(: --help-list)--help-list[Display list of available options]"
"(: --help-list-hidden)--help-list-hidden[Display list of all available options]"
"(: --print-all-options)--print-all-options[Print all option values after command line parsing]"
"(: --print-options)--print-options[Print non-default options after command line parsing]"
"(: --version)--version[Display the version of this program]"
)
_arguments -C \
"--compile-commands-dir=[Specify a path to look for compile_commands.json. If path is invalid, clangd will look in the current directory and parent paths of each source file]:compile_commands.json directory:_directories" \
"--compile_args_from=[The source of compile commands]:compile args source:->compile_args_from" \
"--query-driver=[Comma separated list of globs for white-listing gcc-compatible drivers that are safe to execute. Drivers matching any of these globs will be used to extract system includes.]:driver:_command_names" \
"--resource-dir=[Directory for system clang headers]:resource directory path:_directories" \
\
"--all-scopes-completion[If set to true, code completion will include index symbols that are not defined in the scopes (e.g. namespaces) visible from the code completion point.]" \
"--background-index[Index project code in the background and persist index on disk. Experimental]" \
"--background-index-priority=[Thread priority for building the background index. The effect of this flag is OS-specific.]:thread priority:->background_index_priority" \
"--clang-tidy[Enable clang-tidy diagnostics.]" \
"--completion-parse=[Whether the clang-parser is used for code-completion]:clang-parser:->clang-parser" \
"--completion-style=[Granularity of code completion suggestions]:completion style:->completion-style" \
"--debug-origin[Show origins of completion items]" \
"--fallback-style=[clang-format style to apply by default when no .clang-format file is found]:style" \
"--function-arg-placeholders[When disabled, completions contain only parentheses for function calls. When enabled, completions also contain placeholders for method parameters.]" \
"--header-insertion=[Add #include directives when accepting code completions]:header-insertion:->header-insertion" \
"--header-insertion-decorators[Prepend a circular dot or space before the completion label, depending on whether an include line will be inserted or not.]" \
"--hidden-features[Enable hidden features mostly useful to clangd developers]" \
"--import-insertions[If header insertion is enabled, add #import directives when accepting code completions or fixing includes in Objective-C code]" \
"--include-ineligible-results[Include ineligible completion results (e.g. private members)]" \
"--limit-references=[Limit the number of references returned by clangd. 0 means no limit (default=1000)]:references limit" \
"--limit-results=[Limit the number of results returned by clangd. 0 means no limit.]:result limit" \
"--project-root=[Path to the project root. Requires remote-index-address to be set.]" \
"--ranking-model=[Model to use to rank code-completion items]:->ranking-model" \
"--remote-index-address=[Address of the remote index server]:index server address" \
"--rename-file-limit=[Limit the number of files to be affected by symbol renaming. 0 means no limit (default=50)]:limit of files" \
"--tweaks=[Specify a list of Tweaks to enable (only for clangd developers).]:tweaks" \
\
"--check=[Parse one file in isolation instead of acting as a language server.]:file:_files" \
"--crash-pragmas[Respect \`#pragma clang __debug crash\` and friends.]" \
"--enable-config[Read user and project configuration from YAML files.]" \
"--index-file=[Index file to build the static index. The file must have been created by a compatible clangd-indexer]:index file:_files" \
"-j=[Number of async workers used by clangd]:number of async worker" \
"--lit-test[Abbreviation for -input-style=delimited -pretty -run-synchronously -enable-test-scheme. Intended to simplify lit tests.]" \
"--parse-forwarding-functions[Parse all emplace-like functions in included headers]" \
"--pch-storage=[Storing PCHs in memory increases memory usages, but may improve performance]:pch storage type:->pch-storage" \
"--sync[Parse on main thread. If set, -j is ignored]" \
"--use-dirty-headers[Use files open in the editor when parsing headers instead of reading from the disk]" \
\
"--enable-test-uri-scheme[Enable 'test:' URI scheme. Only use in lit tests.]" \
"--input-mirror-file=[Mirror all LSP input to the specified file. Useful for debugging.]:input mirror file path:_files" \
"--input-style=[Input JSON stream encoding]:input style:->input-style" \
"--log=[Verbosity of log messages written to stderr]:log level:->log" \
"--offset-encoding=[Force the offsetEncoding used for character positions. This bypasses negotiation via client capabilities.]:encoding:->offset-encoding" \
"--path-mappings=[Translates between client paths (as seen by a remote editor) and server paths (where clangd sees files on disk).]:path mappings" \
"--pretty[Pretty-print JSON output]" \
\
$_llvm_generic_options \
\
&& ret=0
case $state in
compile_args_from)
local -a compile_args_from_args
compile_args_from_args=(
"lsp:All compile commands come from LSP and 'compile_commands.json' files are ignored"
"filesystem:All compile commands come from the 'compile_commands.json' files"
)
_arguments \
"*: :{_describe 'compile args source' compile_args_from_args}"
;;
background_index_priority)
local -a background_index_priority_args
background_index_priority_args=(
"background:Minimum priority, runs on idle CPUs. May leave 'performance' cores unused."
"low:Reduced priority compared to interactive work."
"normal:Same priority as other clangd work."
)
_arguments \
"*: :{_describe 'background index priority' background_index_priority_args}"
;;
completion-style)
local -a completion_style_args
completion_style_args=(
"detailed:One completion item for each semantically distinct completion, with full type information."
"bundled:Similar completion items (e.g. function overloads) are combined. Type information shown where possible."
)
_arguments \
"*: :{_describe 'completion style' completion_style_args}"
;;
clang-parser)
local -a clang_parser_args
clang_parser_args=(
"always:Block until the parser can be used"
"auto:Use text-based completion if the parser is not ready"
"never:Always used text-based completion"
)
_arguments \
"*: :{_describe 'clang-parser style' clang_parser_args}"
;;
header-insertion)
local -a header_insertion_args
header_insertion_args=(
"iwyu:Include what you use. Insert the owning header for top-level symbols, unless the header is already directly included or the symbol is forward-declared"
"never:Never insert #include directives as part of code completion"
)
_arguments \
"*: :{_describe 'header insertion' header_insertion_args}"
;;
ranking-model)
local -a ranking_model_args
ranking_model_args=(
"heuristics:Use hueristics to rank code completion items"
"decision_forest:Use Decision Forest model to rank completion items"
)
_arguments \
"*: :{_describe 'ranking model' ranking_model_args}"
;;
input-style)
local -a input_style_args
input_style_args=(
"standard:usual LSP protocol"
"delimited:messages delimited by --- lines, with \# comment support"
)
_arguments \
"*: :{_describe 'input style' input_style_args}"
;;
log)
local -a log_args
log_args=(
"error:Error messages only"
"info:High level execution tracing"
"verbose:Low level details"
)
_arguments \
"*: :{_describe 'log level' log_args}"
;;
offset-encoding)
local -a offset_encoding_args
offset_encoding_args=(
"utf-8:Offsets are in UTF-8 bytes"
"utf-16:Offsets are in UTF-16 code units"
)
_arguments \
"*: :{_describe 'offset oncoding' offset_encoding_args}"
;;
pch-storage)
local -a pch_storage_args
pch_storage_args=(
"disk:store PCHs on disk"
"memory:store PCHs in memory"
)
_arguments \
"*: :{_describe 'pch storage type' pch_storage_args}"
;;
esac
return ret
}
_clangd "$*"
# -----------------------------------------------------------------------------
#
# generate alldoc comment:
# $ clangd --help-hidden
#
# ------------------------------------------------------------------------------
#
# OVERVIEW: clangd is a language server that provides IDE-like features to editors.
#
# It should be used via an editor plugin rather than invoked directly. For more information, see:
# https://clangd.llvm.org/
# https://microsoft.github.io/language-server-protocol/
#
# clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment variable.
#
# USAGE: clangd [options]
#
# OPTIONS:
#
# Color Options:
#
# This option category has no options.
#
# General options:
#
# This option category has no options.
#
# Generic Options:
#
# -h - Alias for --help
# --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
#
# clangd compilation flags options:
#
# --compile-commands-dir=<string> - Specify a path to look for compile_commands.json. If path is invalid, clangd will look in the current directory and parent paths of each source file
# --compile_args_from=<value> - The source of compile commands
# =lsp - All compile commands come from LSP and 'compile_commands.json' files are ignored
# =filesystem - All compile commands come from the 'compile_commands.json' files
# --query-driver=<string> - Comma separated list of globs for white-listing gcc-compatible drivers that are safe to execute. Drivers matching any of these globs will be used to extract system includes. e.g. /usr/bin/**/clang-*,/path/to/repo/**/g++-*
# --resource-dir=<string> - Directory for system clang headers
#
# clangd feature options:
#
# --all-scopes-completion - If set to true, code completion will include index symbols that are not defined in the scopes (e.g. namespaces) visible from the code completion point. Such completions can insert scope qualifiers
# --background-index - Index project code in the background and persist index on disk.
# --background-index-priority=<value> - Thread priority for building the background index. The effect of this flag is OS-specific.
# =background - Minimum priority, runs on idle CPUs. May leave 'performance' cores unused.
# =low - Reduced priority compared to interactive work.
# =normal - Same priority as other clangd work.
# --clang-tidy - Enable clang-tidy diagnostics
# --completion-parse=<value> - Whether the clang-parser is used for code-completion
# =always - Block until the parser can be used
# =auto - Use text-based completion if the parser is not ready
# =never - Always used text-based completion
# --completion-style=<value> - Granularity of code completion suggestions
# =detailed - One completion item for each semantically distinct completion, with full type information
# =bundled - Similar completion items (e.g. function overloads) are combined. Type information shown where possible
# --debug-origin - Show origins of completion items
# --fallback-style=<string> - clang-format style to apply by default when no .clang-format file is found
# --function-arg-placeholders - When disabled, completions contain only parentheses for function calls. When enabled, completions also contain placeholders for method parameters
# --header-insertion=<value> - Add #include directives when accepting code completions
# =iwyu - Include what you use. Insert the owning header for top-level symbols, unless the header is already directly included or the symbol is forward-declared
# =never - Never insert #include directives as part of code completion
# --header-insertion-decorators - Prepend a circular dot or space before the completion label, depending on whether an include line will be inserted or not
# --hidden-features - Enable hidden features mostly useful to clangd developers
# --import-insertions - If header insertion is enabled, add #import directives when accepting code completions or fixing includes in Objective-C code
# --include-ineligible-results - Include ineligible completion results (e.g. private members)
# --limit-references=<int> - Limit the number of references returned by clangd. 0 means no limit (default=1000)
# --limit-results=<int> - Limit the number of results returned by clangd. 0 means no limit (default=100)
# --project-root=<string> - Path to the project root. Requires remote-index-address to be set.
# --ranking-model=<value> - Model to use to rank code-completion items
# =heuristics - Use heuristics to rank code completion items
# =decision_forest - Use Decision Forest model to rank completion items
# --remote-index-address=<string> - Address of the remote index server
# --rename-file-limit=<int> - Limit the number of files to be affected by symbol renaming. 0 means no limit (default=50)
# --tweaks=<string> - Specify a list of Tweaks to enable (only for clangd developers).
#
# clangd flags no longer in use:
#
# --async-preamble - Obsolete flag, ignored
# --clang-tidy-checks=<string> - Obsolete flag, ignored
# --collect-main-file-refs - Obsolete flag, ignored
# --cross-file-rename - Obsolete flag, ignored
# --folding-ranges - Obsolete flag, ignored
# --include-cleaner-stdlib - Obsolete flag, ignored
# --index - Obsolete flag, ignored
# --inlay-hints - Obsolete flag, ignored
# --recovery-ast - Obsolete flag, ignored
# --recovery-ast-type - Obsolete flag, ignored
# --suggest-missing-includes - Obsolete flag, ignored
#
# clangd miscellaneous options:
#
# --check[=<string>] - Parse one file in isolation instead of acting as a language server. Useful to investigate/reproduce crashes or configuration problems. With --check=<filename>, attempts to parse a particular file.
# --crash-pragmas - Respect `#pragma clang __debug crash` and friends.
# --enable-config - Read user and project configuration from YAML files.
# Project config is from a .clangd file in the project directory.
# User config is from clangd/config.yaml in the following directories:
# Windows: %USERPROFILE%\AppData\Local
# Mac OS: ~/Library/Preferences/
# Others: $XDG_CONFIG_HOME, usually ~/.config
# Configuration is documented at https://clangd.llvm.org/config.html
# --index-file=<string> - Index file to build the static index. The file must have been created by a compatible clangd-indexer
# WARNING: This option is experimental only, and will be removed eventually. Don't rely on it
# -j <uint> - Number of async workers used by clangd. Background index also uses this many workers.
# --lit-test - Abbreviation for -input-style=delimited -pretty -sync -enable-test-scheme -enable-config=0 -log=verbose -crash-pragmas. Also sets config options: Index.StandardLibrary=false. Intended to simplify lit tests
# --parse-forwarding-functions - Parse all emplace-like functions in included headers
# --pch-storage=<value> - Storing PCHs in memory increases memory usages, but may improve performance
# =disk - store PCHs on disk
# =memory - store PCHs in memory
# --sync - Handle client requests on main thread. Background index still uses its own thread.
# --use-dirty-headers - Use files open in the editor when parsing headers instead of reading from the disk
#
# clangd protocol and logging options:
#
# --enable-test-uri-scheme - Enable 'test:' URI scheme. Only use in lit tests
# --input-mirror-file=<string> - Mirror all LSP input to the specified file. Useful for debugging
# --input-style=<value> - Input JSON stream encoding
# =standard - usual LSP protocol
# =delimited - messages delimited by --- lines, with # comment support
# --log=<value> - Verbosity of log messages written to stderr
# =error - Error messages only
# =info - High level execution tracing
# =verbose - Low level details
# --offset-encoding=<value> - Force the offsetEncoding used for character positions. This bypasses negotiation via client capabilities
# =utf-8 - Offsets are in UTF-8 bytes
# =utf-16 - Offsets are in UTF-16 code units
# =utf-32 - Offsets are in unicode codepoints
# --path-mappings=<string> - Translates between client paths (as seen by a remote editor) and server paths (where clangd sees files on disk). Comma separated list of '<client_path>=<server_path>' pairs, the first entry matching a given path is used. e.g. /home/project/incl=/opt/include,/home/project=/workarea/project
# --pretty - Pretty-print JSON output
#
# ------------------------------------------------------------------------------
# vim:ft=zsh:et:sts=2:sw=2