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: gopls ignores the fact that the client doesn't support hierarchicalDocumentSymbolSupport #34893

Closed
edkolev opened this issue Oct 14, 2019 · 2 comments
Labels
Documentation FrozenDueToAge gopls Issues related to the Go language server, gopls. help wanted NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@edkolev
Copy link

edkolev commented Oct 14, 2019

What version of Go are you using (go version)?

$ go version

go version go1.13.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/edkolev/Library/Caches/go-build"
GOENV="/Users/edkolev/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/edkolev/gocode"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/v7/fnkk7zpd0hvdsl45hpj92cc40000gn/T/go-build203896190=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Start emacs, install eglot LSP client
  2. Open a main.go with contents
package main

func main() {
	print("hello")
}
  1. Run M-x eglot. At this point eglot notifies gopls for its capabilities as a client. Note that it doesn't report hierarchicalDocumentSymbolSupport as supported.
:capabilities
                      (:workspace
                       (:applyEdit t :executeCommand
                                   (:dynamicRegistration :json-false)
                                   :workspaceEdit
                                   (:documentChanges :json-false)
                                   :didChangeWatchedFiles
                                   (:dynamicRegistration t)
                                   :symbol
                                   (:dynamicRegistration :json-false))
                       :textDocument
                       (:synchronization
                        (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
                        :completion
                        (:dynamicRegistration :json-false :completionItem
                                              (:snippetSupport t)
                                              :contextSupport t)
                        :hover
                        (:dynamicRegistration :json-false)
                        :signatureHelp
                        (:dynamicRegistration :json-false :signatureInformation
                                              (:parameterInformation
                                               (:labelOffsetSupport t)))
                        :references
                        (:dynamicRegistration :json-false)
                        :definition
                        (:dynamicRegistration :json-false)
                        :documentSymbol
                        (:dynamicRegistration :json-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]))
                        :documentHighlight
                        (:dynamicRegistration :json-false)
                        :codeAction
                        (:dynamicRegistration :json-false :codeActionLiteralSupport
                                              (:codeActionKind
                                               (:valueSet
                                                ["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"])))
                        :formatting
                        (:dynamicRegistration :json-false)
                        :rangeFormatting
                        (:dynamicRegistration :json-false)
                        :rename
                        (:dynamicRegistration :json-false)
                        :publishDiagnostics
                        (:relatedInformation :json-false))
                       :experimental nil)
  1. Run M-x imenu which causes the following communication, note that gopls replies with a hierarchical document symbol response.
client-request (id:4) Sat Oct 12 11:59:33 2019:
(:jsonrpc "2.0" :id 4 :method "textDocument/documentSymbol" :params
          (:textDocument
           (:uri "file:///Users/edkolev/dev/go-play/main.go")))

server-reply (id:4) Sat Oct 12 11:59:33 2019:
(:jsonrpc "2.0" :result
          [(:name "main" :detail "()" :kind 12 :range
                  (:start
                   (:line 2 :character 0)
                   :end
                   (:line 4 :character 1))
                  :selectionRange
                  (:start
                   (:line 2 :character 5)
                   :end
                   (:line 2 :character 9)))]
          :id 4)
  1. Emacs shows an error

What did you expect to see?

The list of symbols in the main.go file, i.e. the main() function.

What did you see instead?

Emacs error.

Notes

@gopherbot gopherbot added this to the Unreleased milestone Oct 14, 2019
@gopherbot gopherbot added Documentation Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Oct 14, 2019
@golang golang deleted a comment from gopherbot Oct 15, 2019
@stamblerre stamblerre added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 15, 2019
@ghost
Copy link

ghost commented Oct 15, 2019

Claimed! :-)

@stamblerre stamblerre modified the milestones: Unreleased, gopls unplanned Dec 4, 2019
@stamblerre stamblerre modified the milestones: gopls unplanned, gopls/v1.0.0, gopls/v0.4.0 Jan 29, 2020
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/221823 mentions this issue: internal/lsp: support when hierarchicalDocumentSymbolSupport is false

@golang golang locked and limited conversation to collaborators Mar 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge gopls Issues related to the Go language server, gopls. help wanted NeedsFix The path to resolution is known, but the work has not been done. 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