]> git.madduck.net Git - etc/vim.git/blob - doc/ale-c.txt

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / doc / ale-c.txt
1 ===============================================================================
2 ALE C Integration                                               *ale-c-options*
3
4 For basic checking of problems with C files, ALE offers the `cc` linter, which
5 runs either `clang`, or `gcc`. See |ale-c-cc|.
6
7
8 ===============================================================================
9 Global Options
10                                                     *ale-options.c_always_make*
11                                                           *g:ale_c_always_make*
12                                                           *b:ale_c_always_make*
13 c_always_make
14 g:ale_c_always_make
15   Type: |Number|
16   Default: `has('unix') && !has('macunix')`
17
18   If set to `1`, use `--always-make` for `make`, which means that output will
19   always be parsed from `make` dry runs with GNU make. BSD `make` does not
20   support this option, so you probably want to turn this option off when using
21   a BSD variant.
22
23                                                 *ale-options.c_build_dir_names*
24                                                       *g:ale_c_build_dir_names*
25                                                       *b:ale_c_build_dir_names*
26 c_build_dir_names
27 g:ale_c_build_dir_names
28   Type: |List|
29   Default: `['build', 'bin']`
30
31   A list of directory names to be used when searching upwards from C files
32   to discover compilation databases with. For directory named `'foo'`, ALE
33   will search for `'foo/compile_commands.json'` in all directories on and
34   above the directory containing the C file to find path to compilation
35   database.  This feature is useful for the clang tools wrapped around
36   LibTooling (namely here, clang-tidy)
37
38                                                       *ale-options.c_build_dir*
39                                                             *g:ale_c_build_dir*
40                                                             *b:ale_c_build_dir*
41 c_build_dir
42 g:ale_c_build_dir
43   Type: |String|
44   Default: `''`
45
46   For programs that can read `compile_commands.json` files, this option can be
47   set to the directory containing the file for the project. ALE will try to
48   determine the location of `compile_commands.json` automatically, but if your
49   file exists in some other directory, you can set this option so ALE will
50   know where it is.
51
52   This directory will be searched instead of |g:ale_c_build_dir_names|.
53
54                                          *ale-options.c_parse_compile_commands*
55                                                *g:ale_c_parse_compile_commands*
56                                                *b:ale_c_parse_compile_commands*
57 c_parse_compile_commands
58 g:ale_c_parse_compile_commands
59   Type: |Number|
60   Default: `1`
61
62   If set to `1`, ALE will parse `compile_commands.json` files to automatically
63   determine flags for C or C++ compilers. ALE will first search for the
64   nearest `compile_commands.json` file, and then look for
65   `compile_commands.json` files in the directories for
66   |g:ale_c_build_dir_names|.
67
68                                                  *ale-options.c_parse_makefile*
69                                                        *g:ale_c_parse_makefile*
70                                                        *b:ale_c_parse_makefile*
71 c_parse_makefile
72 g:ale_c_parse_makefile
73   Type: |Number|
74   Default: `0`
75
76   If set to `1`, ALE will run `make -n` to automatically determine flags to
77   set for C or C++ compilers. This can make it easier to determine the correct
78   build flags to use for different files.
79
80   NOTE: When using this option on BSD, you may need to set
81   |g:ale_c_always_make| to `0`, and `make -n` will not provide consistent
82   results if binaries have already been built, so use `make clean` when
83   editing your files.
84
85   WARNING: Running `make -n` automatically can execute arbitrary code, even
86   though it's supposed to be a dry run, so enable this option with care. You
87   might prefer to use the buffer-local version of the option instead with
88   |g:ale_pattern_options|, or you own code for checking which project you're
89   in.
90
91   You might want to disable this option if `make -n` takes too long to run for
92   projects you work on.
93
94   If |g:ale_c_parse_compile_commands| or |b:ale_c_parse_compile_commands| is
95   set to `1`, flags taken from `compile_commands.json` will be preferred over
96   `make -n` output.
97
98
99 ===============================================================================
100 astyle                                                           *ale-c-astyle*
101
102                                               *ale-options.c_astyle_executable*
103                                                     *g:ale_c_astyle_executable*
104                                                     *b:ale_c_astyle_executable*
105 c_astyle_executable
106 g:ale_c_astyle_executable
107   Type: |String|
108   Default: `'astyle'`
109
110   This variable can be changed to use a different executable for astyle.
111
112                                          *ale-options.c_astyle_project_options*
113                                                *g:ale_c_astyle_project_options*
114                                                *b:ale_c_astyle_project_options*
115 c_astyle_project_options
116 g:ale_c_astyle_project_options
117   Type: |String|
118   Default: `''`
119
120   This variable can be changed to use an option file for project level
121   configurations. Provide only the filename of the option file that should be
122   present at the project's root directory.
123
124   For example, if .astylrc is specified, the file is searched in the parent
125   directories of the source file's directory.
126
127
128 ===============================================================================
129 cc                                                                   *ale-c-cc*
130                                                                     *ale-c-gcc*
131                                                                   *ale-c-clang*
132
133                                                   *ale-options.c_cc_executable*
134                                                         *g:ale_c_cc_executable*
135                                                         *b:ale_c_cc_executable*
136 c_cc_executable
137 g:ale_c_cc_executable
138   Type: |String|
139   Default: `'<auto>'`
140
141   This variable can be changed to use a different executable for a C compiler.
142
143   ALE will try to use `clang` if Clang is available, otherwise ALE will
144   default to checking C code with `gcc`.
145
146                                                      *ale-options.c_cc_options*
147                                                            *g:ale_c_cc_options*
148                                                            *b:ale_c_cc_options*
149 c_cc_options
150 g:ale_c_cc_options
151   Type: |String|
152   Default: `'-std=c11 -Wall'`
153
154   This variable can be changed to modify flags given to the C compiler.
155
156                                         *ale-options.c_cc_use_header_lang_flag*
157                                               *g:ale_c_cc_use_header_lang_flag*
158                                               *b:ale_c_cc_use_header_lang_flag*
159 c_cc_use_header_lang_flag
160 g:ale_c_cc_use_header_lang_flag
161   Type: |Number|
162   Default: `-1`
163
164   By default, ALE will use `'-x c-header'` instead of `'-x c'` for header files
165   when using Clang.
166
167   This variable can be changed to manually activate or deactivate this flag
168   for header files.
169
170   - When set to `-1`, the default beviour is used, `'-x c-header'` is used with
171     Clang and `'-x c'` is used with other compilers.
172   - When set to `0`, the flag is deactivated, `'-x c'` is always used
173     independently of the compiler.
174   - When set to `1`, the flag is activated, `'-x c-header'` is always used
175     independently of the compiler.
176
177   Gcc does not support `'-x c-header'` when using `'-'` as input filename,
178   which is what ALE does. This why, by default, ALE only uses `'-x c-header'`
179   with Clang.
180
181                                                  *ale-options.c_cc_header_exts*
182                                                        *g:ale_c_cc_header_exts*
183                                                        *b:ale_c_cc_header_exts*
184 c_cc_header_exts
185 g:ale_c_cc_header_exts
186   Type: |List|
187   Default: `['h']`
188
189   This variable can be changed to modify the list of extensions of the files
190   considered as header files.
191
192   This variable is only used when `'-x c-header'` is used instead of `'-x c'`,
193   see |g:ale_c_cc_use_header_lang_flag|.
194
195
196 ===============================================================================
197 ccls                                                               *ale-c-ccls*
198
199                                                 *ale-options.c_ccls_executable*
200                                                       *g:ale_c_ccls_executable*
201                                                       *b:ale_c_ccls_executable*
202 c_ccls_executable
203 g:ale_c_ccls_executable
204   Type: |String|
205   Default: `'ccls'`
206
207   This variable can be changed to use a different executable for ccls.
208
209                                               *ale-options.c_ccls_init_options*
210                                                     *g:ale_c_ccls_init_options*
211                                                     *b:ale_c_ccls_init_options*
212 c_ccls_init_options
213 g:ale_c_ccls_init_options
214   Type: |Dictionary|
215   Default: `{}`
216
217   This variable can be changed to customize ccls initialization options.
218   For example: >
219
220   let g:ale_c_ccls_init_options = {
221   \   'cacheDirectory': '/tmp/ccls',
222   \   'cacheFormat': 'binary',
223   \   'diagnostics': {
224   \       'onOpen': 0,
225   \       'opChange': 1000,
226   \   },
227   \}
228 <
229   For all available options and explanations, visit
230   https://github.com/MaskRay/ccls/wiki/Customization#initialization-options.
231
232
233 ===============================================================================
234 clangcheck                                                   *ale-c-clangcheck*
235
236 `clang-check` will be run only when files are saved to disk, so that
237 `compile_commands.json` files can be used. It is recommended to use this
238 linter in combination with `compile_commands.json` files.
239 Therefore, `clang-check` linter reads the options |g:ale_c_build_dir| and
240 |g:ale_c_build_dir_names|. Also, setting |g:ale_c_build_dir| actually
241 overrides |g:ale_c_build_dir_names|.
242
243
244 -------------------------------------------------------------------------------
245 Options
246                                           *ale-options.c_clangcheck_executable*
247                                                 *g:ale_c_clangcheck_executable*
248                                                 *b:ale_c_clangcheck_executable*
249 c_clangcheck_executable
250 g:ale_c_clangcheck_executable
251   Type: |String|
252   Default: `'clang-check'`
253
254   This variable can be changed to use a different executable for clangcheck.
255
256                                              *ale-options.c_clangcheck_options*
257                                                    *g:ale_c_clangcheck_options*
258                                                    *b:ale_c_clangcheck_options*
259 c_clangcheck_options
260 g:ale_c_clangcheck_options
261   Type: |String|
262   Default: `''`
263
264   This variable can be changed to modify flags given to clang-check.
265
266   This variable should not be set to point to build subdirectory with
267   `-p path/to/build` option, as it is handled by the |g:ale_c_build_dir|
268   option.
269
270
271 ===============================================================================
272 clangd                                                           *ale-c-clangd*
273
274                                               *ale-options.c_clangd_executable*
275                                                     *g:ale_c_clangd_executable*
276                                                     *b:ale_c_clangd_executable*
277 c_clangd_executable
278 g:ale_c_clangd_executable
279   Type: |String|
280   Default: `'clangd'`
281
282   This variable can be changed to use a different executable for clangd.
283
284                                                  *ale-options.c_clangd_options*
285                                                        *g:ale_c_clangd_options*
286                                                        *b:ale_c_clangd_options*
287 c_clangd_options
288 g:ale_c_clangd_options
289   Type: |String|
290   Default: `''`
291
292   This variable can be changed to modify flags given to clangd.
293
294
295 ===============================================================================
296 clang-format                                                *ale-c-clangformat*
297
298                                          *ale-options.c_clangformat_executable*
299                                                *g:ale_c_clangformat_executable*
300                                                *b:ale_c_clangformat_executable*
301 c_clangformat_executable
302 g:ale_c_clangformat_executable
303   Type: |String|
304   Default: `'clang-format'`
305
306   This variable can be changed to use a different executable for clang-format.
307
308                                             *ale-options.c_clangformat_options*
309                                                   *g:ale_c_clangformat_options*
310                                                   *b:ale_c_clangformat_options*
311 c_clangformat_options
312 g:ale_c_clangformat_options
313   Type: |String|
314   Default: `''`
315
316   This variable can be changed to modify flags given to clang-format.
317
318                                        *ale-options.c_clangformat_style_option*
319                                              *g:ale_c_clangformat_style_option*
320                                              *b:ale_c_clangformat_style_option*
321 c_clangformat_style_option
322 g:ale_c_clangformat_style_option
323   Type: |String|
324   Default: `''`
325
326   This variable can be changed to modify only the style flag given to
327   clang-format. The contents of the variable are passed directly to the -style
328   flag of clang-format.
329
330   Example: >
331   let g:ale_c_clangformat_style_option = {
332   \   'BasedOnStyle': 'Microsoft',
333   \   'ColumnLimit': 80,
334   \   'AllowShortBlocksOnASingleLine': 'Always',
335   \   'AllowShortFunctionsOnASingleLine': 'Inline',
336   \}
337 <
338   If you set this variable, ensure you don't modify -style in
339   |g:ale_c_clangformat_options|, as this will cause clang-format to error.
340
341                                      *ale-options.c_clangformat_use_local_file*
342                                            *g:ale_c_clangformat_use_local_file*
343                                            *b:ale_c_clangformat_use_local_file*
344 c_clangformat_use_local_file
345 g:ale_c_clangformat_use_local_file
346   Type: |Number|
347   Default: `0`
348
349   This variable can be changed to modify whether to use a local .clang-format
350   file. If the file is found, the flag '-style=file' is passed to clang-format
351   and any options configured via |g:ale_c_clangformat_style_option| are not
352   passed.
353
354   If this option is enabled but no .clang-format file is found, default back to
355   |g:ale_c_clangformat_style_option|, if it set.
356
357   If you set this variable, ensure you don't modify -style in
358   |g:ale_c_clangformat_options|, as this will cause clang-format to error.
359
360
361 ===============================================================================
362 clangtidy                                                     *ale-c-clangtidy*
363
364 `clang-tidy` will be run only when files are saved to disk, so that
365 `compile_commands.json` files can be used. It is recommended to use this
366 linter in combination with `compile_commands.json` files.
367 Therefore, `clang-tidy` linter reads the options |g:ale_c_build_dir| and
368 |g:ale_c_build_dir_names|. Also, setting |g:ale_c_build_dir| actually
369 overrides |g:ale_c_build_dir_names|.
370
371
372 -------------------------------------------------------------------------------
373 Options
374                                                *ale-options.c_clangtidy_checks*
375                                                      *g:ale_c_clangtidy_checks*
376                                                      *b:ale_c_clangtidy_checks*
377 c_clangtidy_checks
378 g:ale_c_clangtidy_checks
379   Type: |List|
380   Default: `[]`
381
382   The checks to enable for clang-tidy with the `-checks` argument.
383
384   All options will be joined with commas, and escaped appropriately for
385   the shell. The `-checks` flag can be removed entirely by setting this
386   option to an empty List.
387
388   Not all of clangtidy checks are applicable for C. You should consult the
389   clang documentation for an up-to-date list of compatible checks:
390   http://clang.llvm.org/extra/clang-tidy/checks/list.html
391
392                                            *ale-options.c_clangtidy_executable*
393                                                  *g:ale_c_clangtidy_executable*
394                                                  *b:ale_c_clangtidy_executable*
395 c_clangtidy_executable
396 g:ale_c_clangtidy_executable
397   Type: |String|
398   Default: `'clang-tidy'`
399
400   This variable can be changed to use a different executable for clangtidy.
401
402                                               *ale-options.c_clangtidy_options*
403                                                     *g:ale_c_clangtidy_options*
404                                                     *b:ale_c_clangtidy_options*
405 c_clangtidy_options
406 g:ale_c_clangtidy_options
407   Type: |String|
408   Default: `''`
409
410   This variable can be changed to modify compiler flags given to clang-tidy.
411
412   - Setting this variable to a non-empty string,
413   - and working in a buffer where no compilation database is found using
414     |g:ale_c_build_dir_names| or |g:ale_c_build_dir|,
415   will cause the `--` argument to be passed to `clang-tidy`, which will mean
416   that detection of `compile_commands.json` files for compile command
417   databases will be disabled.
418   Only set this option if you want to control compiler flags
419   entirely manually, and no `compile_commands.json` file is in one
420   of the |g:ale_c_build_dir_names| directories of the project tree.
421
422                                         *ale-options.c_clangtidy_extra_options*
423                                               *g:ale_c_clangtidy_extra_options*
424                                               *b:ale_c_clangtidy_extra_options*
425 c_clangtidy_extra_options
426 g:ale_c_clangtidy_extra_options
427   Type: |String|
428   Default: `''`
429
430   This variable can be changed to modify flags given to clang-tidy.
431
432                                            *ale-options.c_clangtidy_fix_errors*
433                                                  *g:ale_c_clangtidy_fix_errors*
434                                                  *b:ale_c_clangtidy_fix_errors*
435 c_clangtidy_fix_errors
436 g:ale_c_clangtidy_fix_errors
437   Type: |Number|
438   Default: `1`
439
440   This variable can be changed to disable the `-fix-errors` option for the
441   |clangtidy| fixer.
442
443
444 ===============================================================================
445 cppcheck                                                       *ale-c-cppcheck*
446
447                                             *ale-options.c_cppcheck_executable*
448                                                   *g:ale_c_cppcheck_executable*
449                                                   *b:ale_c_cppcheck_executable*
450 c_cppcheck_executable
451 g:ale_c_cppcheck_executable
452   Type: |String|
453   Default: `'cppcheck'`
454
455   This variable can be changed to use a different executable for cppcheck.
456
457                                                *ale-options.c_cppcheck_options*
458                                                      *g:ale_c_cppcheck_options*
459                                                      *b:ale_c_cppcheck_options*
460 c_cppcheck_options
461 g:ale_c_cppcheck_options
462   Type: |String|
463   Default: `'--enable=style'`
464
465   This variable can be changed to modify flags given to cppcheck.
466
467
468 ===============================================================================
469 cquery                                                           *ale-c-cquery*
470
471                                               *ale-options.c_cquery_executable*
472                                                     *g:ale_c_cquery_executable*
473                                                     *b:ale_c_cquery_executable*
474 c_cquery_executable
475 g:ale_c_cquery_executable
476   Type: |String|
477   Default: `'cquery'`
478
479   This variable can be changed to use a different executable for cquery.
480
481                                          *ale-options.c_cquery_cache_directory*
482                                                *g:ale_c_cquery_cache_directory*
483                                                *b:ale_c_cquery_cache_directory*
484 c_cquery_cache_directory
485 g:ale_c_cquery_cache_directory
486   Type: |String|
487   Default: `'~/.cache/cquery'`
488
489   This variable can be changed to decide which directory cquery uses for its
490   cache.
491
492
493 ===============================================================================
494 cspell                                                           *ale-c-cspell*
495
496 See |ale-cspell-options|
497
498
499 ===============================================================================
500 flawfinder                                                   *ale-c-flawfinder*
501
502                                           *ale-options.c_flawfinder_executable*
503                                                 *g:ale_c_flawfinder_executable*
504                                                 *b:ale_c_flawfinder_executable*
505 c_flawfinder_executable
506 g:ale_c_flawfinder_executable
507   Type: |String|
508   Default: `'flawfinder'`
509
510   This variable can be changed to use a different executable for flawfinder.
511
512                                             *ale-options.c_flawfinder_minlevel*
513                                                   *g:ale_c_flawfinder_minlevel*
514                                                   *b:ale_c_flawfinder_minlevel*
515 c_flawfinder_minlevel
516 g:ale_c_flawfinder_minlevel
517   Type: |Number|
518   Default: `1`
519
520   This variable can be changed to ignore risks under the given risk threshold.
521
522                                              *ale-options.c_flawfinder_options*
523                                                    *g:ale_c_flawfinder_options*
524                                                            *b:ale-c-flawfinder*
525 c_flawfinder_options
526 g:ale_c_flawfinder_options
527   Type: |String|
528   Default: `''`
529
530   This variable can be used to pass extra options into the flawfinder command.
531
532                                       *ale-options.c_flawfinder_error_severity*
533                                             *g:ale_c_flawfinder_error_severity*
534                                             *b:ale_c_flawfinder_error_severity*
535 c_flawfinder_error_severity
536 g:ale_c_flawfinder_error_severity
537   Type: |Number|
538   Default: `6`
539
540   This variable can be changed to set the minimum severity to be treated as an
541   error.  This setting also applies to flawfinder for c++.
542
543
544 ===============================================================================
545 uncrustify                                                   *ale-c-uncrustify*
546
547                                           *ale-options.c_uncrustify_executable*
548                                                 *g:ale_c_uncrustify_executable*
549                                                 *b:ale_c_uncrustify_executable*
550 c_uncrustify_executable
551 g:ale_c_uncrustify_executable
552   Type: |String|
553   Default: `'uncrustify'`
554
555   This variable can be changed to use a different executable for uncrustify.
556
557                                              *ale-options.c_uncrustify_options*
558                                                    *g:ale_c_uncrustify_options*
559                                                    *b:ale_c_uncrustify_options*
560 c_uncrustify_options
561 g:ale_c_uncrustify_options
562   Type: |String|
563   Default: `''`
564
565   This variable can be change to modify flags given to uncrustify.
566
567
568 ===============================================================================
569   vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: