Home Explore Blog CI



neovim

21th chunk of `runtime/doc/quickfix.txt`
3037ac68ad53876b2df4c630bb60367ccc922f76e3bccc8d0000000100000fa3
 `:doautocmd java_spotbugs_post ShellCmdPost`
must be removed from such "*Action" (or "*Command") implementations (i.e. the
lines `(a)` and `(b)` in the listed examples) to retain a sequential order for
non-blocking execution, and any notification (see below) must be suppressed.
A `ShellCmdPost` `:autocmd` can be associated with any |:augroup| by assigning
its name to the "augroupForPostCompilerAction" key.

When default actions are not suited to a desired workflow, proceed by writing
arbitrary functions yourself and matching their Funcrefs to the supported
keys: "PreCompilerAction", "PreCompilerTestAction", and "PostCompilerAction".

The next example re-implements the default pre-compiler actions for a Maven
project and requests other default Maven settings with the "compiler" entry:
>vim
	function! MavenPreCompilerAction() abort
		call spotbugs#DeleteClassFiles()
		compiler maven
		make compile
		cc
	endfunction

	function! MavenPreCompilerTestAction() abort
		call spotbugs#DeleteClassFiles()
		compiler maven
		make test-compile
		cc
	endfunction

	let g:spotbugs_properties = {
		\ 'compiler':		'maven',
		\ 'PreCompilerAction':
			\ function('MavenPreCompilerAction'),
		\ 'PreCompilerTestAction':
			\ function('MavenPreCompilerTestAction'),
	\ }

Note that all entered custom settings will take precedence over the matching
default settings in "g:spotbugs_properties".
Note that it is necessary to notify the plugin of the result of a pre-compiler
action before further work can be undertaken.  Using |:cc| after |:make| (or
|:ll| after |:lmake|) as the last command of an action is the supported means
of such communication.

Two commands, "SpotBugsRemoveBufferAutocmd" and "SpotBugsDefineBufferAutocmd",
are provided to toggle actions for buffer-local autocommands.  For example, to
also run actions on any |BufWritePost| and |Signal| event, add these lines to
`~/.config/nvim/after/ftplugin/java.vim`: >vim

	if exists(':SpotBugsDefineBufferAutocmd') == 2
		SpotBugsDefineBufferAutocmd BufWritePost Signal
	endif

Otherwise, you can turn to `:doautocmd java_spotbugs User` at any time.

The "g:spotbugs_properties" variable is consulted by the Java filetype plugin
(|ft-java-plugin|) to arrange for the described automation, and, therefore, it
must be defined before |FileType| events can take place for the buffers loaded
with Java source files.  It could, for example, be set in a project-local
|vimrc| loaded by [1].

Both "g:spotbugs_properties" and "b:spotbugs_properties" are recognized and
must be modifiable (|:unlockvar|).  The "*Command" entries are always treated
as global functions to be shared among all Java buffers.

The SpotBugs Java library and, by extension, its distributed shell scripts do
not support in the `-textui` mode listed pathnames with directory filenames
that contain blank characters [2].  To work around this limitation, consider
making a symbolic link to such a directory from a directory that does not have
blank characters in its name and passing this information to SpotBugs: >vim

	let g:spotbugs_alternative_path = {
		\ 'fromPath':	'path/to/dir_without_blanks',
		\ 'toPath':	'path/to/dir with blanks',
	\ }

[0] https://github.com/Konfekt/vim-compilers
[1] https://github.com/MarcWeber/vim-addon-local-vimrc
[2] https://github.com/spotbugs/spotbugs/issues/909

GNU MAKE						*compiler-make*

Since the default make program is "make", the compiler plugin for make,
:compiler make, will reset the 'makeprg' and 'errorformat' option to
the default values and unlet any variables that may have been set by a
previous compiler plugin.

GROFF					*quickfix-groff* *compiler-groff*

The GROFF compiler plugin uses the mom macro set (documented in the groff_mom
manpage) as input and expects that the output file type extension is passed to
make, say :make html or :make pdf.

Additional arguments can be passed to groff by setting them in
`b:groff_compiler_args` or `g:groff_compiler_args`. The `language` argument
passed to groff is set using

Title: Customizing SpotBugs Actions, Autocommands, and Workarounds for Path Limitations
Summary
This section details how to implement custom SpotBugs actions for pre-compilation, using a Maven project as an example, and emphasizes that custom settings override defaults. It covers the importance of notifying the plugin of pre-compiler action results using |:cc| or |:ll|. It also explains how to use 'SpotBugsRemoveBufferAutocmd' and 'SpotBugsDefineBufferAutocmd' to manage buffer-local autocommands for events like |BufWritePost| and |Signal|. The section highlights the significance of defining 'g:spotbugs_properties' before |FileType| events and notes that both global and buffer-local properties are recognized and modifiable. Finally, it addresses a limitation with SpotBugs' handling of pathnames containing blank characters and suggests a workaround using symbolic links and the 'g:spotbugs_alternative_path' variable. The section ends by briefly mentioning the GNU MAKE and GROFF compiler plugins.