[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot f930a09 1/8: Fix #596: generalize eglot-flymake-b
From: |
Stefan Monnier |
Subject: |
[elpa] externals/eglot f930a09 1/8: Fix #596: generalize eglot-flymake-backend |
Date: |
Wed, 14 Apr 2021 18:53:07 -0400 (EDT) |
branch: externals/eglot
commit f930a096ebe37212949593feeb420170f52d944a
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Fix #596: generalize eglot-flymake-backend
Loosen coupling between eglot-flymake-backend and flymake-mode. The
flymake-mode check in 'eglot-handle-notification publishDiagnostics'
was a hack (and it wasn't even functioning correctly on M-x
eglot-shutdown/eglot-reconnect).
This should also allow eglot-flymake-backend to be driven by
diagnostic-annotating frontends other than Flymake, such as the
popular Flycheck package.
* eglot.el (eglot--managed-mode): Use eglot--report-to-flymake.
(eglot-handle-notification textDocument/publishDiagnostics): Use
eglot--report-to-flymake.
---
eglot.el | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/eglot.el b/eglot.el
index 03e8baa..c236388 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1445,7 +1445,9 @@ Use `eglot-managed-p' to determine if current buffer is
managed.")
(cl-loop for (var . saved-binding) in eglot--saved-bindings
do (set (make-local-variable var) saved-binding))
(remove-function (local 'imenu-create-index-function) #'eglot-imenu)
- (setq eglot--current-flymake-report-fn nil)
+ (when eglot--current-flymake-report-fn
+ (eglot--report-to-flymake nil)
+ (setq eglot--current-flymake-report-fn nil))
(let ((server eglot--cached-server))
(setq eglot--cached-server nil)
(when server
@@ -1680,17 +1682,8 @@ COMMAND is a symbol naming the command."
(t 'eglot-note))
message `((eglot-lsp-diag .
,diag-spec)))))
into diags
- finally (cond ((and flymake-mode eglot--current-flymake-report-fn)
- (save-restriction
- (widen)
- (funcall eglot--current-flymake-report-fn diags
- ;; If the buffer hasn't changed since last
- ;; call to the report function, flymake
won't
- ;; delete old diagnostics. Using :region
- ;; keyword forces flymake to delete
- ;; them (github#159).
- :region (cons (point-min) (point-max))))
- (setq eglot--unreported-diagnostics nil))
+ 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)))
@@ -1970,13 +1963,28 @@ When called interactively, use the currently active
server"
:textDocument (eglot--TextDocumentIdentifier))))
(defun eglot-flymake-backend (report-fn &rest _more)
- "An EGLOT Flymake backend.
-Calls REPORT-FN maybe if server publishes diagnostics in time."
+ "A Flymake backend for Eglot.
+Calls REPORT-FN (or arranges for it to be called) when the server
+publishes diagnostics. Between calls to this function, REPORT-FN
+may be called multiple times (respecting the protocol of
+`flymake-backend-functions')."
(setq eglot--current-flymake-report-fn report-fn)
;; Report anything unreported
(when eglot--unreported-diagnostics
- (funcall report-fn (cdr eglot--unreported-diagnostics))
- (setq eglot--unreported-diagnostics nil)))
+ (eglot--report-to-flymake (cdr eglot--unreported-diagnostics))))
+
+(defun eglot--report-to-flymake (diags)
+ "Internal helper for `eglot-flymake-backend'."
+ (save-restriction
+ (widen)
+ (funcall eglot--current-flymake-report-fn diags
+ ;; If the buffer hasn't changed since last
+ ;; call to the report function, flymake won't
+ ;; delete old diagnostics. Using :region
+ ;; keyword forces flymake to delete
+ ;; them (github#159).
+ :region (cons (point-min) (point-max))))
+ (setq eglot--unreported-diagnostics nil))
(defun eglot-xref-backend () "EGLOT xref backend." 'eglot)
- [elpa] externals/eglot updated (2fbcab2 -> fc221c8), Stefan Monnier, 2021/04/14
- [elpa] externals/eglot f930a09 1/8: Fix #596: generalize eglot-flymake-backend,
Stefan Monnier <=
- [elpa] externals/eglot c65a032 5/8: Close #652: add :company-kind to eglot-completion-at-point, Stefan Monnier, 2021/04/14
- [elpa] externals/eglot c34ec42 2/8: Per #645: Attempt to speed up initial directory/glob correspondence, Stefan Monnier, 2021/04/14
- [elpa] externals/eglot 05fe647 7/8: Per #667: add a passing test demonstrating clangd + TRAMP works, Stefan Monnier, 2021/04/14
- [elpa] externals/eglot fc221c8 8/8: Overhaul bug reporting template, Stefan Monnier, 2021/04/14
- [elpa] externals/eglot 8a5598d 3/8: Fix #650: Highlight relevant part of xref hits using xref-match face, Stefan Monnier, 2021/04/14
- [elpa] externals/eglot a79bb5f 4/8: Overhaul bug-reporting template, Stefan Monnier, 2021/04/14
- [elpa] externals/eglot dd51bf2 6/8: Merge pull request #656 from mohkale/company-kind, Stefan Monnier, 2021/04/14