Add support for LSP diagnostic "additional information".#4589
Open
brownts wants to merge 4 commits intoemacs-lsp:masterfrom
Open
Add support for LSP diagnostic "additional information".#4589brownts wants to merge 4 commits intoemacs-lsp:masterfrom
brownts wants to merge 4 commits intoemacs-lsp:masterfrom
Conversation
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.
159015b to
dec2f7f
Compare
Contributor
Author
|
@jcs090218, any concerns with merging this? |
Contributor
Author
|
Ping @jcs090218, @yyoncho. This PR has been sitting here for a while and I'm not sure what needs to be done in order to have it merged. There are Language Servers which provide "additional information" which could benefit from this. Additionally, it appears this was asked for in the past in #3279. Any help in moving this along is appreciated. Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-diagnosticsvariable. Flymake treats these as interim diagnostics until the file has been opened. Therefore, diagnostics placed inflymake-list-only-diagnosticsare 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. Older versions of Flymake don't provide a way to specify the checker (or a code), so the diagnostic message is appended with this information when provided.