From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dimitri Belopopsky Newsgroups: gmane.emacs.bugs Subject: bug#61066: [PATCH] Add inlay hint support to eglot Date: Fri, 27 Jan 2023 19:44:42 +0100 Message-ID: References: <83a625g66p.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000dfbe2c05f3434252" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37934"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 61066@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 27 19:46:23 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pLTjz-0009aS-9H for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 27 Jan 2023 19:46:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLTjg-0007Je-Oj; Fri, 27 Jan 2023 13:46:04 -0500 Original-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 ) id 1pLTje-0007JQ-PG for bug-gnu-emacs@gnu.org; Fri, 27 Jan 2023 13:46:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pLTje-0003Bg-HD for bug-gnu-emacs@gnu.org; Fri, 27 Jan 2023 13:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pLTje-0003L5-7p for bug-gnu-emacs@gnu.org; Fri, 27 Jan 2023 13:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dimitri Belopopsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 27 Jan 2023 18:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61066 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 61066-submit@debbugs.gnu.org id=B61066.167484510312755 (code B ref 61066); Fri, 27 Jan 2023 18:46:02 +0000 Original-Received: (at 61066) by debbugs.gnu.org; 27 Jan 2023 18:45:03 +0000 Original-Received: from localhost ([127.0.0.1]:38436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pLTig-0003Jd-Jq for submit@debbugs.gnu.org; Fri, 27 Jan 2023 13:45:03 -0500 Original-Received: from mail-qk1-f176.google.com ([209.85.222.176]:35433) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pLTid-0003Ip-DL for 61066@debbugs.gnu.org; Fri, 27 Jan 2023 13:45:01 -0500 Original-Received: by mail-qk1-f176.google.com with SMTP id t9so2774979qkm.2 for <61066@debbugs.gnu.org>; Fri, 27 Jan 2023 10:44:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7qC2GWAYEbpXR8aiYp7FgNEsAN54hfH+npkohqlZsDI=; b=vF8O0B7efyGERKbVAg1N/U7zeCPfaBAxCU04mDxZhl+FWwRUFvJ1o19n1CPxQT/Trj wsIWufOz3WsVoYmYp5tUWrM6docDf2hhhkCz94uLouF5GsxUNjpKsQx7vloBtyw+h2eX 5jzN6NYUX6jKq5ZFKWcXHeUg5qMpUkYidLm+IqP+TO0RELglakkB7OFnYOvE3fyTaVZK kSW+hkkPZ/GRVsmS7nSw9nsBx7GYJU7JTcc6e7x4NfJyWwV58YGV7hK20MiX5VNplj6n jwmIAr6mBHBmYlpESIdkifd8xSfkH67rCJq8LtJRh0619A/w0MsXVvAqc60UAfUFhsEF 7zyA== X-Gm-Message-State: AFqh2kpWyqZV/lHcjtWOFecx6+2+ohhDE04B+s8gCpCD/8o1l8iuPyyY cduKNUJZKNagXZGXsHghSyztd36BALuHRV3QOzJv9Xbm X-Google-Smtp-Source: AMrXdXvibWWKQrFRfmI+ADoIal8w03LXUOwkauOnMgAzLvX5tjSzwopDdV8284W/Kpaa4B2V+YJhoKVNG3Hxr0MydWw= X-Received: by 2002:a05:620a:34e:b0:705:b333:c90c with SMTP id t14-20020a05620a034e00b00705b333c90cmr1297036qkm.378.1674845093869; Fri, 27 Jan 2023 10:44:53 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254269 Archived-At: --000000000000dfbe2c05f3434252 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=C3=A3o T=C3=A1vora = wrote: > On Thu, Jan 26, 2023 at 6:28 AM Eli Zaretskii wrote: > >> > From: Dimitri Belopopsky >> > 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=C3=A3o, WDYT? >> > > I think you're mostly right in your analysis. I also think this should b= e > 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=C3=A3o > --000000000000dfbe2c05f3434252 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

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

Th= is (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 whi= ch 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 gues= s 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=C3=A3o T=C3=A1vora <joaotavora@gmail.com> wrote:
On Thu, Jan 26, 2023 at 6:28 = AM Eli Zaretskii <eliz= @gnu.org> wrote:
> From: Dimitri Belopopsky <dimitri@belopopsky.com>
> Date: Wed, 25 Jan 2023 23:34:02 +0100
>
> I've been working on adding support for inlay hints inside eglot u= sing 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 a= ny 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.=C2=A0 So I think this
feature should work via ElDoc, not as a separate from-the-scratch
implementation.=C2=A0 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.=C2=A0 (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=C3=A3o, WDYT?

I think you're mostly right in y= our analysis.=C2=A0 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 stanc= e in other similar
matters.

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

Of course the existence of this proto= type by Dimitri is certainly
No Bad Thing and a good startin= g point.

Jo=C3=A3o
--000000000000dfbe2c05f3434252--