From: Fredrik Bergroth Date: Mon, 10 Jan 2022 14:09:36 +0000 (+0100) Subject: Add eglot-show-configuration to debug workspace configurations X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~20 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=51ae66b50c9f73956039fddba72dbd7213926622;p=emacs.git Add eglot-show-configuration to debug workspace configurations 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 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index e399b29f09f..91733a8d7a6 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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)