From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Richard Copley Newsgroups: gmane.emacs.bugs Subject: bug#66552: 30.0.50; Eglot feature request: handle quirky code actions Date: Tue, 17 Oct 2023 20:07:46 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26258"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66552@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 17 21:09:30 2023 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 1qspRa-0006j5-6j for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Oct 2023 21:09:30 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qspQp-0001u2-Bd; Tue, 17 Oct 2023 15:08:43 -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 1qspQj-0001tQ-Dv for bug-gnu-emacs@gnu.org; Tue, 17 Oct 2023 15:08:37 -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 1qspQj-0001S7-5h for bug-gnu-emacs@gnu.org; Tue, 17 Oct 2023 15:08:37 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qspR8-00067Y-Dv for bug-gnu-emacs@gnu.org; Tue, 17 Oct 2023 15:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Richard Copley Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Oct 2023 19:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66552 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 66552-submit@debbugs.gnu.org id=B66552.169756972623504 (code B ref 66552); Tue, 17 Oct 2023 19:09:02 +0000 Original-Received: (at 66552) by debbugs.gnu.org; 17 Oct 2023 19:08:46 +0000 Original-Received: from localhost ([127.0.0.1]:32803 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qspQs-000672-AH for submit@debbugs.gnu.org; Tue, 17 Oct 2023 15:08:46 -0400 Original-Received: from mail-vk1-xa29.google.com ([2607:f8b0:4864:20::a29]:46196) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qspQq-00066l-Na for 66552@debbugs.gnu.org; Tue, 17 Oct 2023 15:08:45 -0400 Original-Received: by mail-vk1-xa29.google.com with SMTP id 71dfb90a1353d-49d39f07066so2535081e0c.0 for <66552@debbugs.gnu.org>; Tue, 17 Oct 2023 12:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697569693; x=1698174493; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=3CgzncwspZZPB6YPRK0oeiapP7KTFyAAmLLnbM0P55Q=; b=FGBhTDFHvF1IAIUG5Tu43BWD5E4S1n1VTmBW5XeSsafs7YyYOCpAnwqcrr+7N6HRZq a/LJZaIjGURJIDauLe3CZOsZY5lC6/eW4pf3khkd04cVvynRsSsxpX4yaxdP9IPFcVle hP0/v/EQwxC9e+WrhFcSXgv0TmDtptNJtFQ5HNPGo+bd9YPiY7GW1vZhOWA1fAW1KqI5 W9aF5m963A2+Ltsac3+rclwPJvYre/9R8pxx57YG5Og69pTGT20XM70LNMawCqJuky4t vqPz47MN2ssdGHUVBB19Wr69zKpNONCaseiJzf5AOLdKByoNuitpZezCgWAb3gHSMrXI OqHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697569693; x=1698174493; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3CgzncwspZZPB6YPRK0oeiapP7KTFyAAmLLnbM0P55Q=; b=fUtEJDAlld4gvLb1USJ9E+SFbDkTJbiSBESpOkbPVGfdOoyKfsrnPgkIaf1qwkeJ+v KI/bqL9vB1FhXlv1SB+80t2PqnMZqwZR9HnJNYs679e5KJVqqvA1I1we7NHgcMnKt0qI tvPYtsXhq6rzje5UpYrf5CZ0zgAXLzxXPXzurt0DnaHl8k92EueNY6oRmevGtFC0rslW 1+mKGQGZqu/C3oOmnE5WAUzLlpNsD4H9pg4sTgzyYrCmiff32DC7N6Eh/uw3N17HakMM vrtDtIDYg5ztidRuHtk0Lc7lQE3X+1+5faqcOfNHYZmkz5lhYnjt68C3K0JymLpkXgIO RqzQ== X-Gm-Message-State: AOJu0YyHQf6COpbd2o42yJRlwsEt2GoLO/Yhm9os+EEZ3oETjVN56gqb frBDwEXC1ZzNYmOyXUGeQEkIOUMi4gzTupZcSYE= X-Google-Smtp-Source: AGHT+IEAAv0subPjbBLTcOiKD2qxzcGc0TnCFgKWGEuP+yMkFSVqV7Kl/u4bH3lZvygsqpqbIvi9N/ZKem71rLOv1RE= X-Received: by 2002:a05:6122:a02:b0:49a:9146:ec02 with SMTP id 2-20020a0561220a0200b0049a9146ec02mr3849790vkn.1.1697569693533; Tue, 17 Oct 2023 12:08:13 -0700 (PDT) In-Reply-To: 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:272630 Archived-At: On Tue, 17 Oct 2023 at 04:11, Jo=C3=A3o T=C3=A1vora = wrote: > > On Sun, Oct 15, 2023 at 3:25=E2=80=AFAM Richard Copley wrote: > > > > The language server for Lean 4 [1] provides code actions with a couple > > of features that make it difficult to apply them from within Eglot. > > > > [1] https://github.com/leanprover/lean4 > > > > Firstly, the textDocument version field has the value 0, which is > > generally not equal to the version in `eglot--versioned-identifier', > > resulting in the error "Edits on `%s' require version %d, you have %d" > > from `eglot--apply-text-edits'. > > > > Secondly, all the suggestions have the same title ("Apply 'Try this'"), > > which means an alist using the title as the key can't be used in > > completing-read as in `eglot--read-execute-code-action'. > > > > Could you provide options to ignore the version, and to use the newText > > (JSONPath $.result[:1].edit.documentChanges[:1].edits[:1].newText) > > instead of the title? > > I understand the problem, thanks for describing it nicely. Thanks for reading it! > Anyway, I don't think patching this in a client like Eglot is > recommended. Both these thinks are bugs in the language server > and should be fixed there. Eglot is an LSP client which works > with tens, maybe hundreds, of servers, it can't bloat itself > to work around every server's quirks. > > For the version field, servers don't _have_ to send one (if I > remember correctly). To judge from comments in the Lean 4 sources, the authors wanted to send null, but found that VS code requires a version number (which it ignores), so they send 0 as a workaround. It apparently didn't occur to them to send the correct version, which it turns out is readily available. Indeed, it's extra work to throw it away. > If a servers sends no field, Eglot will > ignore it. If it sends a wrong one, Eglot won't. > You could work around it with a monkey-patch by advising > eglot--apply-text-edits to always have a null second argument. I'll probably go with that. Thanks for the suggestion. It's a shame that this will affect all languages. It would be nice if I could use a defmethod dispatching on a subclass of eglot-lsp-server! But eglot--apply-text-edits doesn't take a server, so it isn't generic. > The second labeling problem is even more bizarre Again, you > can probably monkey-patch Eglot to work around it. Here I'm not sure I agree. The title is only specified to be "A short, human-readable, title for this code action". In this case the suggestions are computed, and inventing unique friendly names for them isn't feasible. "Apply 'Try this'" seems sensible. It refers to the text of the corresponding diagnostic, "Try this : ". > But I really think you should report these two things to the > language server authors. I think so too, but raising issues against the core language doesn't seem to be encouraged. They're going through a reorganisation, so perhaps things will improve. > Jo=C3=A3o