lsp: emit VS-internal HiddenInEditor tag for unnecessary diagnostics#3989
Open
joj wants to merge 1 commit into
Open
lsp: emit VS-internal HiddenInEditor tag for unnecessary diagnostics#3989joj wants to merge 1 commit into
joj wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates LSP diagnostic tagging to make “Unnecessary” diagnostics render as faded (no squiggle) in Visual Studio by emitting a VS-specific extension tag when the client indicates VS extension support, while keeping standard LSP behavior for other clients.
Changes:
- Added a VS-specific
DiagnosticTagconstant (HiddenInEditor) in the LSP protocol layer. - Updated diagnostic conversion to append
HiddenInEditoralongsideUnnecessarywhen talking to Visual Studio.
Show a summary per file
| File | Description |
|---|---|
| internal/lsp/lsproto/lsp.go | Introduces a VS-specific diagnostic tag constant used to influence VS rendering. |
| internal/ls/lsconv/converters.go | Emits the VS extension diagnostic tag (in addition to Unnecessary) when the client is Visual Studio. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 2
jakebailey
reviewed
May 19, 2026
The LSP spec says clients are "allowed to render diagnostics [tagged Unnecessary] faded out instead of having an error squiggle." Visual Studio's LSP client, however, only renders the faded "unused" appearance when a diagnostic carries both DiagnosticTag.Unnecessary AND the VS-internal VSDiagnosticTags.HiddenInEditor tag; with just Unnecessary the diagnostic shows as a normal squiggle. When the client advertises _vs_supportsVisualStudioExtensions, also emit HiddenInEditor (int32.MaxValue - 6 = 2147483641) so unused variables and similar diagnostics render faded in Visual Studio. Non-VS clients continue to receive only the standard LSP tags. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
d8ef53b to
2510166
Compare
jakebailey
reviewed
May 20, 2026
| if (diagnosticTagEnum) { | ||
| diagnosticTagEnum.values.push( | ||
| { | ||
| name: "VsHiddenInEditor", |
Member
There was a problem hiding this comment.
Suggested change
| name: "VsHiddenInEditor", | |
| name: "VSHiddenInEditor", |
Actually, Go naming nit
Comment on lines
+303
to
+312
| tags = make([]lsproto.DiagnosticTag, 0, 3) | ||
| if diagnostic.ReportsUnnecessary() && slices.Contains(opts.tagValueSet, lsproto.DiagnosticTagUnnecessary) { | ||
| tags = append(tags, lsproto.DiagnosticTagUnnecessary) | ||
| // Visual Studio's LSP client only renders Unnecessary diagnostics as | ||
| // faded-out text when they also carry the VS-internal HiddenInEditor | ||
| // tag; otherwise they appear as a regular squiggle. Emit it so VS | ||
| // matches the LSP-spec intent of the Unnecessary tag. | ||
| if opts.visualStudio { | ||
| tags = append(tags, lsproto.DiagnosticTagVsHiddenInEditor) | ||
| } |
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.
The LSP spec says clients are "allowed to render diagnostics [tagged Unnecessary] faded out instead of having an error squiggle." Visual Studio's LSP client, however, only renders the faded "unused" appearance when a diagnostic carries both DiagnosticTag.Unnecessary AND the VS-internal VSDiagnosticTags.HiddenInEditor tag; with just Unnecessary the diagnostic shows as a normal squiggle.
When the client advertises _vs_supportsVisualStudioExtensions, also emit HiddenInEditor (int32.MaxValue - 6 = 2147483641) so unused variables and similar diagnostics render faded in Visual Studio. Non-VS clients continue to receive only the standard LSP tags.