Add support for LSP diagnostic "additional information". #4589
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change provides support for additional information that can be provided with an LSP diagnostic, for both Flycheck and Flymake interfaces. The main change treats each piece of "additional information" as a separate diagnostic with the same severity level as the main diagnostic. Flycheck supports the concept of a group, so for Flycheck diagnostics the main diagnostic and all of it's "additional information" diagnostics are placed in the same Flycheck group.
"Additional information" diagnostics may refer to a file which is not the current buffer. Flycheck handles this as part of it's normal diagnostic interface, however Flymake makes a distinction between diagnostics related to the current buffer and those external to it (i.e., foreign diagnostics). For Flymake, the foreign diagnostics are managed in the
flymake-list-only-diagnostics
variable. Flymake treats these as interim diagnostics until the file has been opened. Therefore, diagnostics placed inflymake-list-only-diagnostics
are removed when that buffer reports its own diagnostics. Additionally, with Flymake, foreign diagnostics are only visible when reporting diagnostics for the project (flymake-show-project-diagnostics
), not when reporting diagnostics for the currentbuffer (
flymake-show-buffer-diagnostics
). Flycheck on the other hand, does not make this distinction and will report both types of diagnostics together (flycheck-list-errors
).Additional changes that drive conformity between Flycheck and Flymake were also applied. When an LSP diagnostic provides a source, this is supplied to Flycheck as the "checker", otherwise the default "lsp" checker is used. This is useful to properly identify the LSP backends generating the diagnostics when it is available. Flymake doesn't provide a way to specify the checker (or a code), so the diagnostic message is appended with this information when provided.