Subject: bug#59149: Feature Request: Report progress of long requests in Eglot

From: Stephen Leake <[email-masked]>
Date: Mon, 21 Nov 2022 10:04:08 -0800

Danny Freeman <[email-masked]> writes:

> Stephen Leake <[email-masked]> writes:
>
>> This works for my needs in ada-mode; + 1.
>
> Great to hear!
>
>> > Anyway, the way the user opts out of LSP configuration is via the user
>> > variable eglot-ignored-server-capabilities.  So there should be some
>> > point where you check the associated LSP capability of "progress
>> > reporting" with eglot--server-capable.
>
> I'm trying to work on using the eglot-ignored-server-capabilities
> functionality with this, and am having some trouble. What exactly is the
> capability to ignore here? 

The LSP says progress report is part of the base protocol, not optional:
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#progress

> I believe this needs an entry somewhere in the
> `eglot-client-capabilities` hierarchy.
>
> This:
[2. application/emacs-lisp]
```
(cl-defgeneric eglot-client-capabilities (server)
  "What the Eglot LSP client supports for SERVER."
  (:method (s)
           (list
            :progress t
            ;; or maybe
            :$ (list :progress t)

            :workspace (list ...
            ... )))
```
>
>
>
> does not translate into anything when checking
> `(eglot--capabilities (eglot-current-server))`. Other capabilities are
> listed but not the new one I've added.

Moving :progress into :workspace worked for me:

            :workspace (list
                        :applyEdit t
                        :executeCommand `(:dynamicRegistration :json-false)
                        :workspaceEdit `(:documentChanges t)
                        :didChangeWatchedFiles
                        `(:dynamicRegistration
                          ,(if (eglot--trampish-p s) :json-false t))
                        :symbol `(:dynamicRegistration :json-false)
                        :configuration t
                        :semanticTokens `(:refreshSupport :json-false)
                        :workspaceFolders t
                        :progress t)

I have no idea why this works when yours does not.

> nor does `(eglot--server-capable :progress)` ;; returns nil
> `(eglot--server-capable :progressHandler)` ;; also nil
>

Note that this is checking the _server_ capabilities; since LSP does not
define "projess" as a capability, no server will ever advertise that
it is supported.

So we can't use eglot-ignores-server-capabilities; we could maybe
introduce eglot-ignored-client-capabilities.

But we already have a mechanism for that; eglot-stay-out-of.

So a user can do:

(add-to-list 'eglot-stay-out-of 'progress)

And in eglot-handle-notification ($/progress) we check for that:

(unless (eglot--stay-out-of-p 'progress)
   ...

There's probably a way to fold that check into the cl-defmethod
dispatching parameters; I did not look into that.

-- 
-- Stephe