GNU bug report logs - #61066
[PATCH] Add inlay hint support to eglot

Previous Next

Package: emacs;

Reported by: Dimitri Belopopsky <dimitri <at> belopopsky.com>

Date: Wed, 25 Jan 2023 22:35:01 UTC

Severity: normal

Tags: patch

Merged with 61412

Done: João Távora <joaotavora <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 61066 in the body.
You can then email your comments to 61066 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 bug-gnu-emacs <at> gnu.org:
bug#61066; Package emacs. (Wed, 25 Jan 2023 22:35:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Dimitri Belopopsky <dimitri <at> belopopsky.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 25 Jan 2023 22:35:02 GMT) Full text and rfc822 format available.

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

From: Dimitri Belopopsky <dimitri <at> belopopsky.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Add inlay hint support to eglot
Date: Wed, 25 Jan 2023 23:34:02 +0100
[Message part 1 (text/plain, inline)]
Hello,

I've been working on adding support for inlay hints inside eglot using
overlays.
Here is a working patch, but I'm still missing a few things:

- I can't figure out a way to show the hints on a document without causing
lags or timeouts from the lsp server
- I'm currently updating the hints by sending the whole file each time (to
make sure all hints get updated correctly). I'm not sure on how to make
this more efficient (or if it even necessary).

On the implementation side:
- implemented with overlays as a minor model, enabled by default
- shows all hints supported by the protocol
- there is a customisation to disable the minor mode if the user doesn't
want the feature

I'd love to get a few points to finish this patch, and of course any ideas
and feedbacks are welcome!

Kind regards,

Dimitri Belopopsky
[Message part 2 (text/html, inline)]
[0001-Add-inlay-hints-to-eglot.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61066; Package emacs. (Thu, 26 Jan 2023 06:29:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dimitri Belopopsky <dimitri <at> belopopsky.com>,
 João Távora <joaotavora <at> gmail.com>
Cc: 61066 <at> debbugs.gnu.org
Subject: Re: bug#61066: [PATCH] Add inlay hint support to eglot
Date: Thu, 26 Jan 2023 08:29:02 +0200
> From: Dimitri Belopopsky <dimitri <at> belopopsky.com>
> Date: Wed, 25 Jan 2023 23:34:02 +0100
> 
> I've been working on adding support for inlay hints inside eglot using overlays.
> Here is a working patch, but I'm still missing a few things:
> 
> - I can't figure out a way to show the hints on a document without causing lags or timeouts from the lsp
> server
> - I'm currently updating the hints by sending the whole file each time (to make sure all hints get updated
> correctly). I'm not sure on how to make this more efficient (or if it even necessary).
> 
> On the implementation side:
> - implemented with overlays as a minor model, enabled by default
> - shows all hints supported by the protocol
> - there is a customisation to disable the minor mode if the user doesn't want the feature
> 
> I'd love to get a few points to finish this patch, and of course any ideas and feedbacks are welcome!

Thank you for working on this important feature.

AFAIU, inlay hints provide information of the same kind as ElDoc and
in similar manner from the display and UX POV.  So I think this
feature should work via ElDoc, not as a separate from-the-scratch
implementation.  ElDoc is already capable of using Eglot-supplied
information, so perhaps the only feature we need to add is the
capability of ElDoc to (optionally) display the information in
overlays near point.  (I thought we already had such a capability in
eldoc.el, but it looks like I was dreaming, because I cannot find it
there.)

The advantage of basing this on ElDoc is that then we will be able to
provide similar features from information sources other than Eglot.

João, WDYT?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61066; Package emacs. (Thu, 26 Jan 2023 12:30:02 GMT) Full text and rfc822 format available.

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

From: João Távora <joaotavora <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Dimitri Belopopsky <dimitri <at> belopopsky.com>, 61066 <at> debbugs.gnu.org
Subject: Re: bug#61066: [PATCH] Add inlay hint support to eglot
Date: Thu, 26 Jan 2023 12:30:55 +0000
[Message part 1 (text/plain, inline)]
On Thu, Jan 26, 2023 at 6:28 AM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Dimitri Belopopsky <dimitri <at> belopopsky.com>
> > Date: Wed, 25 Jan 2023 23:34:02 +0100
> >
> > I've been working on adding support for inlay hints inside eglot using
> overlays.
> > Here is a working patch, but I'm still missing a few things:
> >
> > - I can't figure out a way to show the hints on a document without
> causing lags or timeouts from the lsp
> > server
> > - I'm currently updating the hints by sending the whole file each time
> (to make sure all hints get updated
> > correctly). I'm not sure on how to make this more efficient (or if it
> even necessary).
> >
> > On the implementation side:
> > - implemented with overlays as a minor model, enabled by default
> > - shows all hints supported by the protocol
> > - there is a customisation to disable the minor mode if the user doesn't
> want the feature
> >
> > I'd love to get a few points to finish this patch, and of course any
> ideas and feedbacks are welcome!
>
> Thank you for working on this important feature.
>
> AFAIU, inlay hints provide information of the same kind as ElDoc and
> in similar manner from the display and UX POV.  So I think this
> feature should work via ElDoc, not as a separate from-the-scratch
> implementation.  ElDoc is already capable of using Eglot-supplied
> information, so perhaps the only feature we need to add is the
> capability of ElDoc to (optionally) display the information in
> overlays near point.  (I thought we already had such a capability in
> eldoc.el, but it looks like I was dreaming, because I cannot find it
> there.)
>
> The advantage of basing this on ElDoc is that then we will be able to
> provide similar features from information sources other than Eglot.
>
> João, WDYT?
>

I think you're mostly right in your analysis.  I also think this should be
provided
via some LSP-agnostic infrastructure and not as a separate from-the-scratch
implementation, as you put it. This is (and was) also my stance in other
similar
matters.

The devil is in the details, of course.  Is eldoc.el the right
infrastructure
for it. What augmentation does it need, if any?  Are these augmentations
practical given the relative size, complexity and history of eldoc.el?
Isn't
an "inlay.el" or a "little-hint.el" support library a better choice? Or
maybe
flymake.el with it's use of overlay-based annotations is also acceptable
here?  I don't (yet) have answers to these questions.

Of course the existence of this prototype by Dimitri is certainly
No Bad Thing and a good starting point.

João
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61066; Package emacs. (Fri, 27 Jan 2023 18:46:02 GMT) Full text and rfc822 format available.

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

From: Dimitri Belopopsky <dimitri <at> belopopsky.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 61066 <at> debbugs.gnu.org
Subject: Re: bug#61066: [PATCH] Add inlay hint support to eglot
Date: Fri, 27 Jan 2023 19:44:42 +0100
[Message part 1 (text/plain, inline)]
Hello,

I don't have much experience with hacking emacs, but I was thinking the
current code could also be reused
for the code lens LSP feature. Maybe there are other features that could be
done with the same kind
of setup?

This (to me anyway) would probably mean eldoc isn't the best option for a
more general solution.
Though I expect having overlays for eldoc would be beneficial as well.

I don't really know which is best between a library or integration inside
flymake. I might try out both
ideas, as I have no experience with either of them. My guess flymake sounds
easier to implement, but
a support library could probably be more flexible for reuse?

Dimitri

On Thu, 26 Jan 2023 at 13:29, João Távora <joaotavora <at> gmail.com> wrote:

> On Thu, Jan 26, 2023 at 6:28 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> > From: Dimitri Belopopsky <dimitri <at> belopopsky.com>
>> > Date: Wed, 25 Jan 2023 23:34:02 +0100
>> >
>> > I've been working on adding support for inlay hints inside eglot using
>> overlays.
>> > Here is a working patch, but I'm still missing a few things:
>> >
>> > - I can't figure out a way to show the hints on a document without
>> causing lags or timeouts from the lsp
>> > server
>> > - I'm currently updating the hints by sending the whole file each time
>> (to make sure all hints get updated
>> > correctly). I'm not sure on how to make this more efficient (or if it
>> even necessary).
>> >
>> > On the implementation side:
>> > - implemented with overlays as a minor model, enabled by default
>> > - shows all hints supported by the protocol
>> > - there is a customisation to disable the minor mode if the user
>> doesn't want the feature
>> >
>> > I'd love to get a few points to finish this patch, and of course any
>> ideas and feedbacks are welcome!
>>
>> Thank you for working on this important feature.
>>
>> AFAIU, inlay hints provide information of the same kind as ElDoc and
>> in similar manner from the display and UX POV.  So I think this
>> feature should work via ElDoc, not as a separate from-the-scratch
>> implementation.  ElDoc is already capable of using Eglot-supplied
>> information, so perhaps the only feature we need to add is the
>> capability of ElDoc to (optionally) display the information in
>> overlays near point.  (I thought we already had such a capability in
>> eldoc.el, but it looks like I was dreaming, because I cannot find it
>> there.)
>>
>> The advantage of basing this on ElDoc is that then we will be able to
>> provide similar features from information sources other than Eglot.
>>
>> João, WDYT?
>>
>
> I think you're mostly right in your analysis.  I also think this should be
> provided
> via some LSP-agnostic infrastructure and not as a separate
> from-the-scratch
> implementation, as you put it. This is (and was) also my stance in other
> similar
> matters.
>
> The devil is in the details, of course.  Is eldoc.el the right
> infrastructure
> for it. What augmentation does it need, if any?  Are these augmentations
> practical given the relative size, complexity and history of eldoc.el?
> Isn't
> an "inlay.el" or a "little-hint.el" support library a better choice? Or
> maybe
> flymake.el with it's use of overlay-based annotations is also acceptable
> here?  I don't (yet) have answers to these questions.
>
> Of course the existence of this prototype by Dimitri is certainly
> No Bad Thing and a good starting point.
>
> João
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61066; Package emacs. (Sat, 28 Jan 2023 02:00:02 GMT) Full text and rfc822 format available.

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

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>, Dimitri Belopopsky
 <dimitri <at> belopopsky.com>, João Távora
 <joaotavora <at> gmail.com>
Cc: 61066 <at> debbugs.gnu.org
Subject: Re: bug#61066: [PATCH] Add inlay hint support to eglot
Date: Sat, 28 Jan 2023 03:58:53 +0200
On 26/01/2023 08:29, Eli Zaretskii wrote:
> AFAIU, inlay hints provide information of the same kind as ElDoc and
> in similar manner from the display and UX POV.  So I think this
> feature should work via ElDoc, not as a separate from-the-scratch
> implementation.

IIUC the "inlay hints" are about different information.

Information that is not determined by the position of point.

For example, annotating variable declarations with specific types in a 
language that infers types, here's a screenshot: 
https://user-images.githubusercontent.com/2771466/71774757-54269200-2fc8-11ea-8505-ac2f326761ca.png

Or adding parameter types (or names) inside function calls, example: 
https://user-images.githubusercontent.com/2303841/35807174-43bc0c3c-0a82-11e8-8c99-591fb650e1e0.png

So I don't think this fits Eldoc's protocol.

You were probably thinking of signature help (that was my initial 
impression as well).




Merged 61066 61412. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 21 Feb 2023 15:22:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 25 Mar 2023 11:24:05 GMT) Full text and rfc822 format available.

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

Previous Next


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