unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 73452@debbugs.gnu.org, federico.beffa@fbengineering.ch,
	joaotavora@gmail.com
Subject: bug#73452: Code lens support in eglot
Date: Fri, 27 Sep 2024 22:27:23 +0300	[thread overview]
Message-ID: <5529baea-36d6-4ee7-9d7d-a83dfd7f71c9@gutov.dev> (raw)
In-Reply-To: <86tte18u52.fsf@gnu.org>

On 27/09/2024 09:53, Eli Zaretskii wrote:
>> Date: Fri, 27 Sep 2024 03:20:35 +0300
>> Cc: 73452@debbugs.gnu.org, federico.beffa@fbengineering.ch
>> From: Dmitry Gutov <dmitry@gutov.dev>
>>
>> It seems to me that a brief description would be "buttons that do
>> things", but unlike Code Actions - already available in Eglot - those
>> things don't typically alter the text that they act on.
> 
> This seems to be in contradiction with what's been said previously
> (and my understanding from reading the linked pages): that code lenses
> are UI sugar for server actions.

There is no such term as "server action" in LSP, so the above statement 
is probably both true and false at the same time. But lenses are not 
sugar on top of code actions, if that's what you means.

 > (If this is different from "Code> Actions", then I guess there's some 
subtlety here I don't get yet.)

They are different parts of the LSP protocol, even though, practically, 
some "actions" could be implemented as either. Anyway to quote from 
https://go.googlesource.com/tools/+/master/gopls/doc/features/transformation.md:

   A code action is an action associated with a portion of the file. Each
   time the selection changes, a typical client makes a textDocument/
   codeAction request for the set of available actions, then updates its
   UI elements (menus, icons, tooltips) to reflect them. The VS Code
   manual describes code actions as “Quick fixes + Refactorings”.

   A codeAction request delivers the menu, so to speak, but it does not
   order the meal. Once the user chooses an action, one of two things
   happens. In trivial cases, the action itself contains an edit that the
   client can directly apply to the file. But in most cases the action
   contains a command, similar to the command associated with a code
   lens.

   ...

   The main difference between code lenses and code actions is this:

   * a codeLens request obtains commands for the entire file. Each
   command specifies its applicable source range, and typically appears
   as an annotation on that source range.
   * a codeAction request obtains commands only for a particular range:
   the current selection. All the commands are presented together in a
   menu at that location.

To give a couple of example: 'rename' is a code action, whereas 'run the 
test near point' is a code lens. Because the server will tell you which 
tests are defined in the current file and at which positions.

> You yourself say later that "the strongest point of code lenses is
> advertising actions specific to language and/or to a context", which
> seems to affirm my understanding.  And since Eglot already supports
> actions, what seems to be missing is that UI sugar, i.e. a way of
> presenting the lenses and a way for the user to select those he/she
> wants to invoke.

Yes, and what might be missing is not really a UI feature (we know how 
to print buttons, after all), but higher-level decisions, I guess, for 
how and when to print such buttons. It shouldn't be very difficult to 
implement, but people might disagree on the finer details of behavior.





  reply	other threads:[~2024-09-27 19:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24 14:02 bug#73452: Code lens support in eglot Federico Beffa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-24 14:26 ` João Távora
2024-09-24 15:48   ` Eli Zaretskii
2024-09-24 21:01     ` João Távora
2024-09-25 11:31       ` Eli Zaretskii
2024-09-26  8:09         ` João Távora
2024-09-26 15:35           ` Federico Beffa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-26 17:12             ` João Távora
2024-09-26 19:07               ` Federico Beffa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-26 23:47                 ` Dmitry Gutov
2024-09-27  5:55             ` Eli Zaretskii
2024-09-27  0:20         ` Dmitry Gutov
2024-09-27  6:53           ` Eli Zaretskii
2024-09-27 19:27             ` Dmitry Gutov [this message]
2024-09-25  7:04   ` Federico Beffa via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-25  7:50     ` João Távora

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5529baea-36d6-4ee7-9d7d-a83dfd7f71c9@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=73452@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=federico.beffa@fbengineering.ch \
    --cc=joaotavora@gmail.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).