Skip to content

Conversation

@stefanvanburen
Copy link
Member

Also removes the diagnostic.Data from the new diagnostics, which AFAICS is unused; we can save ourselves the json marshaling.

As a part of this, added a first pass at adding tests for diagnostics; we don't currently have any. These are a bit different because we haven't implemented PullDiagnostics (we can add this, but we'd need a custom implementation, or wait until go.lsp.dev upgrades to 3.17). Instead, we intercept the notifications from the server. Lastly, since we don't actually want the tests to wait around, adds synctest and only runs the tests on Go 1.25 for now (1.26 should be released next month and we'll be able to upgrade to 1.25 as our minimum).

This is in preparation to eventually landing relatedInformation (other spans) in diagnostics, from bufbuild/protocompile#659.

Also pulls in the latest protocompile@main to bring in the new deprecated tag.

Also removes the diagnostic.Data from the new diagnostics, which AFAICS
is unused; we can save ourselves the json marshaling.

As a part of this, added a first pass at adding tests for diagnostics;
we don't currently have any. These are a bit different because we
haven't implemented [PullDiagnostics][1] (we can add this, but we'd need
a custom implementation, or wait until [go.lsp.dev upgrades to
3.17][2]). Instead, we intercept the notifications from the
server. Lastly, since we don't actually want the tests to wait around,
adds synctest and only runs the tests on Go 1.25 for now (1.26 should be
released next month and we'll be able to upgrade to 1.25 as our
minimum).

This is in preparation to eventually landing relatedInformation (other
spans) in diagnostics, from bufbuild/protocompile#659.

Also pulls in the latest protocompile@main to bring in the new
deprecated tag.

[1]: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics
[2]: go-language-server/protocol#52
@github-actions
Copy link
Contributor

github-actions bot commented Jan 30, 2026

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJan 30, 2026, 9:10 PM

stream,
queryExecutor,
)
require.NoError(t, err)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just simplified; Serve will start running in the background, so we don't need the extra goroutine.

// We serialize the bytes into a string before providing the structure to diagnostic.Data
// because diagnostic.Data is an interface{}, which is treated as a JSON "any", which
// will not cleanly deserialize.
diagnostic.Data = string(bytes)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we aren't using this data; it's just included so it can be passed back to us in a subsequent codeAction (ref: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic). I think we can leave it off, for now.

Comment on lines +1152 to +1156
if annotation.Type() == "IMPORT_USED" {
diagnostic.Tags = []protocol.DiagnosticTag{
protocol.DiagnosticTagUnnecessary,
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the old diagnostic from the lint server that we're currently using; the const is here (unexported); if it changes out from under us, the test will catch it, but I suspect we're not going to change anything in that package in the near future.

Comment on lines -367 to +370
// TODO: Use Tags with a protocol.CompletionItemTagDeprecated if the client supports tags.
Deprecated: isDeprecated,
Deprecated: isDeprecated,
Tags: []protocol.SymbolTag{
protocol.SymbolTagDeprecated,
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we ought to have a more generalized idea of client capabilities, but it doesn't seem like a bad idea to just populate both of these values; figured I'd nix the TODO.

@stefanvanburen stefanvanburen changed the title Add tags to diagnostics Add tags to LSP diagnostics Jan 30, 2026

package diagnostics.v1;

import "google/protobuf/timestamp.proto";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rendered in grey, from the "unnecessary" tag:

Image

@stefanvanburen stefanvanburen marked this pull request as ready for review January 30, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants