unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: "Richard Copley" <rcopley@gmail.com>,
	66552@debbugs.gnu.org, "João Távora" <joaotavora@gmail.com>
Subject: bug#66552: 30.0.50; Eglot feature request: handle quirky code actions
Date: Tue, 17 Oct 2023 02:22:38 +0300	[thread overview]
Message-ID: <c28de036-e204-41fc-28bd-23b3f55c9873@gutov.dev> (raw)
In-Reply-To: <CAPM58ohYDG5hTMFBNUuqANQf+TV7dmJ99SSNZWL3m0E3-eS6kA@mail.gmail.com>

Cc'ing Joao.

On 15/10/2023 05:24, 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?
> 
> Here is an example request and reply. The reply is cut down from an
> original list of over 200 suggestions.
> 
> [client-request]
> (:jsonrpc "2.0" :id 777 :method "textDocument/codeAction" :params
>            (:textDocument
>             (:uri"file:///s%3A/projects/lean/float/Fl/Lemmas.lean") :range
>             (:start (:line 50 :character 2) :end (:line 50 :character 8))
>             :context (:diagnostics [])))
> 
> [server-reply]
> (:result
>   [(:title "Apply 'Try this'" :kind "quickfix" :isPreferred t :edit
>            (:documentChanges
>             [(:textDocument
>               (:version 0 :uri"file:///s%3A/Fl/Lemmas.lean")
>               :edits
>               [(:range
>                 (:start (:line 50 :character 2) :end (:line 50 :character 8))
>                 :newText "refine Nat.add_left_cancel ?_")])]
>             :changes nil :changeAnnotations nil))
>    (:title "Apply 'Try this'" :kind "quickfix" :isPreferred t :edit
>            (:documentChanges
>             [(:textDocument
>               (:version 0 :uri"file:///s%3A/Fl/Lemmas.lean")
>               :edits
>               [(:range
>                 (:start (:line 50 :character 2) :end (:line 50 :character 8))
>                 :newText "refine Nat.add_right_cancel ?_")])]
>             :changes nil :changeAnnotations nil))
>    (:title "Apply 'Try this'" :kind "quickfix" :isPreferred t :edit
>            (:documentChanges
>             [(:textDocument
>               (:version 0 :uri"file:///s%3A/Fl/Lemmas.lean")
>               :edits
>               [(:range
>                 (:start (:line 50 :character 2) :end (:line 50 :character 8))
>                 :newText "refine Nat.eq_of_mul_eq_mul_right ?_")])]
>             :changes nil :changeAnnotations nil))
>    (:title "Apply 'Try this'" :kind "quickfix" :isPreferred t :edit
>            (:documentChanges
>             [(:textDocument
>               (:version 0 :uri"file:///s%3A/Fl/Lemmas.lean")
>               :edits
>               [(:range
>                 (:start (:line 50 :character 2) :end (:line 50 :character 8))
>                 :newText "refine Nat.eq_of_mul_eq_mul_left ?_")])]
>             :changes nil :changeAnnotations nil))]
>   :jsonrpc "2.0" :id 777)






  reply	other threads:[~2023-10-16 23:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-15  2:24 bug#66552: 30.0.50; Eglot feature request: handle quirky code actions Richard Copley
2023-10-16 23:22 ` Dmitry Gutov [this message]
2023-10-17  3:03   ` João Távora
2023-10-17  3:11 ` João Távora
2023-10-17 19:07   ` Richard Copley
2023-10-17 21:38     ` João Távora
2023-10-17 23:24       ` Richard Copley
2023-10-26 14:41   ` Richard Copley
2024-01-10 11:06     ` Stefan Kangas

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=c28de036-e204-41fc-28bd-23b3f55c9873@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=66552@debbugs.gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=rcopley@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).