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: setting semanticTokenTypes has no effect #71964

Closed
danztran opened this issue Feb 26, 2025 · 5 comments
Closed

x/tools/gopls: setting semanticTokenTypes has no effect #71964

danztran opened this issue Feb 26, 2025 · 5 comments
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@danztran
Copy link

gopls version

v0.18.1

go env

GO111MODULE='auto'
GOARCH='arm64'
GOBIN=''
GOCACHE='$HOME/Library/Caches/go-build'
GOENV='$HOME/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='$HOME/go/pkg/mod'
GOOS='darwin'
GOPATH='$HOME/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='$HOME/sdk/go1.23.6'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='$HOME/sdk/go1.23.6/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.6'
GODEBUG=''
GOTELEMETRY='off'
GOTELEMETRYDIR='$HOME/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='$PROJECT_DIR/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/j0/w9h1x51j7wzddn_d34qfvycm0000gp/T/go-build1704160563=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Setting ui.semanticTokenTypes in my vscode settings due to Deprecation of noSemanticString and noSemanticNumber

"gopls": {
  "ui.semanticTokens": true,
  "ui.semanticTokenTypes": {
      "string": false,
      "number": false,
   }
}

What did you see happen?

strings have no highlighting for verbs like %v, %w...
Image

What did you expect to see?

have highlight normally.
Image

Editor and settings

"[go]": {
  "editor.semanticHighlighting.enabled": true,
  "editor.defaultFormatter": "golang.go",
  "editor.formatOnSaveMode": "file"
},
"gopls": {
  "formatting.gofumpt": true,
  "ui.diagnostic.analyses": {
    "composites": false,
    "unusedparams": false
  },
  "ui.navigation.symbolScope": "workspace",
  "ui.navigation.importShortcut": "Definition",
  "ui.semanticTokens": true,
  "ui.semanticTokenTypes": {
    "string": false,
    "number": false
  },
  "ui.codelenses": {
    "run_govulncheck": true,
    "gc_details": false
  }
}

Logs

But setting ui.semanticTokenModifiers works as expected.

"ui.semanticTokenModifier": {
  "string": false,
  "number": false
}

I also found a potential implementation error in this gopls function. It appears to be copying ⁠SemanticTokenModifiers instead of ⁠SemanticTokenTypes.

@danztran danztran 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 Feb 26, 2025
@gopherbot gopherbot added this to the Unreleased milestone Feb 26, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/652655 mentions this issue: gopls/internal/settings: correct SemanticTokenTypes source

@h9jiang
Copy link
Member

h9jiang commented Feb 26, 2025

Thanks for reporting this. You are correct, I will review your CL and hopefully make this to the next gopls patch release.

But for now, you can keep setting both ui.semanticTokenTypes.string = false & noSemanticString so you won't see string type show up.

@h9jiang h9jiang modified the milestones: gopls/v0.19.0, gopls/v0.18.2 Feb 26, 2025
@h9jiang
Copy link
Member

h9jiang commented Feb 26, 2025

@findleyr could this issue added to gopls v0.18.2 milestone?

@findleyr
Copy link
Member

@h9jiang absolutely. Thanks @danztran for the report and fix.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/652915 mentions this issue: gopls/internal/settings: correct SemanticTokenTypes source

gopherbot pushed a commit to golang/tools that referenced this issue Feb 26, 2025
…TokenTypes source

fix golang/go#71964

Change-Id: I2694023636272ea971880865a4f2cb6d9192d7d5
GitHub-Last-Rev: c81d388
GitHub-Pull-Request: #564
Reviewed-on: https://go-review.googlesource.com/c/tools/+/652655
Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Hongxiang Jiang <hxjiang@golang.org>
(cherry picked from commit d740adf)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/652915
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. 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