Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for LSP diagnostic "additional information". #4589

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brownts
Copy link
Contributor

@brownts brownts commented Oct 19, 2024

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 in flymake-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 current
buffer (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.

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 in `flymake-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 current
buffer (`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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant