From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "João Távora" <joaotavora@gmail.com>
Cc: 50244-done@debbugs.gnu.org,
Philipp Stephani <p.stephani2@gmail.com>,
Dmitry Gutov <dgutov@yandex.ru>
Subject: bug#50244: 28.0.50; Support project-wide diagnostics reports in flymake.el
Date: Tue, 14 Sep 2021 14:22:42 +0200 [thread overview]
Message-ID: <B39218BB-66AE-4411-BD3D-ADB7D3349965@thornhill.no> (raw)
In-Reply-To: <87ee9r2xwt.fsf@gmail.com>
On 14 September 2021 13:34:42 CEST, "João Távora" <joaotavora@gmail.com> wrote:
>Hi Theodor,
>
>I've now pushed this to master, so I'm marking the bug done. But we
>can keep discussing the Eglot patch here (or in another bug, or in
>Eglot's tracker, as you prefer...)
>
Great.
>Theodor Thornhill <theo@thornhill.no> writes:
>
>>>Thanks. I think I'll try rust-analyzer as I've been meaning to anyway.
>>>Perhaps make it the default Rust server for Eglot.
>> Absolutely, the community seems to have moved on.
>
>Actually I did still try with `rls` since that was most handy and it
>also provides diagnostics for other files on startup. So I tested it
>with rls and got decent results (see Eglot patch).
>
>> By the way- these list only diagnostics do in fact happen on each
>> keystroke in the mentioned servers. Not just on the first load.
>> Would this mean the foreign variant is more correct to use?
>
>Yes, it would, indeed. I don't know if _every_ server operates like
>that, though. But doesn't matter. Are you saying that in your server,
>making a modification to any file always brings in diagnostics for all
>other files, too?
>
Yeah. For any edit in any file, _all_ diagnostics for everything gets re-sent. I've made the assumption earlier that everything is to be flushed every time.
>Anyway, I've tested a bit with Eglot and flymake-list-only-diagnostics
>and it seems to do the right thing (mostly). I attach the Eglot patch
>which you can use as starting point.
>
Thank you! I'll follow up on this tonight if time permits :)
>diff --git a/eglot.el b/eglot.el
>index 7ebc422..d036a75 100644
>--- a/eglot.el
>+++ b/eglot.el
>@@ -1386,6 +1386,11 @@ Doubles as an indicator of snippet support."
> (font-lock-ensure)
> (string-trim (filter-buffer-substring (point-min) (point-max))))))
>
>+(defun eglot--diag-type (severity)
>+ (cond ((<= severity 1) 'eglot-error)
>+ ((= severity 2) 'eglot-warning)
>+ (t 'eglot-note)))
>+
> (define-obsolete-variable-alias 'eglot-ignored-server-capabilites
> 'eglot-ignored-server-capabilities "1.8")
>
>@@ -1788,8 +1793,7 @@ COMMAND is a symbol naming the command."
> diag-spec
> (setq message (concat source ": " message))
> (pcase-let
>- ((sev severity)
>- (`(,beg . ,end) (eglot--range-region range)))
>+ ((`(,beg . ,end) (eglot--range-region range)))
> ;; Fallback to `flymake-diag-region' if server
> ;; botched the range
> (when (= beg end)
>@@ -1808,16 +1812,26 @@ COMMAND is a symbol naming the command."
> (point-at-eol
> (1+ (plist-get (plist-get range :end) :line)))))))
> (eglot--make-diag (current-buffer) beg end
>- (cond ((<= sev 1) 'eglot-error)
>- ((= sev 2) 'eglot-warning)
>- (t 'eglot-note))
>+ (eglot--diag-type severity)
> message `((eglot-lsp-diag . ,diag-spec)))))
> into diags
> finally (cond (eglot--current-flymake-report-fn
> (eglot--report-to-flymake diags))
> (t
> (setq eglot--unreported-diagnostics (cons t diags))))))
>- (jsonrpc--debug server "Diagnostics received for unvisited %s" uri)))
>+ (cl-loop
>+ with path = (expand-file-name (eglot--uri-to-path uri))
>+ for diag-spec across diagnostics
>+ collect (eglot--dbind ((Diagnostic) message severity source) diag-spec
>+ (setq message (concat source ": " message))
>+ (eglot--make-diag path (cons 1 1) nil ; cons 1 1 bcs lazy...
>+ (eglot--diag-type severity)
>+ message))
>+ into diags
>+ finally
>+ (setq flymake-list-only-diagnostics
>+ (assoc-delete-all path flymake-list-only-diagnostics #'string=))
>+ (push (cons path diags) flymake-list-only-diagnostics))))
>
> (cl-defun eglot--register-unregister (server things how)
> "Helper for `registerCapability'.
>
>
>
next prev parent reply other threads:[~2021-09-14 12:22 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-29 0:53 bug#50244: 28.0.50; Support project-wide diagnostics reports in flymake.el João Távora
2021-08-29 23:27 ` Dmitry Gutov
2021-08-30 7:00 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-30 8:46 ` João Távora
2021-09-11 1:08 ` João Távora
2021-09-13 0:08 ` Dmitry Gutov
2021-09-13 6:48 ` João Távora
2021-09-13 18:03 ` João Távora
2021-09-13 19:47 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-13 20:04 ` João Távora
2021-09-13 20:21 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-14 8:50 ` João Távora
2021-09-14 9:21 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-14 11:34 ` João Távora
2021-09-14 12:22 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-10-23 19:22 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-23 20:22 ` João Távora
2021-10-23 20:50 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-09-13 20:11 ` Dmitry Gutov
2021-09-14 8:20 ` João Távora
2021-09-16 22:27 ` Dmitry Gutov
2021-09-16 23:37 ` João Távora
2021-09-13 20:26 ` Dmitry Gutov
2021-09-13 20:53 ` João Távora
2021-09-13 23:35 ` Dmitry Gutov
2021-09-14 8:43 ` João Távora
2021-09-16 22:19 ` Dmitry Gutov
2021-09-16 23:36 ` João Távora
2021-09-18 1:19 ` Dmitry Gutov
2021-09-18 9:59 ` João Távora
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B39218BB-66AE-4411-BD3D-ADB7D3349965@thornhill.no \
--to=bug-gnu-emacs@gnu.org \
--cc=50244-done@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
--cc=joaotavora@gmail.com \
--cc=p.stephani2@gmail.com \
--cc=theo@thornhill.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).