unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
@ 2022-09-11  7:02 Augusto Stoffel
  2022-09-11 15:13 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 12+ messages in thread
From: Augusto Stoffel @ 2022-09-11  7:02 UTC (permalink / raw)
  To: 57725; +Cc: João Távora

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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
  2022-09-11  7:02 bug#57725: 29.0.50; eglot: Error when using :initializationOptions Augusto Stoffel
@ 2022-09-11 15:13 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-09-11 16:20   ` João Távora
  0 siblings, 1 reply; 12+ messages in thread
From: Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-09-11 15:13 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: João Távora, 57725

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





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
  2022-09-11 15:13 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-09-11 16:20   ` João Távora
  2022-09-11 16:25     ` Augusto Stoffel
  0 siblings, 1 reply; 12+ messages in thread
From: João Távora @ 2022-09-11 16:20 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Augusto Stoffel, 57725

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

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@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
>

[-- Attachment #2: Type: text/html, Size: 2036 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
  2022-09-11 16:20   ` João Távora
@ 2022-09-11 16:25     ` Augusto Stoffel
  2022-09-11 16:27       ` João Távora
  0 siblings, 1 reply; 12+ messages in thread
From: Augusto Stoffel @ 2022-09-11 16:25 UTC (permalink / raw)
  To: João Távora; +Cc: Basil L. Contovounesios, 57725

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

On Sun, Sep 11, 2022, 18:20 João Távora <joaotavora@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.

[-- Attachment #2: Type: text/html, Size: 607 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
  2022-09-11 16:25     ` Augusto Stoffel
@ 2022-09-11 16:27       ` João Távora
  2022-09-11 16:33         ` Augusto Stoffel
  0 siblings, 1 reply; 12+ messages in thread
From: João Távora @ 2022-09-11 16:27 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Basil L. Contovounesios, 57725

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

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@gmail.com> wrote:

> On Sun, Sep 11, 2022, 18:20 João Távora <joaotavora@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.
>

[-- Attachment #2: Type: text/html, Size: 1107 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
  2022-09-11 16:27       ` João Távora
@ 2022-09-11 16:33         ` Augusto Stoffel
  2022-09-11 16:38           ` João Távora
  0 siblings, 1 reply; 12+ messages in thread
From: Augusto Stoffel @ 2022-09-11 16:33 UTC (permalink / raw)
  To: João Távora; +Cc: Basil L. Contovounesios, 57725

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@gmail.com> wrote:
>
>  On Sun, Sep 11, 2022, 18:20 João Távora <joaotavora@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
  2022-09-11 16:33         ` Augusto Stoffel
@ 2022-09-11 16:38           ` João Távora
  2022-09-17 11:17             ` Augusto Stoffel
  0 siblings, 1 reply; 12+ messages in thread
From: João Távora @ 2022-09-11 16:38 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Basil L. Contovounesios, 57725

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

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@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@gmail.com> wrote:
> >
> >  On Sun, Sep 11, 2022, 18:20 João Távora <joaotavora@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.
>

[-- Attachment #2: Type: text/html, Size: 2154 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
  2022-09-11 16:38           ` João Távora
@ 2022-09-17 11:17             ` Augusto Stoffel
  2022-09-17 16:33               ` Stefan Kangas
  0 siblings, 1 reply; 12+ messages in thread
From: Augusto Stoffel @ 2022-09-17 11:17 UTC (permalink / raw)
  To: João Távora; +Cc: Basil L. Contovounesios, 57725

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@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@gmail.com> wrote:
>  >
>  >  On Sun, Sep 11, 2022, 18:20 João Távora <joaotavora@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
  2022-09-17 11:17             ` Augusto Stoffel
@ 2022-09-17 16:33               ` Stefan Kangas
  2022-09-17 16:39                 ` Augusto Stoffel
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Kangas @ 2022-09-17 16:33 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Basil L. Contovounesios, João Távora, 57725

Augusto Stoffel <arstoffel@gmail.com>:

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

Should one of the above be a "here"?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
  2022-09-17 16:33               ` Stefan Kangas
@ 2022-09-17 16:39                 ` Augusto Stoffel
  2022-09-17 16:41                   ` Stefan Kangas
  0 siblings, 1 reply; 12+ messages in thread
From: Augusto Stoffel @ 2022-09-17 16:39 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Basil L. Contovounesios, João Távora, 57725

On Sat, 17 Sep 2022 at 18:33, Stefan Kangas wrote:

> Augusto Stoffel <arstoffel@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.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
  2022-09-17 16:39                 ` Augusto Stoffel
@ 2022-09-17 16:41                   ` Stefan Kangas
  2022-09-17 19:09                     ` João Távora
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Kangas @ 2022-09-17 16:41 UTC (permalink / raw)
  To: Augusto Stoffel
  Cc: Basil L. Contovounesios, 57725-done, João Távora

Augusto Stoffel <arstoffel@gmail.com> writes:

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

Done.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#57725: 29.0.50; eglot: Error when using :initializationOptions
  2022-09-17 16:41                   ` Stefan Kangas
@ 2022-09-17 19:09                     ` João Távora
  0 siblings, 0 replies; 12+ messages in thread
From: João Távora @ 2022-09-17 19:09 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Basil L. Contovounesios, 57725-done, Augusto Stoffel

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

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@gmail.com>
wrote:

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


-- 
João Távora

[-- Attachment #2: Type: text/html, Size: 1483 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-09-17 19:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-11  7:02 bug#57725: 29.0.50; eglot: Error when using :initializationOptions Augusto Stoffel
2022-09-11 15:13 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-11 16:20   ` João Távora
2022-09-11 16:25     ` Augusto Stoffel
2022-09-11 16:27       ` João Távora
2022-09-11 16:33         ` Augusto Stoffel
2022-09-11 16:38           ` João Távora
2022-09-17 11:17             ` Augusto Stoffel
2022-09-17 16:33               ` Stefan Kangas
2022-09-17 16:39                 ` Augusto Stoffel
2022-09-17 16:41                   ` Stefan Kangas
2022-09-17 19:09                     ` João Távora

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).