From: João Távora Date: Tue, 4 Oct 2022 20:11:38 +0000 (+0100) Subject: Add half-baked m-x eglot-list-connections X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~6 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b07fa37d04d98fcd9856f9f29fc1323850c230b7;p=emacs.git Add half-baked m-x eglot-list-connections Not very useful for now, but more functionality could be added later, like bindings for disconnecting a given connection, switching to its events buffers, or just listing some details like capabilities. * eglot.el (eglot-list-connections-mode, eglot-list-connections): New mode and function. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 010f8c86c70..918bba62103 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3316,6 +3316,40 @@ If NOERROR, return predicate, else erroring function." (when (eq ?! (aref arg 1)) (aset arg 1 ?^)) `(,self () (re-search-forward ,(concat "\\=" arg)) (,next))) + +;;; List connections mode + +(define-derived-mode eglot-list-connections-mode tabulated-list-mode + "" "Eglot Connection List Mode + +\\{sly-connection-list-mode-map}" + (setq-local tabulated-list-format + `[("Language server" 16) ("Project name" 16) ("Modes handled" 16)]) + (tabulated-list-init-header)) + +(defun eglot-list-connections () + "List currently active Eglot connections." + (interactive) + (with-current-buffer + (get-buffer-create "*EGLOT connections*") + (let ((inhibit-read-only t)) + (erase-buffer) + (eglot-list-connections-mode) + (setq-local tabulated-list-entries + (mapcar + (lambda (server) + (list server + `[,(or (plist-get (eglot--server-info server) :name) + (jsonrpc-name server)) + ,(eglot-project-nickname server) + ,(mapconcat #'symbol-name + (eglot--major-modes server) + ", ")])) + (cl-reduce #'append + (hash-table-values eglot--servers-by-project)))) + (revert-buffer) + (pop-to-buffer (current-buffer))))) + ;;; Hacks ;;;