From: João Távora Date: Mon, 10 Jul 2023 23:09:08 +0000 (+0100) Subject: Eglot: add support for :codeAction/resolve X-Git-Tag: archive/raspbian/1%30.1+1-3+rpi1^2~2^2~20^2~5007 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3b7273f4ae3623962c5d5fdc922a62af1136f448;p=emacs.git Eglot: add support for :codeAction/resolve See https://github.com/emacs-grammarly/eglot-grammarly/issues/7. * lisp/progmodes/eglot.el (eglot--lsp-interface-alist): Augment CodeAction type. (eglot-execute): Consider :codeAction/resolve (eglot-client-capabilities): Advertise textDocument.codeAction.resolveSupport --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 537d8cac8ae..0c46e4a5290 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -463,7 +463,7 @@ This can be useful when using docker to run a language server.") (eval-and-compile (defvar eglot--lsp-interface-alist `( - (CodeAction (:title) (:kind :diagnostics :edit :command :isPreferred)) + (CodeAction (:title) (:kind :diagnostics :edit :command :isPreferred :data)) (ConfigurationItem () (:scopeUri :section)) (Command ((:title . string) (:command . string)) (:arguments)) (CompletionItem (:label) @@ -739,9 +739,12 @@ ACTION is an LSP object of either `CodeAction' or `Command' type." (server action) "Default implementation." (eglot--dcase action (((Command)) (eglot--request server :workspace/executeCommand action)) - (((CodeAction) edit command) - (when edit (eglot--apply-workspace-edit edit)) - (when command (eglot--request server :workspace/executeCommand command)))))) + (((CodeAction) edit command data) + (if (and (null edit) (null command) data + (eglot--server-capable :codeActionProvider :resolveProvider)) + (eglot-execute server (eglot--request server :codeAction/resolve action)) + (when edit (eglot--apply-workspace-edit edit)) + (when command (eglot--request server :workspace/executeCommand command))))))) (cl-defgeneric eglot-initialization-options (server) "JSON object to send under `initializationOptions'." @@ -825,6 +828,7 @@ ACTION is an LSP object of either `CodeAction' or `Command' type." :documentHighlight `(:dynamicRegistration :json-false) :codeAction (list :dynamicRegistration :json-false + :resolveSupport t :dataSupport t :codeActionLiteralSupport '(:codeActionKind (:valueSet