From 29f2ec24713984d561881980aef578faa2a83068 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Wed, 4 May 2022 21:47:21 +0100 Subject: [PATCH] Consider diagnostic.code when generating flymake diagnostics Not sure this will please everybody, can almost guess someone is going to ask for a custom switch. Instead this info (and the source) should be passed on to Flymake. That's where the custom switch for controlling formatting of diagnostic messages should exist. But that's too much work right now. * eglot.el (eglot-handle-notification): Consider Diagnostic.code. --- lisp/progmodes/eglot.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 81c545e64f9..3a33ad3ec2b 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1957,14 +1957,16 @@ COMMAND is a symbol naming the command." (cond ((null sev) 'eglot-error) ((<= sev 1) 'eglot-error) ((= sev 2) 'eglot-warning) - (t 'eglot-note)))) + (t 'eglot-note))) + (mess (source code message) + (concat source (and code (concat " [" code "]")) ": " message))) (if-let ((buffer (find-buffer-visiting (eglot--uri-to-path uri)))) (with-current-buffer buffer (cl-loop for diag-spec across diagnostics - collect (eglot--dbind ((Diagnostic) range message severity source tags) + collect (eglot--dbind ((Diagnostic) range code message severity source tags) diag-spec - (setq message (concat source ": " message)) + (setq message (mess source code message)) (pcase-let ((`(,beg . ,end) (eglot--range-region range))) ;; Fallback to `flymake-diag-region' if server @@ -2001,8 +2003,8 @@ COMMAND is a symbol naming the command." (cl-loop with path = (expand-file-name (eglot--uri-to-path uri)) for diag-spec across diagnostics - collect (eglot--dbind ((Diagnostic) range message severity source) diag-spec - (setq message (concat source ": " message)) + collect (eglot--dbind ((Diagnostic) code range message severity source) diag-spec + (setq message (mess source code message)) (let* ((start (plist-get range :start)) (line (1+ (plist-get start :line))) (char (1+ (plist-get start :character)))) -- 2.39.5