From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Felician Nemeth Newsgroups: gmane.emacs.bugs Subject: bug#62198: [PATCH] Eglot: Send clientInfo during the initialize request Date: Wed, 15 Mar 2023 12:53:58 +0100 Message-ID: <87v8j28c2x.fsf@betli.tmit.bme.hu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="759"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cc: joaotavora@gmail.com To: 62198@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 15 12:55:23 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pcPj1-000AXQ-K6 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 15 Mar 2023 12:55:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcPik-0002eS-P0; Wed, 15 Mar 2023 07:55:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcPii-0002cm-1e for bug-gnu-emacs@gnu.org; Wed, 15 Mar 2023 07:55:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pcPig-0005XP-NJ for bug-gnu-emacs@gnu.org; Wed, 15 Mar 2023 07:55:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pcPig-0008MV-I9; Wed, 15 Mar 2023 07:55:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Felician Nemeth Original-Sender: "Debbugs-submit" Resent-CC: joaotavora@gmail.com, bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Mar 2023 11:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 62198 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: joaotavora@gmail.com Original-Received: via spool by submit@debbugs.gnu.org id=B.167888124732071 (code B ref -1); Wed, 15 Mar 2023 11:55:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Mar 2023 11:54:07 +0000 Original-Received: from localhost ([127.0.0.1]:39225 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcPhn-0008LD-1m for submit@debbugs.gnu.org; Wed, 15 Mar 2023 07:54:07 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:34612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcPhl-0008L6-LU for submit@debbugs.gnu.org; Wed, 15 Mar 2023 07:54:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcPhl-0002Xo-Ey for bug-gnu-emacs@gnu.org; Wed, 15 Mar 2023 07:54:05 -0400 Original-Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pcPhj-0005Pm-ID for bug-gnu-emacs@gnu.org; Wed, 15 Mar 2023 07:54:05 -0400 Original-Received: by mail-wm1-x32b.google.com with SMTP id o11-20020a05600c4fcb00b003eb33ea29a8so1008162wmq.1 for ; Wed, 15 Mar 2023 04:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678881241; h=mime-version:face:user-agent:message-id:date:subject:to:from:from :to:cc:subject:date:message-id:reply-to; bh=3CTEUkFPEjV/JsHL51EhPNDHO3lrI0kbG/qFQY4iCus=; b=O8mkeG4KNhZ9btRg5A+mmquPxx+H+KjHwt33EH+ARGHB8Kis7Y/pFdSNilxuEf4SO4 klzUAuq5YijO9nBTRyP/kMRnAl8OXYLCa8dZnwipkv1TXGV6D+qwGZiVoFfs4MNH2l25 kLa/82X+qMcU7+pgigWXdzBqvbWaX9DLkpzJZ5iXiwGWuyzH+A5VfC30KMpXX3lXihCW PDmJCIQX5aPUPWjS74bESDUfwdA3gYV8gKsrgwEGmXmPfrqnXeSuP1jV2lE6pW5TFSWd G00dAicmM5zeOahKQdK3oqZM9rTCZPS8y1fiBRqnGfrXuNQ+PApDxjzYrAgTCyVl9QTp keIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678881241; h=mime-version:face:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3CTEUkFPEjV/JsHL51EhPNDHO3lrI0kbG/qFQY4iCus=; b=PxDBWcHdcvE9olh7MYiEqgtMMqh+XQvObcNPxlDx5zbdWQcZag6q0F/BgOnHYWHszx KR6tKv6eaiRVI7JParYSlzyK9spOQd3BElZi08sZuD599974W/0w1WQ3EkKSEE8AWz1a 4oHxY+9MJOLwYjOYObSuwNGVkmchn4aZd7Z5DknvsXEEb44jnFRLWNx29ZGDGnSJPjcu QQR3t65+bAH6U95oVDMmY6p7ywZHBOsSyekHShd50ivAv5gEuFJ0SSqnIJQzy1AYqaIp Jo5LOLll0c1RkxgPD7BywnsWWaVODrZOdFz/YxG+yQfDPv2aNQ/sbTOjhx0qzwE2zbJf ffxA== X-Gm-Message-State: AO0yUKUJfytqf1xx/Tp06tN2aRCu9t6PnNYUc5SLoLuxJOF3mRm7a2wA HOCx4mxkjqolwWgbY83PFVNBhClwHhA= X-Google-Smtp-Source: AK7set9/piEGZbiJdG9MHKeqL+UtdJRAJ2qazXTqmWE4SgrGd0yYgDVIBywl30Dii+UeUwv2m5qrJQ== X-Received: by 2002:a05:600c:4f91:b0:3eb:3908:8541 with SMTP id n17-20020a05600c4f9100b003eb39088541mr18046239wmq.2.1678881241039; Wed, 15 Mar 2023 04:54:01 -0700 (PDT) Original-Received: from betli.gmail.com (catv-86-101-66-128.catv.fixed.vodafone.hu. [86.101.66.128]) by smtp.gmail.com with ESMTPSA id l10-20020a5d560a000000b002cfeffb442bsm2575804wrv.57.2023.03.15.04.54.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 04:54:00 -0700 (PDT) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAADFBMVEX5+fmhoaEwMDD/ ///TMNVWAAAAAWJLR0QDEQxM8gAAAAlwSFlzAAAPEgAADxIBIZvyMwAAAAd0SU1FB+AICBUfHgLs gGoAAAGXSURBVCjPRdK/b5tAFAfw753gBEwM2ApMbuVIqf+Ko0qiyhOu4sj2xJBYMn/FUdX7UUUZ OjHgyvf+yj6IcW6Bjx53934ADEvs8bmEr8UVoTYTOyJO9KoYsVofN8kILdbeJ8Li6YpZWop4xOK0 VdfIoXmkHn5/5D7/Ts/8THacSqnkKTcMTxgUkVzFnEIRTKwwYYSCvzfg16f0i8YApW/XG/Pm8R49 dXjxKmRnxv3OwooQWcv4RUYem1fsNe/WU63uk7AmYxk78y32/ee2tZB4fO+WcZ7lnIGEolXW1EGw LfkSuQ0XTgRefgNlfNwRNV6QhBxJ8JNxTMUPyBqTd0bjaAP5G7NJRU39z80hLOZTjqB7K3tEEFSj aEsuQew6qBxxyhHjVUR7H7NpC9iHJZGLMCEuweqAqE1BHbfK2oRIz9EHYA/+wiFWru9smeVfuWNZ 2+NFtX80UA1TvJNdytM4DwO4kY7bJz8Qcd0G0ceslZGkkeoBsjUHwF1+jjM3XHaXEZ7mGLfwPFO+ RV9QLY2iEdmDo78D/gNPaXVYqd+pyQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNi0wOC0wOFQyMzoz MDoyOCswMjowMGy/yHYAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTYtMDgtMDhUMjM6MzA6MjgrMDI6 MDAd4nDKAAAAAElFTkSuQmCC Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=felician.nemeth@gmail.com; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:257956 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I originally posted this patch on github: https://github.com/joaotavora/eglot/pull/818 Jo=C3=A3o 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. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Eglot-Send-clientInfo-during-the-initialize-request.patch >From 5fe9d054845382ce74c29bb338ffc737b0770542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= 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 ;;; 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 --=-=-=--