Home Explore Blog CI



neovim

18th chunk of `runtime/doc/quickfix.txt`
26678f4691422942f55c68f1cd1dd66e0b8e58066495c6650000000100000fa6
 "compiler" directory will set options to use the
selected compiler.  For `:compiler` local options are set, for `:compiler!`
global options.
							*current_compiler*
To support older Vim versions, the plugins always use "current_compiler" and
not "b:current_compiler".  What the command actually does is the following:

- Delete the "current_compiler" and "b:current_compiler" variables.
- Define the "CompilerSet" user command.  With "!" it does ":set", without "!"
  it does ":setlocal".
- Execute ":runtime! compiler/{name}.{vim,lua}".  The plugins are expected to
  set options with "CompilerSet" and set the "current_compiler" variable to the
  name of the compiler.
- Delete the "CompilerSet" user command.
- Set "b:current_compiler" to the value of "current_compiler".
- Without "!" the old value of "current_compiler" is restored.


For writing a compiler plugin, see |write-compiler-plugin|.

Use the |compiler-make| plugin to undo the effect of a compiler plugin.

CPPCHECK			*quickfix-cppcheck* *compiler-cppcheck*

Use g/b:`c_cppcheck_params` to set cppcheck parameters. The global
settings by default include

- `--verbose`: Enables verbose output.
- `--force`: Forces checking of all configurations.
- `--inline-suppr`: Allows inline suppressions.
- `--enable=...`: Enables specific checks like warnings, style, performance,
  portability, information, and missing includes.
- `-j`: Utilizes multiple processors if available, determined by the
  `getconf` command if available (requires omitting the unusedFunction check)

For C++ files (`filetype == 'cpp'`), the `--language=c++` option is added to
ensure Cppcheck treats the file as C++.

If compile_commands.json is present in the current directory, it is added as a
`--project` parameter to the command line. Otherwise, by default the
directories in &path are passed as include directories. These can be set by
g/b:`c_cppcheck_includes` as a list of `-I` flags. Tim Pope's vim-apathy
plug-in [0] can expand &path. To also append the folders in a git repo use >

  let &l:path = join(systemlist('git ls-tree -d --name-only -r HEAD'), ',')

[0] https://github.com/tpope/vim-apathy

DOTNET							*compiler-dotnet*

The .NET CLI compiler outputs both errors and warnings by default. The output
may be limited to include only errors, by setting the g:dotnet_errors_only
variable to |v:true|.

The associated project name is included in each error and warning. To suppress
the project name, set the g:dotnet_show_project_file variable to |v:false|.

Example: limit output to only display errors, and suppress the project name: >
	let dotnet_errors_only = v:true
	let dotnet_show_project_file = v:false
	compiler dotnet
<
GCC					*quickfix-gcc*	*compiler-gcc*

There's one variable you can set for the GCC compiler:

g:compiler_gcc_ignore_unmatched_lines
				Ignore lines that don't match any patterns
				defined for GCC.  Useful if output from
				commands run from make are generating false
				positives.

JAVAC							*compiler-javac*

Commonly used compiler options can be added to 'makeprg' by setting the
b/g:javac_makeprg_params variable.  For example: >

	let g:javac_makeprg_params = "-Xlint:all -encoding utf-8"

MAVEN							*compiler-maven*

Commonly used compiler options can be added to 'makeprg' by setting the
b/g:maven_makeprg_params variable.  For example: >

	let g:maven_makeprg_params = "-DskipTests -U -X"

SPOTBUGS						*compiler-spotbugs*

SpotBugs is a static analysis tool that can be used to find bugs in Java.
It scans the Java bytecode of all classes in the currently open buffer.
(Therefore, `:compiler! spotbugs` is not supported.)

Commonly used compiler options can be added to 'makeprg' by setting the
"b:" or "g:spotbugs_makeprg_params" variable.  For example: >vim

	let b:spotbugs_makeprg_params = "-longBugCodes -effort:max -low"

The global default is "-workHard -experimental".

By default, the class files are searched in the directory where the source
files are placed.  However, typical Java projects

Title: Compiler Plugins Details and Specific Compiler Settings
Summary
This section provides further details on compiler plugins within Vim, explaining how they set options and manage compiler versions using "current_compiler". It outlines how the `CompilerSet` command is used to apply settings, and mentions the |compiler-make| plugin to undo changes. The section then dives into specific compilers like CPPCHECK, DOTNET, GCC, JAVAC, MAVEN, and SPOTBUGS, detailing their unique settings, parameters, and configurations. It also provides examples for customizing each compiler's behavior using variables like `g:c_cppcheck_params`, `g:dotnet_errors_only`, `g:javac_makeprg_params`, and `b:spotbugs_makeprg_params`.