Skip to content
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

x/tools/gopls: report SemanticHighlight for format string directives #71295

Open
xzbdmw opened this issue Jan 16, 2025 · 4 comments · May be fixed by golang/tools#557
Open

x/tools/gopls: report SemanticHighlight for format string directives #71295

xzbdmw opened this issue Jan 16, 2025 · 4 comments · May be fixed by golang/tools#557
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. gopls Issues related to the Go language server, gopls. help wanted NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@xzbdmw
Copy link

xzbdmw commented Jan 16, 2025

gopls version

..

go env

..

What did you do?

Currently, gopls does not report those information to client, and there exists a setting noSemanticString, while turn on, will let client highlight them.

However, some clients will benefit if gopls reports those tokens (e.g., %s), as described in golang/vscode-go#3632 (comment)

What did you see happen?

above

What did you expect to see?

above

Editor and settings

No response

Logs

No response

@xzbdmw xzbdmw added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Jan 16, 2025
@gopherbot gopherbot added this to the Unreleased milestone Jan 16, 2025
@gabyhelp
Copy link

@gabyhelp gabyhelp added the FeatureRequest Issues asking for a new feature that does not need a proposal. label Jan 16, 2025
@findleyr findleyr added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jan 16, 2025
@findleyr findleyr modified the milestones: Unreleased, gopls/unplanned Jan 16, 2025
@findleyr
Copy link
Member

We discussed this in our triage meeting today, and agree that users probably want this (this was one of the motivations for the noSemanticString setting, so that syntax highlighting can fall back to the default.

@xzbdmw
Copy link
Author

xzbdmw commented Jan 17, 2025

Rust-analyzer uses a custom tokenType.FormatSpecifier instead of modifiers, I can think of two ways for gopls:

  1. we can use string.placeholder (placeholder as modifier), and vscode plugin can link this modifier to some existing one by default ( I guess, not sure), some other clients will need to define their own colors.
  2. use an unused (but in spec) tokenType so all clients get different colors for placeholders from literal string automatically (in case they don’t read release notes). Fron lsp spec, there is one seems reasonable:

operator: For tokens that represent an operator.

Edit: I'm going to use TokMacro for this, it is currently only used in template file.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/643138 mentions this issue: gopls: report SemanticHighlight for format string directives

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. gopls Issues related to the Go language server, gopls. help wanted NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants