unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Felician Nemeth <felician.nemeth@gmail.com>
To: 62198@debbugs.gnu.org
Cc: joaotavora@gmail.com
Subject: bug#62198: [PATCH] Eglot: Send clientInfo during the initialize request
Date: Wed, 15 Mar 2023 12:53:58 +0100	[thread overview]
Message-ID: <87v8j28c2x.fsf@betli.tmit.bme.hu> (raw)

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]

I originally posted this patch on github:
https://github.com/joaotavora/eglot/pull/818

João requested to resubmit it here.

To recap: clientInfo arrived in LSP 3.15.0.  LSP clients can use
clientInfo to identify themselves in the initialize request.  This is
generally useful for various debugging tasks.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Eglot-Send-clientInfo-during-the-initialize-request.patch --]
[-- Type: text/x-diff, Size: 3436 bytes --]

From 5fe9d054845382ce74c29bb338ffc737b0770542 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= <felician.nemeth@gmail.com>
Date: Wed, 15 Mar 2023 12:34:06 +0100
Subject: [PATCH] Eglot: Send clientInfo during the initialize request

clientInfo arrived in LSP 3.15.0.  LSP clients can use clientInfo to
identify themselves in the initialize request.  This is generally
useful for various debugging tasks.

* lisp/progmodes/eglot.el (eglot--version): New defconst.
(eglot--connect): Send clientInfo using eglot--version.
* test/lisp/progmodes/eglot-tests.el
(eglot-test-client-info): New test.
---
 lisp/progmodes/eglot.el            | 12 ++++++++++++
 test/lisp/progmodes/eglot-tests.el | 18 ++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 037cc87148..f89c47ac4f 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -410,6 +410,14 @@ eglot-withhold-process-id
 \f
 ;;; Constants
 ;;;
+(defconst eglot--version
+  (eval-when-compile
+    (when byte-compile-current-file
+      (require 'lisp-mnt)
+      (lm-version byte-compile-current-file)))
+  "The version as a string of this version of Eglot.
+It is nil if Eglot is not byte-complied.")
+
 (defconst eglot--symbol-kind-names
   `((1 . "File") (2 . "Module")
     (3 . "Namespace") (4 . "Package") (5 . "Class")
@@ -1310,6 +1318,10 @@ eglot--connect
                                         (eq (jsonrpc-process-type server)
                                             'network))
                               (emacs-pid))
+                            :clientInfo (if eglot--version
+                                            `(:name "Eglot"
+                                              :version ,eglot--version)
+                                          '(:name "Eglot"))
                             ;; Maybe turn trampy `/ssh:foo@bar:/path/to/baz.py'
                             ;; into `/path/to/baz.py', so LSP groks it.
                             :rootPath (file-local-name
diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot-tests.el
index b95e527c51..f17b96848f 100644
--- a/test/lisp/progmodes/eglot-tests.el
+++ b/test/lisp/progmodes/eglot-tests.el
@@ -399,6 +399,24 @@ eglot-test-auto-reconnect
           (while (process-live-p proc) (accept-process-output nil 0.5)))
         (should (not (eglot-current-server)))))))
 
+(ert-deftest eglot-test-client-info ()
+  "Check clientInfo in Eglot's initialize request."
+  (skip-unless (executable-find "pylsp"))
+  (eglot--with-fixture
+   `(("project" . (("coiso.py" . "def coiso: pass"))))
+   (with-current-buffer
+       (eglot--find-file-noselect "project/coiso.py")
+     (eglot--sniffing (:client-requests c-reqs)
+       (should (eglot--tests-connect 10))
+       (eglot--wait-for (c-reqs 10)
+           (&key _id method params &allow-other-keys)
+         (when (string= method "initialize")
+           (let* ((clientInfo (plist-get params :clientInfo))
+                  (name (plist-get clientInfo :name))
+                  (version (plist-get clientInfo :version)))
+             (should (equal name "Eglot"))
+             (should (version<= "1.8" (or version "0"))))))))))
+
 (ert-deftest eglot-test-rust-analyzer-watches-files ()
   "Start rust-analyzer.  Notify it when a critical file changes."
   (skip-unless (executable-find "rust-analyzer"))
-- 
2.30.2


             reply	other threads:[~2023-03-15 11:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15 11:53 Felician Nemeth [this message]
2023-03-15 20:38 ` bug#62198: [PATCH] Eglot: Send clientInfo during the initialize request João Távora
2023-03-16 16:47   ` Felician Nemeth
2023-03-17  8:25     ` Michael Albinus
2023-03-19 12:15       ` Felician Nemeth
2023-03-19 13:23         ` João Távora
2023-03-22 16:05           ` Felician Nemeth
2023-03-22 18:40             ` João Távora
2023-03-23 16:03               ` Felician Nemeth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v8j28c2x.fsf@betli.tmit.bme.hu \
    --to=felician.nemeth@gmail.com \
    --cc=62198@debbugs.gnu.org \
    --cc=joaotavora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).