-
Notifications
You must be signed in to change notification settings - Fork 767
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 new semantic token modifiers in gopls 0.17 #3632
Comments
CC @h9jiang |
I feel this is not needed, because vscode users need to define the color of those "not in spec" modifiers, otherwise there are no visual differences. |
@xzbdmw that may the case, but there is no guarantee that other clients behave well in the presence of unexpected semantic tokens. The spec is (IMO) unclear about how servers are supposed to behave if clients do not advertise a particular token capability. Furthermore, we already have some ad-hoc configuration to customize the behavior of semantic tokens, to address https://go.dev/issue/45753 I think it makes sense to deprecate the somewhat ad-hoc "noSemanticString" and "noSemanticNumber" settings, and replace them with a |
Change https://go.dev/cl/642077 mentions this issue: |
I do hope gopls sends them all by default ( I think that's what rust-analyzer does, I get tons of modifiers with a default setup), because right now, unless people take attention to release notes, and manually advertise these token capabilities, they never know those "out-of-spec" modifiers even exists. |
But there is a small issue with I will proceed with my CL and discussing further in golang/go#71227. |
Change https://go.dev/cl/642416 mentions this issue: |
Change https://go.dev/cl/642423 mentions this issue: |
We agreed to return full set of token types and modifiers from gopls by default (full means token types and modifiers that gopls understand) and provide configuraton options for users to disable some of them. - Two fields of type map[string]bool are introduced to gopls UIOptions (workspace/configuration) to customize semantic token types and modifiers. For now, only value of "false" is effective. Choose type of map over array to keep future compatibility in case we want to introduce enable capabilities. - VSCode-Go populate these options from user settings to gopls. - Gopls "initialize" protocol returns a pre-defined fixed legend including subset of standard legend defined LSP that gopls understand with additional customize modifiers gopls recoganized. - Gopls "textDocument/semanticTokens" protocol returns token types and modifiers based on configuration defined in workspace/configuration. Tested with vscode-go changes CL 642416, screenshot is at golang/vscode-go#3632 (comment) For golang/vscode-go#3632 Change-Id: Ie8220e12a4c8d6c84c54992d84277767e61ec023 Reviewed-on: https://go-review.googlesource.com/c/tools/+/642077 Auto-Submit: Hongxiang Jiang <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]>
This FR is now implemented and will be shipped with Gopls in v0.18.0 and configuration will be available in vscode-go v0.46.0. |
@h9jiang let's also be sure to deprecate noSemanticNumber and noSemanticString. We can associate that change with this CL. We should also document this configuration change in |
Change https://go.dev/cl/642998 mentions this issue: |
As mentioned in the CL, noSemanticString & noSemanticNumber will be deprecated in favor of semanticTokenType["string"] = false, semanticTokenType["number"] = false. Users can use semanticTokenType map to disable more types based on their preference. (Same rule applies to semantic token modifiers) Gopls will still be able to interpret and understand |
Regarding |
Change https://go.dev/cl/643056 mentions this issue: |
Change https://go.dev/cl/643057 mentions this issue: |
xzbdmw@ you mean, return I would be very careful when choosing a new I'm personally ok with having an extra modifiers. @adonovan might be able to offer a decision here. |
I'm not sure how format strings relate to noSemanticString. I think you must be asking: when the server returns "string" token types, should it also return a "formatString" modifier for the subset that appear to be format strings? I don't know the answer (I don't use semantic tokens). What would a client do with this information? Would it not be redundant with the information provided by DocumentHighlight? And let's not forget that we're only using a heuristic to classify format strings. |
Elsewhere, we break up strings into multiple tokens, for example to highlight the imported package name in import specs: I'm doubtful that we should be doing that here, as it is less precise than imports (and I'm not entirely sold on sub-string highlighting in imports as well). However, @xzbdmw please feel free to open that as a separate gopls issue, which we can consider independently. |
When generating package.json based on gopls api-json output, vscode-go release tool will interpret deprecation message and write the message to package.json and settings.md. In settings.md, deprecation message is put above description. Gopls side CL 642998, Test CL 643057. For #3632 Change-Id: Ica21fcc446dd1c5a5d4ef9b66101b3a9b0a47e80 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/643056 kokoro-CI: kokoro <[email protected]> Reviewed-by: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Hongxiang Jiang <[email protected]> Commit-Queue: Hongxiang Jiang <[email protected]>
- gopls api-json will return deprecation message as additional property of a configuration. - go generate ./... will parse the comment of a given field as doc(entire doc comment) and deprecation message(introduced by prefix "Deprecated: "). Follow pattern defined in https://go.dev/wiki/Deprecated. VSCode-Go side CL 643056. For golang/vscode-go#3632 Change-Id: Ia6a67948c75dd51b5cb76bbd6d7385b95ea979e4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/642998 Auto-Submit: Hongxiang Jiang <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]>
Change https://go.dev/cl/643497 mentions this issue: |
For golang/vscode-go#3632 Change-Id: I8d8a219c380ac8ac07a1baaef3bc89701894b985 Reviewed-on: https://go-review.googlesource.com/c/tools/+/643497 Reviewed-by: Alan Donovan <[email protected]> Auto-Submit: Hongxiang Jiang <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Is your feature request related to a problem? Please describe.
https://github.com/golang/tools/blob/master/gopls/doc/release/v0.17.0.md#semantic-token-modifiers-of-top-level-constructor-of-types
Describe the solution you'd like
Add those as default capabilities for vscode
The text was updated successfully, but these errors were encountered: