From: Felicián Németh Date: Tue, 12 Nov 2019 12:50:11 +0000 (+0100) Subject: Support serverinfo of lsp 3.15.0 X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~275 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b5f02979b6c4a6f8b57279768258a5884e1fac5a;p=emacs.git Support serverinfo of lsp 3.15.0 Add support for serverInfo from the upcoming specification. This changeset just stores the info sent by the server and slightly changes a greeting message. But it opens up the possibility to identify servers even when eglot uses a TCP connection and therefore makes possible to implement server specific features (in eglot-x). Old message: ``` Connected! Server `EGLOT (test-ccls/c++-mode)' now managing `c++-mode' buffers in project `test-ccls'. ``` New message: ``` Connected! Server `ccls' now managing `c++-mode' buffers in project `test-ccls'. ``` * eglot.el (eglot--lsp-interface-alist): Extend it with serverInfo. (eglot-lsp-server): Add member variable server-info. (eglot--connect): Store server-info and display server's name when connected. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 0022737fb9d..a7b5d590045 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -229,7 +229,7 @@ let the buffer grow forever." (DocumentHighlight (:range) (:kind)) (FileSystemWatcher (:globPattern) (:kind)) (Hover (:contents) (:range)) - (InitializeResult (:capabilities)) + (InitializeResult (:capabilities) (:serverInfo)) (Location (:uri :range)) (LogMessageParams (:type :message)) (MarkupContent (:kind :value)) @@ -531,6 +531,9 @@ treated as in `eglot-dbind'." (capabilities :documentation "JSON object containing server capabilities." :accessor eglot--capabilities) + (server-info + :documentation "JSON object containing server info." + :accessor eglot--server-info) (shutdown-requested :documentation "Flag set when server is shutting down." :accessor eglot--shutdown-requested) @@ -856,11 +859,12 @@ This docstring appeases checkdoc, that's all." server) :capabilities (eglot-client-capabilities server)) :success-fn - (eglot--lambda ((InitializeResult) capabilities) + (eglot--lambda ((InitializeResult) capabilities serverInfo) (unless cancelled (push server (gethash project eglot--servers-by-project)) (setf (eglot--capabilities server) capabilities) + (setf (eglot--server-info server) serverInfo) (jsonrpc-notify server :initialized (make-hash-table)) (dolist (buffer (buffer-list)) (with-current-buffer buffer @@ -888,7 +892,9 @@ This docstring appeases checkdoc, that's all." (eglot--message "Connected! Server `%s' now managing `%s' buffers \ in project `%s'." - (jsonrpc-name server) managed-major-mode + (or (plist-get serverInfo :name) + (jsonrpc-name server)) + managed-major-mode (eglot--project-nickname server)) (when tag (throw tag t)))) :timeout eglot-connect-timeout