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

add go-* shortcuts for various hard-to-find eglot operations #436

Closed
adonovan opened this issue Apr 18, 2024 · 2 comments
Closed

add go-* shortcuts for various hard-to-find eglot operations #436

adonovan opened this issue Apr 18, 2024 · 2 comments

Comments

@adonovan
Copy link
Contributor

adonovan commented Apr 18, 2024

Could we add these declarations to go-mode.el to make it easier for Go programmers to find common operations whose eglot command is somewhat obscure?

;; upcoming features of gopls/v0.16 that it would be nice to have go-mode support for in advance:

(eglot--code-action eglot-code-action-doc "source.doc")

(defalias 'go-doc #'eglot-code-action-doc
  "View documentation for the current Go package.")

(eglot--code-action eglot-code-action-freesymbols "source.freesymbols")

(defalias 'go-freesymbols #'eglot-code-action-freesymbols
  "View free symbols referenced by the current selection.")

;; existing features

(defalias 'go-inline #'eglot-code-action-inline
  "Inline the Go function call under the cursor.")

(defalias 'go-rename #'eglot-rename
  "Rename a Go symbol.")

[Edit: rename "freerefs" to "freesymbols"]

@dominikh
Copy link
Owner

Do we also need to support lsp-mode or will they add their own functions? And if we only support eglot, should we name them go-eglot-* instead? That'd also help avoid confusion between godoc and go-doc.

@adonovan
Copy link
Contributor Author

adonovan commented Apr 19, 2024

Good question. Perhaps these functions shouldn't presume which LSP client is in use, but should query (waved hands vigorously) whether the buffer is managed by eglot or lsp-mode and take appropriate action.

Much better that way than to include eglot in the symbol name; ideally most Emacs users wouldn't need to know anything about their LSP client.

gopherbot pushed a commit to golang/tools that referenced this issue May 20, 2024
This change adds a new "Show free symbols" (source.freesymbols)
code action that reports the set of free symbols referenced by
the selected region of Go source. The HTML report, produced by
the /freerefs endpoint of gopls' web server, includes an
itemized list of symbols, and a color-annotated source listing.

Symbols are presented in three groups: imported symbols
(grouped by package); package-level symbols and local symbols.
Each symbol is a link to either the integrated doc viewer
(for imported symbols) or the declaration, for others.

The feature is visible in editors as:
- VS Code: Source actions... > Show free references
- Emacs+eglot: M-x go-freesymbols
  (Requires (eglot--code-action go-freerefs "source.freesymbols")
   until dominikh/go-mode.el#436 is resolved.)

There are a number of opportunities for factoring in common
with RenderPackageDoc; they will be dealt with in a follow-up.

Also:
- a unit test of the freeRefs algorithm;
- an integration test of the web interaction.
- release notes.

Change-Id: I97de76686fcc28e445a72e7c611673c47e467dfd
Reviewed-on: https://go-review.googlesource.com/c/tools/+/539663
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Alan Donovan <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
adonovan added a commit to adonovan/go-mode.el that referenced this issue Jun 10, 2024
These four helper functions provide convenient ways to access
gopls server functionality without the user needing to worry
about how their LSP client does things. They should work for
eglot and lsp-mode (though I haven't tested the latter).

Updates dominikh/go-mode.el/dominikh#436
adonovan added a commit to adonovan/go-mode.el that referenced this issue Jun 11, 2024
These four helper functions provide convenient ways to access
gopls server functionality without the user needing to worry
about how their LSP client does things. They should work for
eglot and lsp-mode (though I haven't tested the latter).

Updates dominikh/go-mode.el/dominikh#436
adonovan added a commit to adonovan/go-mode.el that referenced this issue Jun 18, 2024
These four helper functions provide convenient ways to access
gopls server functionality without the user needing to worry
about how their LSP client does things. They should work for
eglot and lsp-mode (though I haven't tested the latter).

Updates dominikh/go-mode.el/dominikh#436
dominikh pushed a commit that referenced this issue Jun 20, 2024
These four helper functions provide convenient ways to access
gopls server functionality without the user needing to worry
about how their LSP client does things. They should work for
eglot and lsp-mode (though I haven't tested the latter).

Updates dominikh/go-mode.el/#436
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants