GNU bug report logs - #57725
29.0.50; eglot: Error when using :initializationOptions

Previous Next

Package: emacs;

Reported by: Augusto Stoffel <arstoffel <at> gmail.com>

Date: Sun, 11 Sep 2022 07:04:02 UTC

Severity: normal

Found in version 29.0.50

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 57725 in the body.
You can then email your comments to 57725 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to joaotavora <at> gmail.com, bug-gnu-emacs <at> gnu.org:
bug#57725; Package emacs. (Sun, 11 Sep 2022 07:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Augusto Stoffel <arstoffel <at> gmail.com>:
New bug report received and forwarded. Copy sent to joaotavora <at> gmail.com, bug-gnu-emacs <at> gnu.org. (Sun, 11 Sep 2022 07:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; eglot: Error when using :initializationOptions
Date: Sun, 11 Sep 2022 09:02:49 +0200
If I attempt to pass :initializationOptions to a server like so:

    (setf (alist-get 'python-mode eglot-server-programs)
          '("jedi-language-server" :initializationOptions eglot--{}))

I get an error:

    Debugger entered--Lisp error: (invalid-slot-name "#<eglot-lsp-server eglot-lsp-server-92f0c8>" :initializationOptions)

A workaround is to add this to the eglot-lsp-server defclass:

@@ -788,6 +788,7 @@ treated as in `eglot-dbind'."
    (managed-buffers
     :documentation "List of buffers managed by server."
     :accessor eglot--managed-buffers)
+   (_ :initarg :initializationOptions)
    (saved-initargs
     :documentation "Saved initargs for reconnection purposes."
     :accessor eglot--saved-initargs)

I can also confirm that after the workaround, the options are passed
correctly to the server upon initialization.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57725; Package emacs. (Sun, 11 Sep 2022 15:14:02 GMT) Full text and rfc822 format available.

Message #8 received at 57725 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: João Távora <joaotavora <at> gmail.com>,
 57725 <at> debbugs.gnu.org
Subject: Re: bug#57725: 29.0.50; eglot: Error when using :initializationOptions
Date: Sun, 11 Sep 2022 18:13:33 +0300
Augusto Stoffel [2022-09-11 09:02 +0200] wrote:

> If I attempt to pass :initializationOptions to a server like so:
>
>     (setf (alist-get 'python-mode eglot-server-programs)
>           '("jedi-language-server" :initializationOptions eglot--{}))
>
> I get an error:
>
>     Debugger entered--Lisp error: (invalid-slot-name "#<eglot-lsp-server eglot-lsp-server-92f0c8>" :initializationOptions)
>
> A workaround is to add this to the eglot-lsp-server defclass:
>
> @@ -788,6 +788,7 @@ treated as in `eglot-dbind'."
>     (managed-buffers
>      :documentation "List of buffers managed by server."
>      :accessor eglot--managed-buffers)
> +   (_ :initarg :initializationOptions)
>     (saved-initargs
>      :documentation "Saved initargs for reconnection purposes."
>      :accessor eglot--saved-initargs)
>
> I can also confirm that after the workaround, the options are passed
> correctly to the server upon initialization.

Nice.

Closing this ticket will also close
https://github.com/joaotavora/eglot/issues/940.

Thanks,

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57725; Package emacs. (Sun, 11 Sep 2022 16:21:02 GMT) Full text and rfc822 format available.

Message #11 received at 57725 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: Augusto Stoffel <arstoffel <at> gmail.com>, 57725 <at> debbugs.gnu.org
Subject: Re: bug#57725: 29.0.50; eglot: Error when using :initializationOptions
Date: Sun, 11 Sep 2022 17:20:13 +0100
[Message part 1 (text/plain, inline)]
I almost agree with this fix as is, but maybe we should name the slot. What
happens if my the connection is restarted, shouldn't the previous
initializationOptions be reused?

On Sun, Sep 11, 2022, 16:13 Basil L. Contovounesios <contovob <at> tcd.ie> wrote:

> Augusto Stoffel [2022-09-11 09:02 +0200] wrote:
>
> > If I attempt to pass :initializationOptions to a server like so:
> >
> >     (setf (alist-get 'python-mode eglot-server-programs)
> >           '("jedi-language-server" :initializationOptions eglot--{}))
> >
> > I get an error:
> >
> >     Debugger entered--Lisp error: (invalid-slot-name "#<eglot-lsp-server
> eglot-lsp-server-92f0c8>" :initializationOptions)
> >
> > A workaround is to add this to the eglot-lsp-server defclass:
> >
> > @@ -788,6 +788,7 @@ treated as in `eglot-dbind'."
> >     (managed-buffers
> >      :documentation "List of buffers managed by server."
> >      :accessor eglot--managed-buffers)
> > +   (_ :initarg :initializationOptions)
> >     (saved-initargs
> >      :documentation "Saved initargs for reconnection purposes."
> >      :accessor eglot--saved-initargs)
> >
> > I can also confirm that after the workaround, the options are passed
> > correctly to the server upon initialization.
>
> Nice.
>
> Closing this ticket will also close
> https://github.com/joaotavora/eglot/issues/940.
>
> Thanks,
>
> --
> Basil
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57725; Package emacs. (Sun, 11 Sep 2022 16:27:01 GMT) Full text and rfc822 format available.

Message #14 received at 57725 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 57725 <at> debbugs.gnu.org
Subject: Re: bug#57725: 29.0.50; eglot: Error when using :initializationOptions
Date: Sun, 11 Sep 2022 18:25:55 +0200
[Message part 1 (text/plain, inline)]
On Sun, Sep 11, 2022, 18:20 João Távora <joaotavora <at> gmail.com> wrote:

> I almost agree with this fix as is, but maybe we should name the slot.
> What happens if my the connection is restarted, shouldn't the previous
> initializationOptions be reused?
>

Most certainly.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57725; Package emacs. (Sun, 11 Sep 2022 16:29:01 GMT) Full text and rfc822 format available.

Message #17 received at 57725 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 57725 <at> debbugs.gnu.org
Subject: Re: bug#57725: 29.0.50; eglot: Error when using :initializationOptions
Date: Sun, 11 Sep 2022 17:27:49 +0100
[Message part 1 (text/plain, inline)]
Can you suggest an alternative patch so that that second effect also
happens?

João

On Sun, Sep 11, 2022, 17:26 Augusto Stoffel <arstoffel <at> gmail.com> wrote:

> On Sun, Sep 11, 2022, 18:20 João Távora <joaotavora <at> gmail.com> wrote:
>
>> I almost agree with this fix as is, but maybe we should name the slot.
>> What happens if my the connection is restarted, shouldn't the previous
>> initializationOptions be reused?
>>
>
> Most certainly.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57725; Package emacs. (Sun, 11 Sep 2022 16:34:02 GMT) Full text and rfc822 format available.

Message #20 received at 57725 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 57725 <at> debbugs.gnu.org
Subject: Re: bug#57725: 29.0.50; eglot: Error when using :initializationOptions
Date: Sun, 11 Sep 2022 18:33:16 +0200
On Sun, 11 Sep 2022 at 17:27, João Távora wrote:

> Can you suggest an alternative patch so that that second effect also happens?
>
> João
>
> On Sun, Sep 11, 2022, 17:26 Augusto Stoffel <arstoffel <at> gmail.com> wrote:
>
>  On Sun, Sep 11, 2022, 18:20 João Távora <joaotavora <at> gmail.com> wrote:
>
>  I almost agree with this fix as is, but maybe we should name the slot. What
>  happens if my the connection is restarted, shouldn't the previous
>  initializationOptions be reused?
>
>  Most certainly.

Actually, I'm not so sure what the best behavior is.  I think reusing
the original :initializationOptions is consistent with other behavior in
Eglot (is it?), but there's also merit in recomputing/using the current
user settings — for instance, if you need to debug the
:initializationOptions.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57725; Package emacs. (Sun, 11 Sep 2022 16:39:01 GMT) Full text and rfc822 format available.

Message #23 received at 57725 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 57725 <at> debbugs.gnu.org
Subject: Re: bug#57725: 29.0.50; eglot: Error when using :initializationOptions
Date: Sun, 11 Sep 2022 17:38:09 +0100
[Message part 1 (text/plain, inline)]
Yes, makes sense, but there is another piece of initialization -- good ol
command line params -- that are also treated the way i described (i'm
almost sure, but better confirm).

So it's good to be consistent. If this kind of refreshing from user options
is needed for debug purposes, the user can simply shutdown and restart
instead of eglot-reconnect. At least this is what I figured at the time.

On Sun, Sep 11, 2022, 17:33 Augusto Stoffel <arstoffel <at> gmail.com> wrote:

> On Sun, 11 Sep 2022 at 17:27, João Távora wrote:
>
> > Can you suggest an alternative patch so that that second effect also
> happens?
> >
> > João
> >
> > On Sun, Sep 11, 2022, 17:26 Augusto Stoffel <arstoffel <at> gmail.com> wrote:
> >
> >  On Sun, Sep 11, 2022, 18:20 João Távora <joaotavora <at> gmail.com> wrote:
> >
> >  I almost agree with this fix as is, but maybe we should name the slot.
> What
> >  happens if my the connection is restarted, shouldn't the previous
> >  initializationOptions be reused?
> >
> >  Most certainly.
>
> Actually, I'm not so sure what the best behavior is.  I think reusing
> the original :initializationOptions is consistent with other behavior in
> Eglot (is it?), but there's also merit in recomputing/using the current
> user settings — for instance, if you need to debug the
> :initializationOptions.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57725; Package emacs. (Sat, 17 Sep 2022 11:18:02 GMT) Full text and rfc822 format available.

Message #26 received at 57725 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 57725 <at> debbugs.gnu.org
Subject: Re: bug#57725: 29.0.50; eglot: Error when using :initializationOptions
Date: Sat, 17 Sep 2022 13:17:47 +0200
I just submitted a pull request on Github, so that we can see the CI
test results.

    https://github.com/joaotavora/eglot/pull/1038

I guess we can close the ticket there and continue the discussion there.

On Sun, 11 Sep 2022 at 17:38, João Távora wrote:

> Yes, makes sense, but there is another piece of initialization -- good ol command line
> params -- that are also treated the way i described (i'm almost sure, but better confirm).
>
> So it's good to be consistent. If this kind of refreshing from user options is needed for
> debug purposes, the user can simply shutdown and restart instead of eglot-reconnect. At
> least this is what I figured at the time.
>
> On Sun, Sep 11, 2022, 17:33 Augusto Stoffel <arstoffel <at> gmail.com> wrote:
>
>  On Sun, 11 Sep 2022 at 17:27, João Távora wrote:
>
>  > Can you suggest an alternative patch so that that second effect also happens?
>  >
>  > João
>  >
>  > On Sun, Sep 11, 2022, 17:26 Augusto Stoffel <arstoffel <at> gmail.com> wrote:
>  >
>  >  On Sun, Sep 11, 2022, 18:20 João Távora <joaotavora <at> gmail.com> wrote:
>  >
>  >  I almost agree with this fix as is, but maybe we should name the slot. What
>  >  happens if my the connection is restarted, shouldn't the previous
>  >  initializationOptions be reused?
>  >
>  >  Most certainly.
>
>  Actually, I'm not so sure what the best behavior is.  I think reusing
>  the original :initializationOptions is consistent with other behavior in
>  Eglot (is it?), but there's also merit in recomputing/using the current
>  user settings — for instance, if you need to debug the
>  :initializationOptions.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57725; Package emacs. (Sat, 17 Sep 2022 16:34:01 GMT) Full text and rfc822 format available.

Message #29 received at 57725 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 João Távora <joaotavora <at> gmail.com>, 57725 <at> debbugs.gnu.org
Subject: Re: bug#57725: 29.0.50; eglot: Error when using :initializationOptions
Date: Sat, 17 Sep 2022 18:33:40 +0200
Augusto Stoffel <arstoffel <at> gmail.com>:

> I guess we can close the ticket there and continue the discussion there.
                                  ^^^^^                             ^^^^^

Should one of the above be a "here"?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57725; Package emacs. (Sat, 17 Sep 2022 16:40:02 GMT) Full text and rfc822 format available.

Message #32 received at 57725 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 João Távora <joaotavora <at> gmail.com>, 57725 <at> debbugs.gnu.org
Subject: Re: bug#57725: 29.0.50; eglot: Error when using :initializationOptions
Date: Sat, 17 Sep 2022 18:39:14 +0200
On Sat, 17 Sep 2022 at 18:33, Stefan Kangas wrote:

> Augusto Stoffel <arstoffel <at> gmail.com>:
>
>> I guess we can close the ticket there and continue the discussion there.
>                                   ^^^^^                             ^^^^^
>
> Should one of the above be a "here"?

Yes, please close this ticket here at the Emacs tracker.




Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Sat, 17 Sep 2022 16:42:02 GMT) Full text and rfc822 format available.

Notification sent to Augusto Stoffel <arstoffel <at> gmail.com>:
bug acknowledged by developer. (Sat, 17 Sep 2022 16:42:02 GMT) Full text and rfc822 format available.

Message #37 received at 57725-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 57725-done <at> debbugs.gnu.org,
 João Távora <joaotavora <at> gmail.com>
Subject: Re: bug#57725: 29.0.50; eglot: Error when using :initializationOptions
Date: Sat, 17 Sep 2022 18:41:17 +0200
Augusto Stoffel <arstoffel <at> gmail.com> writes:

> Yes, please close this ticket here at the Emacs tracker.

Done.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57725; Package emacs. (Sat, 17 Sep 2022 19:09:02 GMT) Full text and rfc822 format available.

Message #40 received at 57725-done <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 57725-done <at> debbugs.gnu.org,
 Augusto Stoffel <arstoffel <at> gmail.com>
Subject: Re: bug#57725: 29.0.50; eglot: Error when using :initializationOptions
Date: Sat, 17 Sep 2022 20:09:25 +0100
[Message part 1 (text/plain, inline)]
In the future, I would suggest the other direction.  Ask me or Stefan to
close the ticket at the Eglot tracker.

Anyway, I think this two-liner patch fixes the problem and doesn't have any
unintended side-effects for M-x eglot-reconnect.

diff --git a/eglot.el b/eglot.el
index ff94d5ca5f..3b1b1a9536 100644
--- a/eglot.el
+++ b/eglot.el
@@ -796,6 +796,8 @@ treated as in `eglot-dbind'."
   :documentation
   "Represents a server. Wraps a process for LSP communication.")

+(cl-defmethod initialize-instance :before ((_server eglot-lsp-server)
&optional args)
+  (cl-remf args :initializationOptions))

 ;;; Process management
 (defvar eglot--servers-by-project (make-hash-table :test #'equal)

On Sat, Sep 17, 2022 at 5:41 PM Stefan Kangas <stefankangas <at> gmail.com>
wrote:

> Augusto Stoffel <arstoffel <at> gmail.com> writes:
>
> > Yes, please close this ticket here at the Emacs tracker.
>
> Done.
>


-- 
João Távora
[Message part 2 (text/html, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 16 Oct 2022 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 191 days ago.

Previous Next


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