From 3b7273f4ae3623962c5d5fdc922a62af1136f448 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Tue, 11 Jul 2023 00:09:08 +0100 Subject: [PATCH] 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 --- lisp/progmodes/eglot.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 -- 2.39.5