From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#73452: Code lens support in eglot Date: Fri, 27 Sep 2024 22:27:23 +0300 Message-ID: <5529baea-36d6-4ee7-9d7d-a83dfd7f71c9@gutov.dev> References: <05f4d679-d2cd-409c-aafd-bfac2eda7a21@fbengineering.ch> <86v7ylcatg.fsf@gnu.org> <86ikukc6lz.fsf@gnu.org> <86tte18u52.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33880"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: 73452@debbugs.gnu.org, federico.beffa@fbengineering.ch, joaotavora@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 27 21:40:51 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 1suGpd-0008cR-Tx for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 27 Sep 2024 21:40:50 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1suGpR-0008Gk-Lv; Fri, 27 Sep 2024 15:40:37 -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 1suGpO-0008GK-Bq for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 15:40: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 1suGpO-0002Vz-2p for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 15:40:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=In-Reply-To:From:References:MIME-Version:Date:To:Subject; bh=ggB100lfIjN6+dfE53D62Q9ULDy33HEKwuyDI2sEKOo=; b=SE/qGNGqMA5yv7or1lZvFvS0oPqWea6XzESCYx05EXXYGJymBH6S/zbZySCjLRNmNGER/PmYvVpx7XoioZmp/CuUGQv9OM7NhYoxYEMptk9s5kkhNoqJY7TbkgCiV2TVuTieaIOx9V8fd6Gp9jJlGM733R7Jr1Mh+LpWmXJ8xeYpa9Vt7VnXNHABCsj0tjN9TKsyvOW7WiLyUYgpDLwKLAjJo6j6c8xjkCgHxcFC5N7bNQy2IWv81DPYdHxW1wSwnp46NVXNhW0THCo9wi/lD2WfE9X3pCB0o9m5qm4vG+6jZ1Z4wkXMrQ0B54RyGE6KPURdaZhGduV9L3yL5U+ryw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1suGpq-00044B-3s for bug-gnu-emacs@gnu.org; Fri, 27 Sep 2024 15:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 27 Sep 2024 19:41: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.172746601914991 (code B ref 73452); Fri, 27 Sep 2024 19:41:02 +0000 Original-Received: (at 73452) by debbugs.gnu.org; 27 Sep 2024 19:40:19 +0000 Original-Received: from localhost ([127.0.0.1]:51380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suGp7-0003td-Cu for submit@debbugs.gnu.org; Fri, 27 Sep 2024 15:40:19 -0400 Original-Received: from fhigh-a2-smtp.messagingengine.com ([103.168.172.153]:49969) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1suGdH-0002y5-6g for 73452@debbugs.gnu.org; Fri, 27 Sep 2024 15:28:04 -0400 Original-Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id DCB6B1140151; Fri, 27 Sep 2024 15:27:28 -0400 (EDT) Original-Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Fri, 27 Sep 2024 15:27:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1727465248; x=1727551648; bh=ggB100lfIjN6+dfE53D62Q9ULDy33HEKwuyDI2sEKOo=; b= EbIO3R5B6vfIdtsui3A/k/nMBPjDjdnHUfigjQKE1q08ibq5stgDhHy4y1ZHtiV2 TWA14sinwXhqhMHj/7kHJUOWzKsH5e0WmZ+A113743xuw0sATvnYrAMbdluQZh+P dnAdurgH92uE5JCYIzyclFtUoy7UsOXtFsU53mFVDsLbfgGdpqgzK1ZB7784GUEq MGQNBCMwoVcyCug0oc+ZlGwM7CZHTPIBeE2p+Y+9YlEow8ie0Ivi78bW/coqDotf yzkhecfITHWmW7hqlsHE5/M8jv6OX8r3+gq9bC4OLq1f75THg6O7aEJFPY4T4esR QZDJLUBkNreew19f3SBVTw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1727465248; x= 1727551648; bh=ggB100lfIjN6+dfE53D62Q9ULDy33HEKwuyDI2sEKOo=; b=H I+X0fIwuyUmMj3MoiAgvBQAry4NNPPSKk8y3INd39yqjHyeuyyTZelIfFfCIfRDf uZQJEDbWzTw6Ejnq08km+SLO93Acovyi7fjbtCAY1X/TUgwkBsx31ZOKaXR6pwje vgLzeKev/Z2F6jkZ8X9jVrYSmurOHJN3nqbn83NnepUCFAo8Aj/n+BQwooR1zgOK Sn4teHoMi/kt9Cdgd4NEqOHCmV9UG7aP1TTCDaghEwnWQ6QwGMT4giDuRuarFd6l s7mVnX9WkTZRkQUIEwqwtlLqryHUYj+OnMaQkj7OT+tXpi8jh+DhY3QfVIfNsVHF KgRB+n6sfZX+VpfA+CPGQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddtledgudefiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddv jeenucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrd guvghvqeenucggtffrrghtthgvrhhnpeekfffhkeeuheeihfekvedtieekleejueduvdeu hefhvefgteefiedtuedthefhieenucffohhmrghinhepghhoohhglhgvshhouhhrtggvrd gtohhmpdhtrhgrnhhsfhhorhhmrghtihhonhdrmhgunecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomhepughmihhtrhihsehguhhtohhvrdguvghvpd hnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegvlhhi iiesghhnuhdrohhrghdprhgtphhtthhopehjohgrohhtrghvohhrrgesghhmrghilhdrtg homhdprhgtphhtthhopeejfeeghedvseguvggssghughhsrdhgnhhurdhorhhgpdhrtghp thhtohepfhgvuggvrh X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Sep 2024 15:27:26 -0400 (EDT) Content-Language: en-US In-Reply-To: <86tte18u52.fsf@gnu.org> 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:292535 Archived-At: 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 >> >> 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.