From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#73452: Code lens support in eglot Date: Fri, 27 Sep 2024 08:55:16 +0300 Message-ID: <864j61abej.fsf@gnu.org> References: <05f4d679-d2cd-409c-aafd-bfac2eda7a21@fbengineering.ch> <86v7ylcatg.fsf@gnu.org> <86ikukc6lz.fsf@gnu.org> <402b37ee-8f2a-4c44-8861-be9054ed5255@fbengineering.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10602"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73452@debbugs.gnu.org, joaotavora@gmail.com To: Federico Beffa Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 27 07:58:54 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1su40D-0002Zf-9V for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 27 Sep 2024 07:58:53 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1su3zw-0003Ch-RY; Fri, 27 Sep 2024 01:58:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1su3zv-0003CW-0k for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 01:58:35 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1su3zu-0001hr-NQ for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 01:58:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-version:References:In-Reply-To:From:Date:To:Subject; bh=NjbewltVjoz3ORkyfHNY33ZNGjKlQDWA4UKhFI41izA=; b=AYx5OFb+0vG366wzr3bkK0UI5fjvX4P7HJK4NYITGgambT1oPzzjX1qS2DyO/BMXfd16bNPcD/DrJkkzVIsCqdCQl1VZvEWvWuKvDl3E9WBnIVJe1KxFp6DuY+39Ml1PD4BXN6dcOr5awsbB4OaEA5avjc5/zOwuCG9RtPcN1l3J9VmnW3tkGqsTCMqUpPqgEYGWUYInKRGTi65nCGEb2kHziRpwFjdIM6K4zv7fbEjoHo9iDTWOpFRU26SMJTls1b2MEiHUilaazb1eSGw1GDqa0+4w6I3Ry0AfWTm5whxeJvt1beqlxy2MiaqrXRawCcnJyehyucS4kxVW3C0mwg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1su40M-0007N9-HA for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 01:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 27 Sep 2024 05:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73452 X-GNU-PR-Package: emacs Original-Received: via spool by 73452-submit@debbugs.gnu.org id=B73452.172741668828257 (code B ref 73452); Fri, 27 Sep 2024 05:59:02 +0000 Original-Received: (at 73452) by debbugs.gnu.org; 27 Sep 2024 05:58:08 +0000 Original-Received: from localhost ([127.0.0.1]:45259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1su3zU-0007Lh-C9 for submit@debbugs.gnu.org; Fri, 27 Sep 2024 01:58:08 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36428) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1su3zQ-0007L7-H3 for 73452@debbugs.gnu.org; Fri, 27 Sep 2024 01:58:07 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1su3wm-0001aX-4u; Fri, 27 Sep 2024 01:55:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=NjbewltVjoz3ORkyfHNY33ZNGjKlQDWA4UKhFI41izA=; b=rqQfEE9nwT5kKQ9OX+DU k/S4JL7ipx5plHloTLc6VE8hgztM78slxZZx/LKk6nqhe6c11SYitd84c7K8oyIia49iTLpuoXm4D Rz6LXv3SzM0eFVPL+4E38RpzPp+w5ZEKfB9gknXgYVwplMwVevkTzWvZkqCqC/CMLalDczwQ0K1jO bs3DeK6uy8KLy5/nBHSiMZ+2oTsGkPhaHCDRgpXa5mEi5TkV4a78loHTVkkWGU3rDM+SmVqOAy7dF 5beoklIULkLF7SAfUrbCUxyHvN9IuTP3I+poX7LAbRodVdBhPOGGvNZD0OWrWei7yshi9cv5qZtrH xf4S/jsNNPTqTA==; In-Reply-To: <402b37ee-8f2a-4c44-8861-be9054ed5255@fbengineering.ch> (message from Federico Beffa on Thu, 26 Sep 2024 17:35:21 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292491 Archived-At: > Date: Thu, 26 Sep 2024 17:35:21 +0200 > Cc: 73452@debbugs.gnu.org > From: Federico Beffa > > Code lenses are not too different from code actions (see below). A new > abstraction would make sense only if you plan to reorganize the entire > `eglot` code. In that case the concept of a "code reviewer" or > "assistant" could be useful, with functions like > - signal-error > - suggest > - exec-in-comment > - visit > - show-references > - show-type > ... > > > > >>> Read the last parts of the discussion I linked to if you're > >>> interested. > >> I did, but couldn't answer my questions, because the discussion relies > >> heavily on VSCode features with which I'm not familiar and whose > >> descriptions I saw didn't clarify the issue. > > Yes, that's part of the problem. This LSP feature is a VSCode/VStudio MS > > UI thing, and I also don't know those things well. The few times I open > > these apps I get turned off by all the clutter. > > I'm not an expert, but my understanding is as follows: > > A code lens represents a command that should be shown to users along > with source code text, like the number of references, a way to run > tests, etc. It goes like this: > > 1. The client sends a code lens request. > 2. The server replies with commands along with the text to show to the user. > 3. When/if the user chooses to run any of them, the client sends the > request to run it to the server. (As an option it's also possible for > the client to run the command.) > 4. The server executes the command and replies with the change in the > source code. > > So, the main difference between code actions and code lens is the fact > that the latter should show some text to the user. A few examples from > the Haskell language server are: > > - You can run some code in comments and get the result added. Here is a > screenshot from VSCode > > "Refresh..." is sent by the server. (It's "Execute..." before the first > execution). > > - An "import" lens suggests changing a library import to only import > used symbols > > > - Expressions without type annotations get a lens showing the type and, > if executed, it's added. > > > You may not like the VSCode UI, but Emacs doesn't have to use exactly > the same interface. The client decides how to present the code lens > text, and you may choose to only display it in some circumstances. > > Code lenses are part of the core features of LSP since several years and > are used by many servers. If Emacs ignores them, all those features are > not available in Emacs. A client can't decide that it prefers to use > actions instead of lenses. It's the server how decides how to offer the > functionality. Thanks. So basically, code lenses are suggestions for actions, and those suggestions are presented as a kind of overlays over the code? If so, I think the infrastructure we need is mostly the presentation of the lenses and how the users select the action(s) they want?