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: not returning semanticTokensProvider capability #54531

Open
puremourning opened this issue Aug 18, 2022 · 5 comments
Open

x/tools/gopls: not returning semanticTokensProvider capability #54531

puremourning opened this issue Aug 18, 2022 · 5 comments
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

@puremourning
Copy link

puremourning commented Aug 18, 2022

gopls version

ben@BenMBP2021 ycmd % /Users/ben/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/go/bin/gopls version
golang.org/x/tools/gopls v0.9.4
    golang.org/x/tools/gopls@v0.9.4 h1:YhHOxVi++ILnY+QnH9FGtRKZZrunSaR7OW8/dCp7bBk=

go env

ben@BenMBP2021 golang-tools % go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/ben/Library/Caches/go-build"
GOENV="/Users/ben/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS="-modcacherw"
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/ben/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/ben/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.19/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.19/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.19"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/ben/Development/YouCompleteMe/golang-tools/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 arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/g3/2g6b5vgj3pz55jg8__0yr6nh0000gn/T/go-build426307582=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. initialise gopls, specifying client capabilities indicating semanticTokens are supported, and enable semanticTokens: true
[Trace - 20:48:52.151 PM] Sending request 'initialize - (1)'.
Params: {"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"documentationFormat":["plaintext","markdown"]},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"documentSymbol":{"hierarchicalDocumentSymbolSupport":false,"labelSupport":false,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"hover":{"contentFormat":["plaintext","markdown"]},"inlay_hint":{},"semanticTokens":{"augmentSyntaxTokens":true,"formats":["relative"],"requests":{"full":{"delta":false},"range":true},"tokenModifiers":[],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","member","macro","keyword","modifier","comment","string","number","regexp","operator"]},"signatureHelp":{"signatureInformation":{"documentationFormat":["plaintext","markdown"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true}},"workspace":{"applyEdit":true,"configuration":true,"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"workspaceEdit":{"documentChanges":true},"workspaceFolders":true}},"initializationOptions":{"hints":{"assignVariableTypes":true,"compositeLiteralFields":true,"compositeLiteralTypes":true,"constantValues":true,"functionTypeParameters":true,"parameterNames":true,"rangeVariableTypes":true},"hoverKind":"Structured","semanticTokens":true},"processId":50805,"rootPath":"/Users/ben/Development/YouCompleteMe/golang-tools","rootUri":"file:///Users/ben/Development/YouCompleteMe/golang-tools","workspaceFolders":[{"name":"golang-tools","uri":"file:///Users/ben/Development/YouCompleteMe/golang-tools"}]}

What did you expect to see?

The initialise response should include semanticTokensProvider including the legend required to decode the tokens:

export interface SemanticTokensOptions extends WorkDoneProgressOptions {
	/**
	 * The legend used by the server
	 */
	legend: [SemanticTokensLegend](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#semanticTokensLegend);

	/**
	 * Server supports providing semantic tokens for a specific range
	 * of a document.
	 */
	range?: boolean | {
	};

	/**
	 * Server supports providing semantic tokens for a full document.
	 */
	full?: boolean | {
		/**
		 * The server supports deltas for full documents.
		 */
		delta?: boolean;
	};
}

What did you see instead?

gopls does not declare that it supports semantic Tokens.

Editor and settings

ycmd

Settings:

--   gopls Settings: {
--   "hints": {
--     "assignVariableTypes": true,
--     "compositeLiteralFields": true,
--     "compositeLiteralTypes": true,
--     "constantValues": true,
--     "functionTypeParameters": true,
--     "parameterNames": true,
--     "rangeVariableTypes": true
--   },
--   "hoverKind": "Structured",
--   "semanticTokens": true
-- }

Logs

https://gist.github.com/puremourning/6a531965b8a6ef2bcde713e6cf9f2ae2

@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 Aug 18, 2022
@gopherbot gopherbot added this to the Unreleased milestone Aug 18, 2022
@puremourning
Copy link
Author

puremourning commented Aug 18, 2022

Just to be clear, the specification states:

The server therefore needs to let the client know which numbers it is using for which types and modifiers. They do so using a legend, which is defined as follows:

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_semanticTokens

@suzmue suzmue modified the milestones: Unreleased, gopls/later Aug 19, 2022
@adonovan
Copy link
Member

adonovan commented Aug 25, 2022

Thanks for the bug report. For our own prioritization, could you tell us what problem this protocol issue presents to the end user?

@puremourning
Copy link
Author

puremourning commented Aug 25, 2022

I am the author of a language server protocol client. The impact is that semantic highlighting doesn't work without gopls-specific hacks.

I have made this work for our users, but would like to remove hacks or undocumented deviations from the specification, as any new version of gopls could break this workaround.

@adonovan
Copy link
Member

adonovan commented Aug 25, 2022

Thanks for clarifying. It doesn't sound like your need is urgent, but rest assured that we consider it a bug too.

@puremourning
Copy link
Author

puremourning commented Aug 26, 2022

sure, it's not urgent - thought I'd point it out as other clients may also benefit if they don't have the capability to do something bespoke.

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

No branches or pull requests

4 participants