GNU bug report logs - #59929
[PATCH]: Eglot, request progress notification on server init

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Danny Freeman <danny@HIDDEN>; Keywords: patch; dated Fri, 9 Dec 2022 20:08:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 59929 <at> debbugs.gnu.org:


Received: (at 59929) by debbugs.gnu.org; 9 Dec 2022 21:56:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 09 16:56:57 2022
Received: from localhost ([127.0.0.1]:38759 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p3lMX-0006K0-48
	for submit <at> debbugs.gnu.org; Fri, 09 Dec 2022 16:56:57 -0500
Received: from out2.migadu.com ([188.165.223.204]:16192)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <danny@HIDDEN>) id 1p3lMU-0006Js-SN
 for 59929 <at> debbugs.gnu.org; Fri, 09 Dec 2022 16:56:56 -0500
References: <87y1rgtk78.fsf@HIDDEN>
 <handler.59929.B.167061645810464.ack <at> debbugs.gnu.org>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dfreeman.email;
 s=key1; t=1670623013;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=elJDtJ27YjA9erITB8249lLWTrDHkDIzr6E6WmqiEeY=;
 b=JE6/JGy6ViypWflswhfUZJY6htzVXuwzOZETzDyDDVc03mdn5l+wvB5HA0XvwP/4pDs0qm
 ChSm7HzwQL/PNN1eCp+oANkseW0lqIsm9mRQWnC08FH0HJ7WFmVEEJgSHcdSkVEVHP3tXd
 W/Se+ecTfqXiQxGUGtvCSkJ7I9QAKhM=
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Danny Freeman <danny@HIDDEN>
To: 59929 <at> debbugs.gnu.org
Subject: Re: [PATCH]: Eglot, request progress notification on server init
Date: Fri, 09 Dec 2022 15:59:24 -0500
In-reply-to: <handler.59929.B.167061645810464.ack <at> debbugs.gnu.org>
Message-ID: <87k030tf4t.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 59929
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain


Another patch for consideration related to the first in this thread,
I've confirmed that clients can signal to servers that they are willing
to accept server initiated progress notifications with the client
capability in the attached patch. 

Note: there is still no server capability for this that can be ignored,
and the `eglot-report-progress` defcustom remains relevant here. Any
server initiated progress report will be ignored if
`eglot-report-progress` is `nil`.

Server will send a `window/workDoneProgress/create` request, but nothing
needs to be done with it. That request will be followed by the already
implemented $/progress notifications.

I need to find a server that I can test this with before this patch is
applied. I will report back in this thread once I've done that.

-- 
Danny Freeman


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Eglot-Enable-server-initiated-progress-reports.patch

From f30bd7d7396d29c38249a232e36f4b811dd27f56 Mon Sep 17 00:00:00 2001
From: dannyfreeman <danny@HIDDEN>
Date: Fri, 9 Dec 2022 15:55:28 -0500
Subject: [PATCH] Eglot: Enable server initiated progress reports

* lisp/progmodes/eglot
(eglot-client-capabilities): servers can initiate progress reports
---
 lisp/progmodes/eglot.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index cceb9fb5b32..e909efdb6f4 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -728,6 +728,7 @@ eglot-client-capabilities
   "What the Eglot LSP client supports for SERVER."
   (:method (s)
            (list
+            :window (list :workDoneProgress t)
             :workspace (list
                         :applyEdit t
                         :executeCommand `(:dynamicRegistration :json-false)
@@ -2062,6 +2063,10 @@ eglot-handle-notification
   (_server (_method (eql telemetry/event)) &rest _any)
   "Handle notification telemetry/event.") ;; noop, use events buffer
 
+(cl-defmethod eglot-handle-reqeust
+  (_server (_method (eql window/workDoneProgress/create)) &rest _any)
+  "Handle request window/workDoneProgress/create.") ;; noop, use events buffer
+
 (cl-defmethod eglot-handle-notification
   (server (_method (eql $/progress)) &key token value)
   "Handle $/progress notification identified by TOKEN from SERVER."
-- 
2.38.1


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59929; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 9 Dec 2022 20:07:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 09 15:07:38 2022
Received: from localhost ([127.0.0.1]:38204 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p3jej-0002ii-Ks
	for submit <at> debbugs.gnu.org; Fri, 09 Dec 2022 15:07:37 -0500
Received: from lists.gnu.org ([209.51.188.17]:33214)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <danny@HIDDEN>) id 1p3jeh-0002ia-6C
 for submit <at> debbugs.gnu.org; Fri, 09 Dec 2022 15:07:35 -0500
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 <danny@HIDDEN>)
 id 1p3jee-0002bU-4f
 for bug-gnu-emacs@HIDDEN; Fri, 09 Dec 2022 15:07:35 -0500
Received: from out2.migadu.com ([2001:41d0:2:aacc::])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <danny@HIDDEN>)
 id 1p3jeb-000074-EJ
 for bug-gnu-emacs@HIDDEN; Fri, 09 Dec 2022 15:07:31 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dfreeman.email;
 s=key1; t=1670616447;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type;
 bh=2WPDMOFzeSFgaSoB26KDA3cUgz9VwGeiax4rAZHxndI=;
 b=TLHbGy51zo3M8CxHHDUP5xyiqmyIgKm4DkRG119ck6dMtjxe1JA1tn4Fh/jeqFKUGDrfxo
 NTjhRMLRtoBDfmV4+MbMkGYVV18mvc4xN6F+fE/u430DI10TZrTCc+YHQhomDWkWBXfD07
 4RSXLylG3V2YDotj4gL9rsoyXBQSjM4=
From: Danny Freeman <danny@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH]: Eglot, request progress notification on server init
Date: Fri, 09 Dec 2022 14:55:05 -0500
Message-ID: <87y1rgtk78.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Migadu-Flow: FLOW_OUT
Received-SPF: pass client-ip=2001:41d0:2:aacc::;
 envelope-from=danny@HIDDEN; helo=out2.migadu.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 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,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

--=-=-=
Content-Type: text/plain


I would like to propose a change to Eglot that builds on my last patch
in bug 59149.

What I did not realize at the time of writing that patch, is that
clients can opt into receiving progress notifications for server
initialization when sending the `:initialize` request.
This is useful for slow starting servers or large projects that require
the lsp server to do a lot of analysis on startup. The server of course
has to be able to send these progress reports. Not all of them do and
may ignore this parameter.

If users do not want to see this, they can set `eglot-report-progress`
to `nil`.

There are other requests that extend the WorkDoneProgressParams
interface that this could also be done for. It may be worth looking
through the spec and seeing if it makes sense to send this param with
other requests. Many of them are for typically quick requests like
`textDocument/definition`

Thank you,
-- 
Danny Freeman


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Eglot-show-progress-reports-for-slow-starting-server.patch
Content-Description: Eglot report initialization progress

From 1b81fa34ff282bfca0f754afad2c9eca04ad7985 Mon Sep 17 00:00:00 2001
From: dannyfreeman <danny@HIDDEN>
Date: Fri, 9 Dec 2022 14:40:01 -0500
Subject: [PATCH] Eglot: show progress reports for slow starting servers

* lisp/progmodes/eglot.el (eglot--connect): report progress on
initialization

This takes advantage of the new `eglot-handle-notification`
implementation of the LSP $/progress method.

Slow starting servers will now show their progress in the
minibuffer if `eglot-report-progress` is `t`. The server must
also opt in to providing the $/progress notifications.

See
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#initialize
for more information on the InitializeParams interface.
---
 lisp/progmodes/eglot.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index a53f62fc565..cceb9fb5b32 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1291,7 +1291,10 @@ eglot--connect
                             :initializationOptions (eglot-initialization-options
                                                     server)
                             :capabilities (eglot-client-capabilities server)
-                            :workspaceFolders (eglot-workspace-folders server))
+                            :workspaceFolders (eglot-workspace-folders server)
+                            ;; Request $/progress notifications from the
+                            ;; server on startup.
+                            :workDoneToken "initialize")
                       :success-fn
                       (eglot--lambda ((InitializeResult) capabilities serverInfo)
                         (unless canceled
-- 
2.38.1


--=-=-=--




Acknowledgement sent to Danny Freeman <danny@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#59929; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 13 Dec 2022 01:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.