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

Open
edkolev opened this issue Oct 14, 2019 · 1 comment

Comments

@edkolev
Copy link

@edkolev 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

@ysz

This comment has been minimized.

Copy link

@ysz ysz commented Oct 15, 2019

Claimed! :-)

ysz added a commit to ysz/tools that referenced this issue Oct 17, 2019
Return empty flat list of all symbols if client
does not support hierarchical document symbols
ysz added a commit to ysz/tools that referenced this issue Oct 17, 2019
ysz added a commit to ysz/tools that referenced this issue Oct 17, 2019
ysz added a commit to ysz/tools that referenced this issue Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.