[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/eglot2emacs 49e56e47d8 066/120: Solve flymake diagnostics synchr
From: |
João Távora |
Subject: |
feature/eglot2emacs 49e56e47d8 066/120: Solve flymake diagnostics synchronization problems |
Date: |
Thu, 20 Oct 2022 07:16:55 -0400 (EDT) |
branch: feature/eglot2emacs
commit 49e56e47d81c0cdfb219d38cb46bfcbdb1c503fd
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Solve flymake diagnostics synchronization problems
A diagnostics-lazy server is one who doesn't re-report already
reported diagnostics when it received textDocument/didSave.
Such is the case of Clangd, for example. Before this change, saving
an Eglot/Clang-managed buffer with some diagnostics caused the Flymake
indicator to display Wait[0 0] until some change was actually done to
the buffer.
That is because Flymake, by default, wants diagnostics on buffer save,
per flymake-start-on-save-buffer. But it doesn't work to simply turn
that off. That's because if one types something and quickly saves,
and the LSP diagnostics do come in after the save (for some reason,
like server latency), then Flymake sometimes doesn't request any
diagnostics at all.
The reason for the Flymake behaviour wasn't investigated, but that
wasn't a very good solution either
Rather this change makes it so that when such a Flymake request comes
in, it always gets served immediately with the latest information.
The latest information is now always stored in eglot--diagnostics,
with eglot--unreported-diagnotics being removed. The up-to-date list
is reported to Flymake whenever it requests it. It is updated
whenever the LSP server decides to.
* eglot.el (eglot--last-reported-diagnostics): Delete.
(eglot--unreported-diagnostics): Delete.
(eglot--diagnostics): New variable..
(eglot--maybe-activate-editing-mode): Use eglot--diagnostics.
(eglot-handle-notification): Set eglot--diaggnostics.
(eglot-flymake-backend): Read eglot--diagnostics. Always report.
(eglot--report-to-flymake): Set eglot--diagnostics.
---
lisp/progmodes/eglot.el | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index d712b06e76..52f61e80f4 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1701,8 +1701,8 @@ Use `eglot-managed-p' to determine if current buffer is
managed.")
(or (eglot-current-server)
(jsonrpc-error "No current JSON-RPC connection")))
-(defvar-local eglot--unreported-diagnostics nil
- "Unreported Flymake diagnostics for this buffer.")
+(defvar-local eglot--diagnostics nil
+ "Flymake diagnostics for this buffer.")
(defvar revert-buffer-preserve-modes)
(defun eglot--after-revert-hook ()
@@ -1717,7 +1717,7 @@ If it is activated, also signal textDocument/didOpen."
;; Called when `revert-buffer-in-progress-p' is t but
;; `revert-buffer-preserve-modes' is nil.
(when (and buffer-file-name (eglot-current-server))
- (setq eglot--unreported-diagnostics `(:just-opened . nil))
+ (setq eglot--diagnostics nil)
(eglot--managed-mode)
(eglot--signal-textDocument/didOpen))))
@@ -1995,7 +1995,7 @@ COMMAND is a symbol naming the command."
finally (cond (eglot--current-flymake-report-fn
(eglot--report-to-flymake diags))
(t
- (setq eglot--unreported-diagnostics (cons t
diags))))))
+ (setq eglot--diagnostics diags)))))
(cl-loop
with path = (expand-file-name (eglot--uri-to-path uri))
for diag-spec across diagnostics
@@ -2305,9 +2305,7 @@ may be called multiple times (respecting the protocol of
`flymake-backend-functions')."
(cond (eglot--managed-mode
(setq eglot--current-flymake-report-fn report-fn)
- ;; Report anything unreported
- (when eglot--unreported-diagnostics
- (eglot--report-to-flymake (cdr eglot--unreported-diagnostics))))
+ (eglot--report-to-flymake eglot--diagnostics))
(t
(funcall report-fn nil))))
@@ -2322,7 +2320,7 @@ may be called multiple times (respecting the protocol of
;; keyword forces flymake to delete
;; them (github#159).
:region (cons (point-min) (point-max))))
- (setq eglot--unreported-diagnostics nil))
+ (setq eglot--diagnostics diags))
(defun eglot-xref-backend () "EGLOT xref backend." 'eglot)
- feature/eglot2emacs b633c29648 112/120: Rename "eglot -> eglot" in docstrings, (continued)
- feature/eglot2emacs b633c29648 112/120: Rename "eglot -> eglot" in docstrings, João Távora, 2022/10/20
- feature/eglot2emacs 5b902b5cbb 110/120: Add support for "single server, multiple modes", João Távora, 2022/10/20
- feature/eglot2emacs 4071eaf8ad 116/120: * eglot.el (version): actually bump to 1.9, João Távora, 2022/10/20
- feature/eglot2emacs 9801e217f9 118/120: Rework header of eglot.el, João Távora, 2022/10/20
- feature/eglot2emacs 77f3157dcd 048/120: Use new jdtls script for eclipse jdt, João Távora, 2022/10/20
- feature/eglot2emacs 349f6b5f78 050/120: Don't advertise didchangewatchedfiles on tramp, João Távora, 2022/10/20
- feature/eglot2emacs 965e1378f1 053/120: Use bounds of thing at point when asking for code actions, João Távora, 2022/10/20
- feature/eglot2emacs a38ce8b28f 052/120: Add simple support for workspacefolders, João Távora, 2022/10/20
- feature/eglot2emacs cb562118cb 047/120: Don't strip invisible text when formatting hover string, João Távora, 2022/10/20
- feature/eglot2emacs 904556f662 058/120: Easier initializationoptions in eglot-server-programs, João Távora, 2022/10/20
- feature/eglot2emacs 49e56e47d8 066/120: Solve flymake diagnostics synchronization problems,
João Távora <=
- feature/eglot2emacs 917e8ffa31 080/120: Add support for jedi-language-server, João Távora, 2022/10/20
- feature/eglot2emacs 9dbc18cbfa 084/120: Tweak some details, fix some bugs, João Távora, 2022/10/20
- feature/eglot2emacs 2a12f622dc 087/120: Eglot-workspace-configuration can be a function, João Távora, 2022/10/20
- feature/eglot2emacs 1986c4df88 089/120: Reply more reasonably to server's workspace/applyedit, João Távora, 2022/10/20
- feature/eglot2emacs bef332a983 101/120: Adjust last commit about workspace configuration, João Távora, 2022/10/20
- feature/eglot2emacs 523547321e 102/120: Allow :initializationoptions in eglot-server-programs, João Távora, 2022/10/20
- feature/eglot2emacs 68b9c03b44 106/120: Don't use three-argument plist-get, João Távora, 2022/10/20
- feature/eglot2emacs 0829d5e7a2 107/120: Revert "fix jdtls support", João Távora, 2022/10/20
- feature/eglot2emacs b205479035 108/120: Fix blunder in eglot--guess-contact, João Távora, 2022/10/20
- feature/eglot2emacs b07fa37d04 113/120: Add half-baked m-x eglot-list-connections, João Távora, 2022/10/20