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: using hints results in error saying hints already specified when not #57470

Closed
leighmcculloch opened this issue Dec 27, 2022 · 4 comments
Labels
FrozenDueToAge 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

@leighmcculloch
Copy link
Contributor

gopls version

❯ gopls -v version
Build info
----------
golang.org/x/tools/gopls v0.11.0
    golang.org/x/tools/gopls@v0.11.0 h1:/nvKHdTtePQmrv9XN3gIUN9MOdUrKzO/dcqgbG6x8EY=
    github.com/BurntSushi/toml@v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
    github.com/google/go-cmp@v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/exp@v0.0.0-20221031165847-c99f073a8326 h1:QfTh0HpN6hlw6D3vu8DAwC8pBIwikq0AI1evdm+FksE=
    golang.org/x/exp/typeparams@v0.0.0-20221031165847-c99f073a8326 h1:fl8k2zg28yA23264d82M4dp+YlJ3ngDcpuB1bewkQi4=
    golang.org/x/mod@v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
    golang.org/x/sync@v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
    golang.org/x/sys@v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
    golang.org/x/text@v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
    golang.org/x/tools@v0.3.1-0.20221213193459-ca17b2c27ca8 h1:7/HkGkN/2ktghBCSRRgp31wAww4syfsW52tj7yirjWk=
    golang.org/x/vuln@v0.0.0-20221109205719-3af8368ee4fe h1:qptQiQwEpETwDiz85LKtChqif9xhVkAm8Nhxs0xnTww=
    honnef.co/go/tools@v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA=
    mvdan.cc/gofumpt@v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
    mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.19.1

go env

❯ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/Users/leighmcculloch/.local/bin"
GOCACHE="/Users/leighmcculloch/Library/Caches/go-build"
GOENV="/Users/leighmcculloch/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/leighmcculloch/.local/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/leighmcculloch/.local/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/leighmcculloch/.local/bin/go/latest"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/leighmcculloch/.local/bin/go/latest/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/leighmcculloch/Code/playground/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/63/pqms5lmj1ys9wqt171l2y6xr0000gn/T/go-build450876770=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Added the following JSON to VSCode Settings.

    "gopls": {
        "ui.completion.usePlaceholders": true,
        "codelenses": {
            "generate": true,
            "gc_details": true,
        },
        "hints": {
            "assignVariableTypes": true
        }
    },

What did you expect to see?

Expected to see hints for variable type assignments.

What did you see instead?

The following error message immediately after saving the settings:

Invalid settings: parsing setting "hints": duplicate configuration for hints

Editor and settings

See above.

Logs

<!--
If possible please include gopls logs. Instructions for capturing them can be found here:
https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capture-logs
-->

I spent a little while trying to figure out how to capture the logs in VSCode following the instructions in the link, as well as the "documentation for your editor" link, but I couldn't figure it out. I'm happy to provide logs if someone could give me some more straightforward instructions than those above.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Dec 27, 2022
@gopherbot gopherbot added this to the Unreleased milestone Dec 27, 2022
@leighmcculloch
Copy link
Contributor Author

What did you see instead?

The following error message immediately after saving the settings:

Invalid settings: parsing setting "hints": duplicate configuration for hints

This error message suggested to me that I'd accidentally double specified the "hints" block, but I've double checked my settings JSON file, and there's no "hints" other than the one shown above.

@leighmcculloch
Copy link
Contributor Author

Ah so, I think I'm trying to configure inlayHints incorrectly for VSCode's specific use of gopls.

While the gopls hints are configurable with that option, the VSCode extension surfaces inlay hints under a different config, and then I think passes them through.

I got inlay hints working by instead adding this option in VSCode:

    "go.inlayHints.assignVariableTypes": true,

@gopherbot
Copy link

Change https://go.dev/cl/459519 mentions this issue: docs/features.md: add link to inlayHints settings from features.md

gopherbot pushed a commit to golang/vscode-go that referenced this issue Dec 28, 2022
Add more specific instructions for how to go about updating settings
for the inlay hints feature in VS Code.

For golang/go#57470

Change-Id: Ibb457ad1c8c8a092cc27fafc1a70b3f62812f783
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/459519
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
@suzmue
Copy link
Contributor

suzmue commented Dec 29, 2022

@leighmcculloch Thanks for filing an issue and glad you figured it out! I updated the feature documentation in VS Code to point to the go.inlayHints.* settings, so hopefully that helps with this in the future.

@suzmue suzmue closed this as completed Dec 29, 2022
@golang golang locked and limited conversation to collaborators Dec 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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

No branches or pull requests

3 participants