From: Alan Donovan via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "João Távora" <joaotavora@gmail.com>
Cc: sebastian.poeplau@mailbox.org,
Felician Nemeth <felician.nemeth@gmail.com>,
62116@debbugs.gnu.org
Subject: bug#62116: RFE: eglot: support window.showDocument LSP RPC
Date: Fri, 5 May 2023 13:35:49 -0400 [thread overview]
Message-ID: <CAPVWWDW0rA7HZYYYC_3jjXtZ+ApPjjUk1q5sPRg-j8_yt27rFQ@mail.gmail.com> (raw)
In-Reply-To: <87pm7esnl0.fsf@gmail.com>
On Fri, 5 May 2023 at 13:17, João Távora <joaotavora@gmail.com> wrote:
> Yes, but I don't really think this is a design problem with gopls. Or
> at least I don't think Eglot should not make these nested calls in the
> first place. So I would like to understand how this nested RPC requests
> takes place. From my reading of the eglot.el's code, there aren't any -- that
> is, with Emacs -Q -- at least.
>
> So I would like to reproduce this situation to analyse what can be done.
>
> I have gopls on my archlinux machine, though I seldom program in Go.
> How does one go about setting up gopls in terms of workspace
> configuration, command line options, etc so that the feature is
> exercised? Also, can I somehow make use of this feature with any small
> hello world project or do I need something bigger? In that case can you
> point me to a git repository that I can download, or attach that
> project?
Sure. You can reproduce the experimental setup like so:
1. git clone golang.org/x/tools
2. Download and checkout this commit:
https://go-review.git.corp.google.com/c/tools/+/474735
(It's a stack of 2 messy CLs on top of an old master, but it works.)
3. (cd gopls && go install)
This puts gopls on your $PATH.
4. killall gopls
So that eglot uses the new executable.
5. Load the definition of the eglot-handle-request window/showDocument handler.
6. Also load this function.
(defun gopls--package-docs ()
"Open the documentation for this Go package in a browser."
(interactive)
(save-excursion
;; TODO(adonovan): We currently cram this functionality into the
;; textDocument/definition RPC applied to the "package" keyword.
;; Do something more principled.
(goto-char 0)
(re-search-forward "^package ")
(beginning-of-line)
(xref-find-definitions 'package)))
7. Visit a Go file, e.g. go/analysis/analysis.go. Move cursor to the
"package" keyword.
8. Run the gopls--package-docs command. This sends an "definitions"
RPC request for the package keyword. The server has been modified to
interpret this as a (strange) request to open a web page of package
documentation. The server sends a showDocument request
(http://localhost...) to the client. The client handler
eglot-handle-request opens a browser. You should see a page full of
links to source declarations.
9. Click on one of these links. This causes the web server (gopls) to
send another showDocument request, this time for file://..., to the
client, which causes gopls to open the file containing the declaration
and move to the correct position.
Removing the asynchrony causes the file:// downcall to get stuck
because it makes an upcall to gopls while the server is still waiting
for the showDocument downcall to finish.
> My main curiosity is where does this "click" happen in the first
> place... (that's related to my lack of hands-on experience with this
> feature, as described above)
See above.
> >> 2. if browse-url should be used for non-file: urls (it might open a browser window outside of Emacs, which IMO is fine.)
> >
> > What's the alternative? The very purpose of the operation is to open a
> > URL in a browser.
>
> Not always, IIUC. Sometimes it's just to open a file.
I think "file:" URLs should be opened by find-file in Emacs, and all
other URLs should go to browse-url (and thence Chrome, etc).
cheers
alan
next prev parent reply other threads:[~2023-05-05 17:35 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 15:34 bug#62115: RFE: eglot: support window.showDocument LSP RPC Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-10 15:40 ` bug#62116: " Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-03-11 12:56 ` João Távora
2023-03-11 13:17 ` Eli Zaretskii
2023-03-11 20:20 ` João Távora
2023-03-12 6:26 ` Eli Zaretskii
2023-04-22 9:08 ` Felician Nemeth
2023-05-05 6:03 ` Eli Zaretskii
2023-05-05 7:35 ` João Távora
2023-05-05 16:51 ` João Távora
2023-05-05 17:06 ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-05 17:19 ` João Távora
2023-05-05 17:35 ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-05-05 17:36 ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-11 23:12 ` João Távora
2023-05-06 12:46 ` Felician Nemeth
2023-05-08 13:23 ` Felician Nemeth
2023-05-08 16:36 ` João Távora
2023-05-09 17:03 ` Felician Nemeth
2023-05-09 17:13 ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-11 22:41 ` João Távora
2023-05-12 0:54 ` João Távora
2023-05-12 20:46 ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-15 8:48 ` João Távora
2023-05-13 10:21 ` Felician Nemeth
2023-05-13 11:57 ` João Távora
2023-05-14 19:02 ` Felician Nemeth
2023-05-14 19:19 ` João Távora
2023-05-15 10:45 ` João Távora
2023-05-16 18:34 ` João Távora
2023-05-24 22:13 ` Alan Donovan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-25 1:03 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPVWWDW0rA7HZYYYC_3jjXtZ+ApPjjUk1q5sPRg-j8_yt27rFQ@mail.gmail.com \
--to=bug-gnu-emacs@gnu.org \
--cc=62116@debbugs.gnu.org \
--cc=adonovan@google.com \
--cc=felician.nemeth@gmail.com \
--cc=joaotavora@gmail.com \
--cc=sebastian.poeplau@mailbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.