]> git.eshelyaron.com Git - emacs.git/commitdiff
Add eglot-show-configuration to debug workspace configurations
authorFredrik Bergroth <fbergroth@gmail.com>
Mon, 10 Jan 2022 14:09:36 +0000 (15:09 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sat, 17 Sep 2022 00:38:03 +0000 (01:38 +0100)
Also see https://github.com/joaotavora/eglot/issues/790, https://github.com/joaotavora/eglot/issues/1033.

GitHub-reference: per https://github.com/joaotavora/eglot/issues/590

lisp/progmodes/eglot.el

index e399b29f09f429ea04836850be9e54e381df15f3..91733a8d7a664eab117b89b74ce825af54ce2374 100644 (file)
@@ -75,6 +75,7 @@
 (require 'filenotify)
 (require 'ert)
 (require 'array)
+(require 'json)
 
 ;; ElDoc is preloaded in Emacs, so `require'-ing won't guarantee we are
 ;; using the latest version from GNU Elpa when we load eglot.el.  Use an
@@ -2210,6 +2211,18 @@ above.")
 ;;;###autoload
 (put 'eglot-workspace-configuration 'safe-local-variable 'listp)
 
+(defun eglot-show-configuration (server)
+  "Dump `eglot-workspace-configuration' as json for debugging."
+  (interactive (list (eglot--read-server "Server configuration"
+                                         (eglot-current-server))))
+  (let ((conf (eglot--workspace-configuration server)))
+    (with-current-buffer (get-buffer-create " *eglot configuration*")
+      (erase-buffer)
+      (insert (jsonrpc--json-encode conf))
+      (json-mode)
+      (json-pretty-print-buffer)
+      (pop-to-buffer (current-buffer)))))
+
 (defun eglot--workspace-configuration (server)
   (if (functionp eglot-workspace-configuration)
       (funcall eglot-workspace-configuration server)