From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#58777: eldoc + eglot does not highlight the function parameter the cursor is at Date: Sat, 12 Nov 2022 21:12:46 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000008a26bf05ed4c788e" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16400"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58777@debbugs.gnu.org, =?UTF-8?Q?Micha=C5=82?= Dubiel To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 12 22:14:12 2022 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 1otxpL-00046u-Hm for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Nov 2022 22:14:11 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otxpF-0005Wp-AL; Sat, 12 Nov 2022 16:14:05 -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 1otxpD-0005W4-Ch for bug-gnu-emacs@gnu.org; Sat, 12 Nov 2022 16:14: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 1otxpD-0007Uh-4V for bug-gnu-emacs@gnu.org; Sat, 12 Nov 2022 16:14:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1otxpC-00028o-W3 for bug-gnu-emacs@gnu.org; Sat, 12 Nov 2022 16:14:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Nov 2022 21:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58777 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58777-submit@debbugs.gnu.org id=B58777.16682875878147 (code B ref 58777); Sat, 12 Nov 2022 21:14:02 +0000 Original-Received: (at 58777) by debbugs.gnu.org; 12 Nov 2022 21:13:07 +0000 Original-Received: from localhost ([127.0.0.1]:49452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otxoJ-00027K-18 for submit@debbugs.gnu.org; Sat, 12 Nov 2022 16:13:07 -0500 Original-Received: from mail-oa1-f43.google.com ([209.85.160.43]:46726) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otxoG-00026T-Hg for 58777@debbugs.gnu.org; Sat, 12 Nov 2022 16:13:05 -0500 Original-Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-13b6c1c89bdso8815707fac.13 for <58777@debbugs.gnu.org>; Sat, 12 Nov 2022 13:13:04 -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=pFTAUPrTys4oD1ZODtvJqQKKA9W84nXD/1k+ZfUQnQk=; b=Z0pk8KtI/gGneo2NJea0VyEpuljydeXoKjLFajsASI5zRuKlkmQ7N+ftAph5aj6927 RsuQc0/rReAdrwnhK/P4nCROWnDaRbvG3b0KqG+CDwzCROC0ChZBYXDWZo0mNnk4eOLl tE1I2dKRfysXKEPuI4WxpDWmFpQJGyP+sscLgxc4BHvMvo7rw/TaWIBmjSRfa5Bt3HdT 04RyPdZGva5r638eED9eAREroXojJR5m54lhzyAEn7MFSTa/bkFoG6U42lXQvx3t2Ftt S81CdiILyl5IEObqC5Iu2io8bD/SI63L1pg2uhcMNtfGc//+hmnHmzCateACKKBQSfsP BoXg== 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=pFTAUPrTys4oD1ZODtvJqQKKA9W84nXD/1k+ZfUQnQk=; b=BHzbfjTUW0iQmVNq1+blDmLmLJLYlwjstwOvBuy5g4PHb1YcHcV/SB2dAgdF1/J3hg 1OGM6SjKjmdFaOk7OBOAFDIbykXLWfP1RRAGnoTpWNqARvhpeMs+46ZYwNaROgMDVzzm a5ZWAMT2SpWqelv/Wg/4Wy1USDtN9URWa2EqMg+ZyEU9W/gbvy3TZ4JmJqkudJBYi48o OBXsSNdc4INhpsoLHZTROS9XHBE9dxRDZjvl5XZl0/u1JA2uX0mzkeJ1GQLQU+waA0va uiOQIuPTwi+E0paOt1GjvokAiyuqImI3P2X5ljTe2eA3n6cCPvyMFZXHyEo84ZssQKIN 6Qkw== X-Gm-Message-State: ANoB5plBapctr4/axAOdDJjV+kg0N3NQRmqraF/1LeXojVo8BzMt72pk AvXBCfAEcwsaOckcYJZS1TVeP3nKUiuAdV7ZDBioqPK9 X-Google-Smtp-Source: AA0mqf6Rcn54tzup/XYHxSvlZV/ovVkrdHj2OtqEwRt482bFwtgBOBQomiPDd1suqVqosg9h91/58n2BzztfLNrP/XE= X-Received: by 2002:a05:6870:9f13:b0:13b:5ffe:ff70 with SMTP id xl19-20020a0568709f1300b0013b5ffeff70mr3818618oab.171.1668287579169; Sat, 12 Nov 2022 13:12:59 -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:247720 Archived-At: --0000000000008a26bf05ed4c788e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I'd say this looks good. It would be even better with a couple of automated tests, but then again eglot-tests.el hasn't migrated to Emacs yet. Jo=C3=A3o On Sat, Nov 12, 2022, 20:45 Stefan Kangas wrote: > Copying in Jo=C3=A3o; please see the below patch. > > Micha=C5=82 Dubiel writes: > > > Hi, > > > > I have noticed an issue with highlighting the function parameters by > > eldoc when using eglot + pyright python LSP server (version 1.1.276). > > Assume this very simple python code: > > ``` > > def function(arg1, arg2, arg3): > > pass > > > > function(1, 2, 3) > > ``` > > > > If the cursor is placed at any of the arguments of the function call > > statement, eldoc does not highlight the argument the cursor is > > currently at. > > > > This happens because pyright does not include the function name in the > > returned signature help label when the cursor is inside the > > parentheses, i.e (cursor denoted as |) : > > 1. For fun|ction(arg1, arg2, arg3), the returned signature label from > > pyright is: > > (function) function: (arg1: Unknown, arg2: Unknown, arg3: Unknown) -> > None > > > > 2. For function(1|, 2, 3) (please notice the cursor is at arg1): > > (arg1: Unknown, arg2: Unknown, arg3: Unknown) -> None > > > > Because in case 2 there is no function name but only the arguments > > inside the parenthesis, the eglot's `eglot--sig-info' function fails > > to parse the label correctly and mark the `params-start' and > > `params-end' variables. > > > > I believe a simple fix for this is to change the regexp pattern used > > for finding the arguments in the function signature label as in the > > attached patch. It ensures that the parameters are found regardless of > > whether the function name was included in the signature label or not. > > > > Regards, > > Michal > > > > From e9cebcd9aed7d92bd2ea0b692165e5b55adf8084 Mon Sep 17 00:00:00 2001 > > From: Michal Dubiel > > Date: Sun, 23 Oct 2022 19:54:31 +0200 > > Subject: [PATCH] eglot: Support signature labels without a function nam= e > > > > * lisp/progmodes/eglot.el (eglot--sig-info): Support signature labels > > without a function name. > > --- > > lisp/progmodes/eglot.el | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el > > index 71001ba680..f5a00b03c7 100644 > > --- a/lisp/progmodes/eglot.el > > +++ b/lisp/progmodes/eglot.el > > @@ -2909,7 +2909,7 @@ for which LSP on-type-formatting should be > requested." > > (let ((active-param (or activeParameter sig-help-active-param)) > > params-start params-end) > > ;; Ad-hoc attempt to parse label as () > > - (when (looking-at "\\([^(]+\\)(\\([^)]+\\))") > > + (when (looking-at "\\([^(]*\\)(\\([^)]+\\))") > > (setq params-start (match-beginning 2) params-end (match-en= d > 2)) > > (add-face-text-property (match-beginning 1) (match-end 1) > > 'font-lock-function-name-face)) > --0000000000008a26bf05ed4c788e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'd say this looks good. It would be even better= with a couple of automated tests, but then again eglot-tests.el hasn't= migrated to Emacs yet.

= Jo=C3=A3o

On Sat, Nov 12, 2022, 20:45 Stefan Kangas <stefankangas@gmail.com> wrote:
Copying in Jo=C3=A3o; please see the = below patch.

Micha=C5=82 Dubiel <majkijin@gmail.com> writes:

> Hi,
>
> I have noticed an issue with highlighting the function parameters by > eldoc when using eglot + pyright python LSP server (version 1.1.276).<= br> > Assume this very simple python code:
> ```
> def function(arg1, arg2, arg3):
>=C2=A0 =C2=A0 =C2=A0pass
>
> function(1, 2, 3)
> ```
>
> If the cursor is placed at any of the arguments of the function call > statement, eldoc does not highlight the argument the cursor is
> currently at.
>
> This happens because pyright does not include the function name in the=
> returned signature help label when the cursor is inside the
> parentheses, i.e (cursor denoted as |) :
> 1. For fun|ction(arg1, arg2, arg3), the returned signature label from<= br> > pyright is:
> (function) function: (arg1: Unknown, arg2: Unknown, arg3: Unknown) -&g= t; None
>
> 2. For function(1|, 2, 3) (please notice the cursor is at arg1):
> (arg1: Unknown, arg2: Unknown, arg3: Unknown) -> None
>
> Because in case 2 there is no function name but only the arguments
> inside the parenthesis, the eglot's `eglot--sig-info' function= fails
> to parse the label correctly and mark the `params-start' and
> `params-end' variables.
>
> I believe a simple fix for this is to change the regexp pattern used > for finding the arguments in the function signature label as in the > attached patch. It ensures that the parameters are found regardless of=
> whether the function name was included in the signature label or not.<= br> >
> Regards,
> Michal
>
> From e9cebcd9aed7d92bd2ea0b692165e5b55adf8084 Mon Sep 17 00:00:00 2001=
> From: Michal Dubiel <majkijin@gmail.com>
> Date: Sun, 23 Oct 2022 19:54:31 +0200
> Subject: [PATCH] eglot: Support signature labels without a function na= me
>
> * lisp/progmodes/eglot.el (eglot--sig-info): Support signature labels<= br> > without a function name.
> ---
>=C2=A0 lisp/progmodes/eglot.el | 2 +-
>=C2=A0 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index 71001ba680..f5a00b03c7 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -2909,7 +2909,7 @@ for which LSP on-type-formatting should be reque= sted."
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((active-param (or activeParamet= er sig-help-active-param))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0params-start par= ams-end)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; Ad-hoc attempt to parse lab= el as <name>(<params>)
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (looking-at "\\([^(]+\\)= (\\([^)]+\\))")
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (looking-at "\\([^(]*\\)= (\\([^)]+\\))")
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq params-start (mat= ch-beginning 2) params-end (match-end 2))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(add-face-text-property= (match-beginning 1) (match-end 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'font-loc= k-function-name-face))
--0000000000008a26bf05ed4c788e--