feat: append LSP diagnostic codes to flymake messages#5036
Open
alberti42 wants to merge 1 commit intoemacs-lsp:masterfrom
Open
feat: append LSP diagnostic codes to flymake messages#5036alberti42 wants to merge 1 commit intoemacs-lsp:masterfrom
alberti42 wants to merge 1 commit intoemacs-lsp:masterfrom
Conversation
Member
|
Can you do this to |
Author
|
Hi @jcs090218, thanks for the quick reply already. I checked flycheck. The good news is that we don't need to change anything in the flycheck branch. The code is already correct and exactly displays the error code as [CODE]. You can see that code? was already deconstructed and passed to (-map (-lambda ((&Diagnostic :message :severity? :tags? :code? :source?
:range (&Range :start (start &as &Position
:line start-line
:character start-character)
:end (end &as &Position
:line end-line
:character end-character))))
(flycheck-error-new
:buffer (current-buffer)
:checker checker
:filename buffer-file-name
:message message
:level (lsp-diagnostics--flycheck-calculate-level severity? tags?)
:id code?
:group source?
:line (lsp-translate-line (1+ start-line))
:column (1+ (lsp-translate-column start-character))
:end-line (lsp-translate-line (1+ end-line))
:end-column (unless (lsp--position-equal start end)
(1+ (lsp-translate-column end-character))))))What was missing was precisely the flymake branch where the code was not displayed. If this PR makes it to upstream, then both branches display the same message and error code. |
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.
Currently,
lsp-diagnostics--flymake-update-diagnosticsextracts:messageand:severity?from each LSP diagnostic but silently drops:code?. As a result, flymake displays messages like:without the diagnostic rule name that the language server also provides.
This patch binds
:code?and appends it to the message text when present:This is a small but valuable change. The diagnostic code is the primary handle users need to:
# pyright: ignore[reportPossiblyUnbound])Without the code, users must guess the rule name. The fix is a two-line change: bind
:code?in the existing-let*destructuring and conditionally append[code]to the message.The code field is optional in the LSP spec, so the format falls back gracefully to the plain message when absent.