[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/eglot2emacs 0f44d338f1 025/120: Support optional diagnostic.tags
From: |
João Távora |
Subject: |
feature/eglot2emacs 0f44d338f1 025/120: Support optional diagnostic.tags |
Date: |
Thu, 20 Oct 2022 07:16:46 -0400 (EDT) |
branch: feature/eglot2emacs
commit 0f44d338f17bd426ab43f6a619873c9ac91bc51e
Author: Brian Leung <bkleung89@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>
Support optional diagnostic.tags
https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#diagnosticTag
A DiagnosticTag can be either 1 (DiagnosticTag.Unnecessary) or
2 (DiagnosticTag.Deprecated). Following the rendering suggestions in
the protocol, we fade out Unnecessary code and strike-through
Deprecated code.
* eglot.el (eglot-diagnostic-tag-unnecessary-face)
(eglot-diagnostic-tag-deprecated-face): New faces.
(eglot--tag-faces): New defconst.
(eglot--lsp-interface-alist): Add Diagnostic.tags.
(eglot-client-capabilities): Advertise supported tags.
(eglot-handle-notification): Assign the appropriate properties.
* eglot-tests.el (diagnostic-tags-unnecessary-code): New test.
GitHub-reference: per https://github.com/joaotavora/eglot/issues/794
---
lisp/progmodes/eglot.el | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 813b29775e..dc20ef751b 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -252,6 +252,14 @@ CONTACT can be:
'((t (:inherit font-lock-constant-face :weight bold)))
"Face for package-name in EGLOT's mode line.")
+(defface eglot-diagnostic-tag-unnecessary-face
+ '((t . (:weight ultra-light)))
+ "Face used to render unused or unnecessary code.")
+
+(defface eglot-diagnostic-tag-deprecated-face
+ '((t . (:strike-through t)))
+ "Face used to render deprecated or obsolete code.")
+
(defcustom eglot-autoreconnect 3
"Control ability to reconnect automatically to the LSP server.
If t, always reconnect automatically (not recommended). If nil,
@@ -332,6 +340,10 @@ This can be useful when using docker to run a language
server.")
(21 . "Constant") (22 . "Struct") (23 . "Event") (24 . "Operator")
(25 . "TypeParameter")))
+(defconst eglot--tag-faces
+ `((1 . eglot-diagnostic-tag-unnecessary-face)
+ (2 . eglot-diagnostic-tag-deprecated-face)))
+
(defconst eglot--{} (make-hash-table) "The empty JSON object.")
(defun eglot--executable-find (command &optional remote)
@@ -353,7 +365,7 @@ This can be useful when using docker to run a language
server.")
:sortText :filterText :insertText
:insertTextFormat
:textEdit :additionalTextEdits :commitCharacters
:command :data))
- (Diagnostic (:range :message) (:severity :code :source
:relatedInformation :codeDescription))
+ (Diagnostic (:range :message) (:severity :code :source
:relatedInformation :codeDescription :tags))
(DocumentHighlight (:range) (:kind))
(FileSystemWatcher (:globPattern) (:kind))
(Hover (:contents) (:range))
@@ -695,7 +707,11 @@ treated as in `eglot-dbind'."
;; TODO: We can support
:codeDescription after
;; adding an appropriate UI to
;; Flymake.
- :codeDescriptionSupport :json-false))
+ :codeDescriptionSupport :json-false
+ :tagSupport
+ `(:valueSet
+ [,@(mapcar
+ #'car eglot--tag-faces)])))
:experimental eglot--{})))
(defclass eglot-lsp-server (jsonrpc-process-connection)
@@ -1811,7 +1827,7 @@ COMMAND is a symbol naming the command."
(with-current-buffer buffer
(cl-loop
for diag-spec across diagnostics
- collect (eglot--dbind ((Diagnostic) range message severity source)
+ collect (eglot--dbind ((Diagnostic) range message severity source
tags)
diag-spec
(setq message (concat source ": " message))
(pcase-let
@@ -1839,7 +1855,11 @@ COMMAND is a symbol naming the command."
((<= sev 1) 'eglot-error)
((= sev 2) 'eglot-warning)
(t 'eglot-note))
- message `((eglot-lsp-diag .
,diag-spec)))))
+ message `((eglot-lsp-diag . ,diag-spec))
+ (and tags
+ `((face . ,(mapcar (lambda (tag)
+ (alist-get
tag eglot--tag-faces))
+ tags)))))))
into diags
finally (cond (eglot--current-flymake-report-fn
(eglot--report-to-flymake diags))
- feature/eglot2emacs fb8706165c 004/120: Use fortls also for fortran-mode, (continued)
- feature/eglot2emacs fb8706165c 004/120: Use fortls also for fortran-mode, João Távora, 2022/10/20
- feature/eglot2emacs a218f52ec9 012/120: Un-reverse references in xref buffer, João Távora, 2022/10/20
- feature/eglot2emacs be1e214fb2 013/120: Add cmake-language-server for cmake-mode, João Távora, 2022/10/20
- feature/eglot2emacs 512d8b9f59 011/120: Add variable to withhold the init req process id, João Távora, 2022/10/20
- feature/eglot2emacs 09c071d3d1 019/120: Add tooltip describing pending requests, João Távora, 2022/10/20
- feature/eglot2emacs f0b9018f52 018/120: Properly print error message of eglot-alternatives, João Távora, 2022/10/20
- feature/eglot2emacs ae7315b5f1 016/120: ; fix license statement, João Távora, 2022/10/20
- feature/eglot2emacs 49e46c3d53 017/120: Add up-to-date server executables for html/css/json, João Távora, 2022/10/20
- feature/eglot2emacs 34c7da506d 020/120: Support autoimporttext from pyright language server, João Távora, 2022/10/20
- feature/eglot2emacs 9adb310e08 021/120: Don't error out on unsupported diagnostic.codedescription, João Távora, 2022/10/20
- feature/eglot2emacs 0f44d338f1 025/120: Support optional diagnostic.tags,
João Távora <=
- feature/eglot2emacs 0739cdcf20 031/120: Improve backwards-compatibility of eglot-mode-map, João Távora, 2022/10/20
- feature/eglot2emacs 9710754080 042/120: Add support for optional completionitem.tags, João Távora, 2022/10/20
- feature/eglot2emacs c2d97d22aa 056/120: Implement on-type-formatting support, João Távora, 2022/10/20
- feature/eglot2emacs 1d9542cbe8 059/120: Protect against empty firsttriggercharacter strings, João Távora, 2022/10/20
- feature/eglot2emacs a63916f928 062/120: Tweak eglot mode-line menus, João Távora, 2022/10/20
- feature/eglot2emacs 4beab004d9 070/120: Ensure exit-function of eglot-c-at-point runs on exact match, João Távora, 2022/10/20
- feature/eglot2emacs 29f2ec2471 071/120: Consider diagnostic.code when generating flymake diagnostics, João Távora, 2022/10/20
- feature/eglot2emacs cc5d1a5a72 091/120: Always default eglot-strict-mode to nil, João Távora, 2022/10/20
- feature/eglot2emacs e74e199912 093/120: Add out-of-box support for perl lsp server, João Távora, 2022/10/20
- feature/eglot2emacs d2e842bbf5 098/120: Prefer documentchanges to changes in server-initiated edits, João Távora, 2022/10/20