[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot fdb4de1 039/139: Simplify flymake integration
From: |
João Távora |
Subject: |
[elpa] externals/eglot fdb4de1 039/139: Simplify flymake integration |
Date: |
Mon, 14 May 2018 09:54:50 -0400 (EDT) |
branch: externals/eglot
commit fdb4de165885d4ff777a40dcaca289452545db8d
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Simplify flymake integration
And get rid of the ridiculous environment thingy
* eglot.el (eglot--process-sentinel): Continuations are triplets.
(eglot--environment-vars, eglot--environment): Remove.
(eglot--process-receive): Simplify.
(eglot--unreported-diagnostics): New variable.
(eglot--textDocument/publishDiagnostics): Simplify.
(eglot-flymake-backend): Report unreported diagnostics.
---
eglot.el | 58 +++++++++++++++++++++++-----------------------------------
1 file changed, 23 insertions(+), 35 deletions(-)
diff --git a/eglot.el b/eglot.el
index 8584440..8bb0729 100644
--- a/eglot.el
+++ b/eglot.el
@@ -229,8 +229,8 @@ INTERACTIVE is t if called interactively."
(when (not (process-live-p process))
;; Remember to cancel all timers
;;
- (maphash (lambda (id quad)
- (cl-destructuring-bind (_success _error timeout _env) quad
+ (maphash (lambda (id triplet)
+ (cl-destructuring-bind (_success _error timeout) triplet
(eglot--message
"(sentinel) Cancelling timer for continuation %s" id)
(cancel-timer timeout)))
@@ -349,13 +349,6 @@ identifier. ERROR is non-nil if this is an error."
(setq msg (propertize msg 'face 'error)))
(insert msg)))))
-(defvar eglot--environment-vars
- '(eglot--current-flymake-report-fn)
- "A list of variables with saved values on every request.")
-
-(defvar eglot--environment nil
- "Dynamically bound alist of symbol and values.")
-
(defun eglot--process-receive (proc message)
"Process MESSAGE from PROC."
(let* ((response-id (plist-get message :id))
@@ -388,13 +381,9 @@ identifier. ERROR is non-nil if this is an error."
(t
(let* ((method (plist-get message :method))
(handler-sym (intern (concat "eglot--"
- method)))
- (eglot--environment (cl-fourth continuations)))
+ method))))
(if (functionp handler-sym)
- (cl-progv
- (mapcar #'car eglot--environment)
- (mapcar #'cdr eglot--environment)
- (apply handler-sym proc (plist-get message :params)))
+ (apply handler-sym proc (plist-get message :params))
(eglot--debug "No implemetation for notification %s yet"
method)))))))
@@ -476,9 +465,7 @@ identifier. ERROR is non-nil if this is an error."
error-fn
(lambda (&rest args)
(throw catch-tag (apply error-fn args))))
- timeout-timer
- (cl-loop for var in eglot--environment-vars
- collect (cons var (symbol-value var))))
+ timeout-timer)
(eglot--pending-continuations process))
(unless async-p
(unwind-protect
@@ -563,23 +550,18 @@ running. INTERACTIVE is t if called interactively."
;;; Notifications
;;;
-(defvar eglot--current-flymake-report-fn nil)
+(defvar-local eglot--current-flymake-report-fn nil
+ "Current flymake report function for this buffer")
+(defvar-local eglot--unreported-diagnostics nil
+ "Unreported diagnostics for this buffer.")
(cl-defun eglot--textDocument/publishDiagnostics
(_process &key uri diagnostics)
"Handle notification publishDiagnostics"
(let* ((obj (url-generic-parse-url uri))
(filename (car (url-path-and-query obj)))
- (buffer (find-buffer-visiting filename))
- (report-fn (cdr (assoc 'eglot--current-flymake-report-fn
- eglot--environment))))
+ (buffer (find-buffer-visiting filename)))
(cond
- ((not eglot--current-flymake-report-fn)
- (eglot--warn "publishDiagnostics called but no report-fn"))
- ((and report-fn
- (not (eq report-fn
- eglot--current-flymake-report-fn)))
- (eglot--warn "outdated publishDiagnostics report from server"))
(buffer
(with-current-buffer buffer
(cl-flet ((pos-at
@@ -607,9 +589,12 @@ running. INTERACTIVE is t if called interactively."
:note))
message))))
into diags
- finally (funcall
- eglot--current-flymake-report-fn
- diags)))))
+ finally
+ (if eglot--current-flymake-report-fn
+ (funcall eglot--current-flymake-report-fn
+ diags)
+ (setq eglot--unreported-diagnostics
+ diags))))))
(t
(eglot--message "OK so %s isn't visited" filename)))))
@@ -875,11 +860,14 @@ running. INTERACTIVE is t if called interactively."
(defun eglot-flymake-backend (report-fn &rest _more)
"An EGLOT Flymake backend.
Calls REPORT-FN maybe if server publishes diagnostics in time."
- ;; call immediately with no diagnostics, this just means we don't
- ;; have them yet (and also clears any pending ones).
- ;;
- (funcall report-fn nil)
+ ;; Call immediately with anything unreported (this will clear any
+ ;; pending diags)
+ (funcall report-fn eglot--unreported-diagnostics)
+ (setq eglot--unreported-diagnostics nil)
+ ;; Setup so maybe it's called later, too.
(setq eglot--current-flymake-report-fn report-fn)
+ ;; Take this opportunity to signal a didChange that might eventually
+ ;; make the server report new diagnostics.
(eglot--maybe-signal-didChange))
- [elpa] externals/eglot 9d404c9 054/139: Update README.md, (continued)
- [elpa] externals/eglot 9d404c9 054/139: Update README.md, João Távora, 2018/05/14
- [elpa] externals/eglot 29d4103 056/139: Fix mode-line mouse-clicks from outside selected window, João Távora, 2018/05/14
- [elpa] externals/eglot b1554fc 055/139: * eglot.el (eglot--process-receive): Skip null method notifs., João Távora, 2018/05/14
- [elpa] externals/eglot 51ff863 046/139: Must re-announce didOpen after reconnect, João Távora, 2018/05/14
- [elpa] externals/eglot c95a0a4 041/139: Multiple servers per project are possible, João Távora, 2018/05/14
- [elpa] externals/eglot f8bfb7e 064/139: Handle requests from server correctly, João Távora, 2018/05/14
- [elpa] externals/eglot b69302c 060/139: Make M-x eglot's interactive spec a separate function, João Távora, 2018/05/14
- [elpa] externals/eglot b657b32 068/139: Use rootUri instead of rootPath, João Távora, 2018/05/14
- [elpa] externals/eglot 7d0bf64 062/139: Workaround RLS's regusal to treat nil as empty json object, João Távora, 2018/05/14
- [elpa] externals/eglot 75495dc 033/139: Slightly more user friendly start, João Távora, 2018/05/14
- [elpa] externals/eglot fdb4de1 039/139: Simplify flymake integration,
João Távora <=
- [elpa] externals/eglot cc183a6 043/139: Fix assorted bugs, João Távora, 2018/05/14
- [elpa] externals/eglot df5d76d 065/139: Reply to client/registerCapability (don't handle it yet), João Távora, 2018/05/14
- [elpa] externals/eglot c2862f4 063/139: Don't auto-reconnect if last attempt lasted less than 3 seconds, João Távora, 2018/05/14
- [elpa] externals/eglot f1b6485 053/139: Trim some edges and add a bunch of boring RPC methods, João Távora, 2018/05/14
- [elpa] externals/eglot 0e95167 042/139: Watch for files opened under umbrella of existing process, João Távora, 2018/05/14
- [elpa] externals/eglot 4d4b85d 061/139: eglot-editing-mode becomes eglot--managed-mode, João Távora, 2018/05/14
- [elpa] externals/eglot e7ffc31 067/139: Make reported capabilities into its own function, João Távora, 2018/05/14
- [elpa] externals/eglot 79a2a1e 069/139: Be quite explicit about our lack of capabilities right now, João Távora, 2018/05/14
- [elpa] externals/eglot 95187cf 058/139: Connect to LSP server via TCP, João Távora, 2018/05/14
- [elpa] externals/eglot f76f04e 057/139: More correctly keep track of didOpen/didClose per buffer, João Távora, 2018/05/14