From: Felician Nemeth Date: Sun, 2 Mar 2025 22:06:38 +0000 (+0000) Subject: Eglot: implement additionalPropertiesSupport for showMessage X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=57034317ef00b26dfd6875a9f8789f40dd4ee35a;p=emacs.git Eglot: implement additionalPropertiesSupport for showMessage This feature was introduced in LSP v3.16. https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#window_showMessageRequest * lisp/progmodes/eglot.el (eglot-client-capabilities): Set window/showMessage/messageActionItem/additionalPropertiesSupport to t. (eglot-handle-request window/showMessageRequest): Return the whole selected MessageActionItem, not just its title. Co-authored-by: João Távora (cherry picked from commit 18c81b76bc4c0fcd3effac3114763bae887a9d67) --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 9dc8281692d..cdb06efbea4 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1087,6 +1087,8 @@ object." [,@(mapcar #'car eglot--tag-faces)]))) :window `(:showDocument (:support t) + :showMessage (:messageActionItem + (:additionalPropertiesSupport t)) :workDoneProgress ,(if eglot-report-progress t :json-false)) :general (list :positionEncodings ["utf-32" "utf-8" "utf-16"]) :experimental eglot--{}))) @@ -2564,18 +2566,19 @@ still unanswered LSP requests to the server\n")))) (cl-defmethod eglot-handle-request (_server (_method (eql window/showMessageRequest)) &key type message actions &allow-other-keys) - "Handle server request window/showMessageRequest." - (let* ((actions (append actions nil)) ;; gh#627 + "Handle server request window/showMessageRequest. +ACTIONS is a list of MessageActionItem, this has the user choose one and +return it back to the server. :null is returned if the list was empty." + (let* ((actions (mapcar (lambda (a) (cons (plist-get a :title) a)) actions)) (label (completing-read (concat (format (propertize "[eglot] Server reports (type=%s): %s" 'face (if (or (not type) (<= type 1)) 'error)) type message) "\nChoose an option: ") - (or (mapcar (lambda (obj) (plist-get obj :title)) actions) - '("OK")) - nil t (plist-get (elt actions 0) :title)))) - (if label `(:title ,label) :null))) + (or actions '("OK")) + nil t (caar actions)))) + (if (and actions label) (cdr (assoc label actions)) :null))) (cl-defmethod eglot-handle-notification (_server (_method (eql window/logMessage)) &key _type _message)