From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#50244: 28.0.50; Support project-wide diagnostics reports in flymake.el Date: Tue, 14 Sep 2021 14:22:42 +0200 Message-ID: References: <87bl5hm5qj.fsf@gmail.com> <87y283536t.fsf@gmail.com> <41cd4854-d162-bc6c-900e-96a4245e2c59@yandex.ru> <87o88w4al4.fsf@gmail.com> <87ilz444zy.fsf@gmail.com> <87k0jj35iz.fsf@gmail.com> <46AA4768-F628-49C5-A933-8ED43814CAC9@thornhill.no> <87ee9r2xwt.fsf@gmail.com> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1598"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 50244-done@debbugs.gnu.org, Philipp Stephani , Dmitry Gutov 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 Tue Sep 14 14:23:11 2021 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 1mQ7Sw-0000Aj-Jp for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Sep 2021 14:23:11 +0200 Original-Received: from localhost ([::1]:37742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ7Sv-0000D3-8K for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 14 Sep 2021 08:23:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ7Sp-0000Cv-5Z for bug-gnu-emacs@gnu.org; Tue, 14 Sep 2021 08:23:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36321) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mQ7So-00049E-UB for bug-gnu-emacs@gnu.org; Tue, 14 Sep 2021 08:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mQ7So-0005aD-Gb for bug-gnu-emacs@gnu.org; Tue, 14 Sep 2021 08:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 14 Sep 2021 12:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50244 X-GNU-PR-Package: emacs Original-Received: via spool by 50244-done@debbugs.gnu.org id=D50244.163162217221428 (code D ref 50244); Tue, 14 Sep 2021 12:23:02 +0000 Original-Received: (at 50244-done) by debbugs.gnu.org; 14 Sep 2021 12:22:52 +0000 Original-Received: from localhost ([127.0.0.1]:47867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQ7Se-0005ZX-FK for submit@debbugs.gnu.org; Tue, 14 Sep 2021 08:22:52 -0400 Original-Received: from out2.migadu.com ([188.165.223.204]:24440) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQ7Sa-0005ZM-TQ for 50244-done@debbugs.gnu.org; Tue, 14 Sep 2021 08:22:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1631622167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pSiRXhluNs++BuCYY18Tsn383Yxicem1cNJzh6xpl1A=; b=UamYNoJHc+KRUVBFB/yT01rgk7IJhbNkTgbXQhBqo83Xv8hogH8VZ2mARARoIvtzR1v4N8 NYdbUDQljKZq6jVc2XCnsp6fIox0DtRPkQpBTue/EiSglaWCTKjGCEfgCMZALlU/tzzzUh lBh0kKkcGXkJDMAWF8KwiF52hWW/T1aKEy4nPe26cpXLNUWyXvS2NvVEF4p4+Xm7Sg/x1L WyDYVfixJjVcmrDLbGPHVfKpn1rZ+PEUhR2O4E8UdGz5bxwMjaXNdIM/EJEa1FAZhferk6 3NS0E7wq5eoSrKJsvrozmcbUktlOesHb2mpSIifTHEm1WOolRTfGwjVh3sdB1g== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-Reply-To: <87ee9r2xwt.fsf@gmail.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: theo@thornhill.no 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" Xref: news.gmane.io gmane.emacs.bugs:214303 Archived-At: On 14 September 2021 13:34:42 CEST, "Jo=C3=A3o T=C3=A1vora" wrote: >Hi Theodor, > >I've now pushed this to master, so I'm marking the bug done=2E But we >can keep discussing the Eglot patch here (or in another bug, or in >Eglot's tracker, as you prefer=2E=2E=2E) > Great=2E >Theodor Thornhill writes: > >>>Thanks=2E I think I'll try rust-analyzer as I've been meaning to anywa= y=2E >>>Perhaps make it the default Rust server for Eglot=2E >> Absolutely, the community seems to have moved on=2E > >Actually I did still try with `rls` since that was most handy and it >also provides diagnostics for other files on startup=2E So I tested it >with rls and got decent results (see Eglot patch)=2E > >> By the way- these list only diagnostics do in fact happen on each >> keystroke in the mentioned servers=2E Not just on the first load=2E >> Would this mean the foreign variant is more correct to use? > >Yes, it would, indeed=2E I don't know if _every_ server operates like >that, though=2E But doesn't matter=2E Are you saying that in your serve= r, >making a modification to any file always brings in diagnostics for all >other files, too? > Yeah=2E For any edit in any file, _all_ diagnostics for everything gets re= -sent=2E I've made the assumption earlier that everything is to be flushed= every time=2E=20 >Anyway, I've tested a bit with Eglot and flymake-list-only-diagnostics >and it seems to do the right thing (mostly)=2E I attach the Eglot patch >which you can use as starting point=2E > Thank you! I'll follow up on this tonight if time permits :) >diff --git a/eglot=2Eel b/eglot=2Eel >index 7ebc422=2E=2Ed036a75 100644 >--- a/eglot=2Eel >+++ b/eglot=2Eel >@@ -1386,6 +1386,11 @@ Doubles as an indicator of snippet support=2E" > (font-lock-ensure) > (string-trim (filter-buffer-substring (point-min) (point-max)))))) >=20 >+(defun eglot--diag-type (severity) >+ (cond ((<=3D severity 1) 'eglot-error) >+ ((=3D severity 2) 'eglot-warning) >+ (t 'eglot-note))) >+ > (define-obsolete-variable-alias 'eglot-ignored-server-capabilites > 'eglot-ignored-server-capabilities "1=2E8") >=20 >@@ -1788,8 +1793,7 @@ COMMAND is a symbol naming the command=2E" > diag-spec > (setq message (concat source ": " message)) > (pcase-let >- ((sev severity) >- (`(,beg =2E ,end) (eglot--range-region range))) >+ ((`(,beg =2E ,end) (eglot--range-region range))) > ;; Fallback to `flymake-diag-region' if server > ;; botched the range > (when (=3D beg end) >@@ -1808,16 +1812,26 @@ COMMAND is a symbol naming the command=2E" > (point-at-eol > (1+ (plist-get (plist-get range :end) := line))))))) > (eglot--make-diag (current-buffer) beg end >- (cond ((<=3D sev 1) 'eglot-error) >- ((=3D sev 2) 'eglot-warnin= g) >- (t 'eglot-note)) >+ (eglot--diag-type severity) > message `((eglot-lsp-diag =2E ,di= ag-spec))))) > into diags > finally (cond (eglot--current-flymake-report-fn > (eglot--report-to-flymake diags)) > (t > (setq eglot--unreported-diagnostics (cons t diag= s)))))) >- (jsonrpc--debug server "Diagnostics received for unvisited %s" uri))= ) >+ (cl-loop >+ with path =3D (expand-file-name (eglot--uri-to-path uri)) >+ for diag-spec across diagnostics >+ collect (eglot--dbind ((Diagnostic) message severity source) diag-s= pec >+ (setq message (concat source ": " message)) >+ (eglot--make-diag path (cons 1 1) nil ; cons 1 1 bcs lazy= =2E=2E=2E >+ (eglot--diag-type severity) >+ message)) >+ into diags >+ finally >+ (setq flymake-list-only-diagnostics >+ (assoc-delete-all path flymake-list-only-diagnostics #'string= =3D)) >+ (push (cons path diags) flymake-list-only-diagnostics)))) >=20 > (cl-defun eglot--register-unregister (server things how) > "Helper for `registerCapability'=2E > > >