From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Marcin Pajkowski Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Eglot: auto-import completion item Date: Sun, 20 Nov 2022 21:52:43 +0100 Message-ID: References: <83a64pewpw.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="000000000000818a9005eded1fb9" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32838"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 20 21:53:44 2022 Return-path: Envelope-to: ged-emacs-devel@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 1owrJv-0008LW-W7 for ged-emacs-devel@m.gmane-mx.org; Sun, 20 Nov 2022 21:53:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owrJE-00053J-Us; Sun, 20 Nov 2022 15:53:00 -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 1owrJD-000538-Ge for emacs-devel@gnu.org; Sun, 20 Nov 2022 15:52:59 -0500 Original-Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1owrJB-0003lz-BN; Sun, 20 Nov 2022 15:52:59 -0500 Original-Received: by mail-pg1-x533.google.com with SMTP id 62so9429624pgb.13; Sun, 20 Nov 2022 12:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aDC1Lsi28CLxcwnftRiALcrci7DXnUq/b7wviD5RFQw=; b=P9Fcz4AUpge5JSy6XrpQUMqkKVxtMSNE1cFZLFK+ma9v30z86sgdrgrHnao6ZZIKhz P5RzRX92nKmrZnU63aKPABTEc4M/XY5tpRAhhXxfRVqeb+pSy+Cp05fX6zcVvMefABLL 8ImnOX9U2nUGOQskJD30VqC+Z50jDEGnE68T5XXSmdg3ZqHtZDcM5rqYk2wAonruv2K4 vu5mdx0yYcW2qG+MHnI+RiG8ihl65rxzM7sq88bJ2Gy03qtk4lmlOc0kKlurKeQykoH2 hIYxmBepRbeb2C/lfzR2UN9BOhxuJK8H9tOasWWZlpt55uEbk4MbLIl/9Qutyq5anc5s kPwg== 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=aDC1Lsi28CLxcwnftRiALcrci7DXnUq/b7wviD5RFQw=; b=iKObjDi41PPeS49RPQ9PJ77CqVd70Foz+InhiOvg0cGvUhEdiBdkAmBZNh9DhjSKIW Ssm54cI4v3XesFyYBSnH9s/3hlXaFULpGBi8UBERMUoziHtJdrB2QEOvzpLacEooST4U 20S2ptclJLg+pq75treEMmoN1GJOgsx+hB7uEKRgR8kx4RsQc41Cq+4cu2xrkAHkELqv jZcHVjB4ytqEPSv4FXbsQaj6yLYUZWPLtzlsdEfyLpm0R5dXyGt8GyOH3/WRZEcKFY+G Ya0SNoivubRvrTOSI8VCGSvKThsTUSQ+Gyng2EV7Hk5dsDDBZn7M5GJJwfC3jm0sq6uq SHXQ== X-Gm-Message-State: ANoB5pkqCmi0+1cJWo9zUMhlHgLkBO01hfKUhkO0IdFJmpsGY6pfP/Ev KSQRlGpVQV+Pw7Kg62iz9DZsZR90vaU/hYFR2zw= X-Google-Smtp-Source: AA0mqf6pM8BD9p5YRHiIMgvyeHJ76TFbazGCPmgizfbCwtr3rWpak9ZmsLsNaYrkNDw2G7attApQGGSBEQW0+EG9Mn8= X-Received: by 2002:a63:5356:0:b0:44d:e5d8:fb15 with SMTP id t22-20020a635356000000b0044de5d8fb15mr14977051pgl.89.1668977575155; Sun, 20 Nov 2022 12:52:55 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=marcin.pajkowski@gmail.com; helo=mail-pg1-x533.google.com X-Spam_score_int: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, THIS_AD=1.3 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300271 Archived-At: --000000000000818a9005eded1fb9 Content-Type: multipart/alternative; boundary="000000000000818a8d05eded1fb7" --000000000000818a8d05eded1fb7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Emacs developers, I use clangd and rust-analyzer LSP servers and found this issue is specific to rust-analyzer. This advertisement is required by rust-analyzer server to provide completions for symbols that are not resolved but can be automatically imported. Without advertising, this capability server does not report such completions, which kind of makes sense IMHO: - server can avoid some computations, - client which does not support additionalTextEdits capability doesn't receive items that can't be auto-imported. User of such LSP client could probably consider such suggestions inaccurate (I applied completion and my code does not compile). Reference: https://rust-analyzer.github.io/manual.html#completion-with-autoimport I reflected my clarifications in a commit message and put the patch in a separate file. Best regards, Marcin czw., 17 lis 2022 o 11:40 Jo=C3=A3o T=C3=A1vora napi= sa=C5=82(a): > What these particular capabilities are about can be seen > in the LSP spec. I haven't checked, but I think this refers to > Eglot's capability to present meta information about a given > completion item and to do additional things elsewhere in the > buffer once a given completion item is chosen by the user. > So, typically you may be given the completion: > > std::cout > > and if you do choose it, Eglot and LSP try to ensure that > an #include appears in the top of your C++ file. > > In general, normally both client and server advertise their > capabilities to each other so that the other side refrains from > doing anything that is not explicitly mentioned in these > advertisements. This is how there are really no "versions of > the protocol" (well there are, but they aren't used in the way > a normal versioned API is used). It doesn't always work that > way, and both clients and servers will both request stuff that > isn't possible and volunteer stuff that isn't needed. > > It's indeed odd to find that Eglot starts advertising a > capability just by itself, without adding any new functional > code presumably backing that advertisement, so you're right > to be suspicious, Eli. > > But it may be just that the advertisement was incorrectly > glossed over in the past (which wouldn't necessarily present > a problem since many servers don't bother to check > advertisements, as explained), or -- also possible -- that the > advertisement wasn't even specified in the past. > > Most importantly, I would like Marcin to explain, if possible, > what actual problem with what server this is solving. > > The reasoning and conclusion should be in the commit message > for this patch for future reference. > > Jo=C3=A3o > > On Thu, Nov 17, 2022 at 9:50 AM Eli Zaretskii wrote: > >> > From: Marcin Pajkowski >> > Date: Sat, 12 Nov 2022 14:23:52 +0100 >> > >> > * lisp/progmodes/eglot.el (eglot-client-capabilities): Advertise >> > resolveSupport capabilities >> > --- >> > lisp/progmodes/eglot.el | 1 + >> > 1 file changed, 1 insertion(+) >> > >> > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el >> > index 63ebbe6cab..953c0f45fc 100644 >> > --- a/lisp/progmodes/eglot.el >> > +++ b/lisp/progmodes/eglot.el >> > @@ -736,6 +736,7 @@ eglot-client-capabilities >> > t >> > :json-false) >> > :deprecatedSupport t >> > + :resolveSupport (:properties >> ["documentation" "details" "additionalTextEdits"]) >> > :tagSupport (:valueSet [1])) >> > :contextSupport t) >> > :hover (list :dynamicRegistration :json-fal= se >> > -- >> > 2.38.1 >> >> Jo=C3=A3o, what about this one? Should we install it? What are >> resolveSupport capabilities about? >> >> > > -- > Jo=C3=A3o T=C3=A1vora > --000000000000818a8d05eded1fb7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Emacs developers,

I= use clangd and rust-analyzer LSP servers and found this issue
is s= pecific to rust-analyzer.

This advertisement is required by = rust-analyzer server
to provide completions for symbols that are not res= olved
but can be automatically imported. Without advertising, this capab= ility
server does not report such completions, which kind of makes sense= IMHO:

- server can avoid some computations,
- client which does = not support additionalTextEdits capability
=C2=A0 doesn't receive it= ems that can't be auto-imported. User of such
=C2=A0 LSP client= could probably consider such suggestions inaccurate
=C2=A0 (I ap= plied completion and my code does not compile).

I reflected my clarifications in a commit message and= put the patch
in a separate file.

Best regards,
Marcin
<= br>
czw., 1= 7 lis 2022 o 11:40=C2=A0Jo=C3=A3o T=C3=A1vora <joaotavora@gmail.com> napisa=C5=82(a):
What the= se particular capabilities are about can be seen
in the LSP spec.= =C2=A0 I haven't checked, but=C2=A0 I think this refers to
Eg= lot's capability to present meta information about a given
completion item and to do additional things elsewhere in the
<= div>buffer once a given completion item is chosen by the user.=C2=A0
So, typically you may be given the completion:

=C2=A0=C2=A0 std::cout

and if you do choose = it, Eglot and LSP try to ensure that
an #include <iostream>= appears in the top of your C++ file.

In gener= al, normally both client and server advertise their
capabili= ties to each other so that the other side refrains from
doing any= thing that is not explicitly mentioned in these
advertisements.= =C2=A0 This is how there are really no "versions of
the prot= ocol" (well there are, but they aren't used in the way
a= normal versioned API is used).=C2=A0 It doesn't always work that
=
way, and both clients and servers will both request stuff that
isn't possible and volunteer stuff that isn't needed.
<= div>
It's indeed odd to find that Eglot starts advertisin= g a
capability just by itself, without adding any new functional=
code presumably backing that advertisement, so you're right<= /div>
to be suspicious, Eli.

But it may be= just that the advertisement was incorrectly
glossed over in = the past (which wouldn't necessarily present
a problem since = many servers don't bother to check
advertisements, as explain= ed), or -- also possible -- that the
advertisement wasn't eve= n specified in the past.

Most importantly, I would= like Marcin to explain, if possible,
what actual problem with wh= at server this is solving.=C2=A0

The reasonin= g and conclusion should be in the commit message
for this patch f= or future reference.

Jo=C3=A3o
=
On Thu= , Nov 17, 2022 at 9:50 AM Eli Zaretskii <eliz@gnu.org> wrote:
> From: Marcin Pajkowski <marcin.pajkowski@gmai= l.com>
> Date: Sat, 12 Nov 2022 14:23:52 +0100
>
> * lisp/progmodes/eglot.el (eglot-client-capabilities): Advertise
> resolveSupport capabilities
> ---
>=C2=A0 lisp/progmodes/eglot.el | 1 +
>=C2=A0 1 file changed, 1 insertion(+)
>
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index 63ebbe6cab..953c0f45fc 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -736,6 +736,7 @@ eglot-client-capabilities
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0t
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0:json-false)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :depr= ecatedSupport t
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :resolveSup= port (:properties ["documentation" "details" "addi= tionalTextEdits"])
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :tagS= upport (:valueSet [1]))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 :contextSupp= ort t)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:hover=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (list :dynamicRegistration :json-fal= se
> --
> 2.38.1

Jo=C3=A3o, what about this one?=C2=A0 Should we install it?=C2=A0 What are<= br> resolveSupport capabilities about?



--
Jo=C3=A3o = T=C3=A1vora
--000000000000818a8d05eded1fb7-- --000000000000818a9005eded1fb9 Content-Type: text/x-patch; charset="US-ASCII"; name="Eglot-Advertise-completion.resolveSupport-capabilities.patch" Content-Disposition: attachment; filename="Eglot-Advertise-completion.resolveSupport-capabilities.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lapth7gn0 RnJvbSA0Y2JhN2ZmYTlhZDg5MzQ2MDFlZmU3MzkxYjViMDM2NjYxZDlmMjQwIE1vbiBTZXAgMTcg MDA6MDA6MDA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ICAgICAgICAgICAgICAgICAgICAgICAgOmRlcHJlY2F0ZWRT dXBwb3J0IHQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnJlc29sdmVT dXBwb3J0ICg6cHJvcGVydGllcyBbImRvY3VtZW50YXRpb24iICJkZXRhaWxzIiAiYWRkaXRpb25h bFRleHRFZGl0cyJdKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6dGFn U3VwcG9ydCAoOnZhbHVlU2V0IFsxXSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICA6Y29udGV4dFN1cHBvcnQgdCkKICAgICAgICAgICAgICA6aG92ZXIgICAgICAgICAgICAg IChsaXN0IDpkeW5hbWljUmVnaXN0cmF0aW9uIDpqc29uLWZhbHNlCi0tIAoyLjM4LjEKCg== --000000000000818a9005eded1fb9--