Skip to content

x/tools/gopls: missing textDocument/references results at first, in emacs+eglot+xrefs #53499

Closed
@adonovan

Description

@adonovan
  1. Start a new Emacs instance using go-mode, eglot, xrefs, and gopls.
  2. Find-file xtools/internal/lsp/cache/cache.go, where xtools is a git clone of golang.org/x/tools.
  3. Place cursor at func New identifier and call the xref-find-references Lisp command.
  4. Observe no results.
  5. Find-file xtools/internal/lsp/cmd/cmd.go then immediately kill the buffer.
  6. Repeat steps 2 and 3
  7. Observe these (correct) results:
internal/lsp/cmd/capabilities_test.go
46: 	c.Server = lsp.NewServer(cache.New(app.options).NewSession(ctx), c.Client)
internal/lsp/cmd/cmd.go
289: 		connection.Server = lsp.NewServer(cache.New(app.options).NewSession(ctx), connection.Client)
internal/lsp/cmd/serve.go
104: 		ss = lsprpc.NewStreamServer(cache.New(s.app.options), isDaemon)

This history of opened buffers should not affect the results of this query.

My first question at this point is: is the problem in Emacs or gopls? I tried to answer that by using the command-line client, but that exits zero with no output even when Emacs is working, which looks like a separate bug:

$ go run ./gopls/ --remote=localhost:8091 references internal/lsp/cache/cache.go:31:6
$

(Adding -v to the latter command displays a number of info logs concerning "go/packages.Load". Is the command-line tool trying to do the analysis itself instead of sending a request to the server?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions