]> git.eshelyaron.com Git - emacs.git/commitdiff
Support serverinfo of lsp 3.15.0
authorFelicián Németh <felician.nemeth@gmail.com>
Tue, 12 Nov 2019 12:50:11 +0000 (13:50 +0100)
committerFelicián Németh <felician.nemeth@gmail.com>
Wed, 13 Nov 2019 14:36:10 +0000 (15:36 +0100)
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.

lisp/progmodes/eglot.el

index 0022737fb9db978f5d90f54b1d2bb3d4d8077ca9..a7b5d5900456a80712373496a8be9ac159643b9d 100644 (file)
@@ -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