[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eglot 69c1746 3/4: Hopefully fix the Flymake bootstrap

From: João Távora
Subject: [elpa] externals/eglot 69c1746 3/4: Hopefully fix the Flymake bootstrap problem
Date: Sun, 27 May 2018 08:20:13 -0400 (EDT)

branch: externals/eglot
commit 69c17462ab61774928b036faf96855d889f641da
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>

    Hopefully fix the Flymake bootstrap problem
    Immediately after M-x eglot, eglot's use of flymake was having trouble
    detecting the first diagnostics sent from the server, resulting in an
    annoying "Wait" in the mode-line.
    * eglot.el (eglot--current-flymake-report-fn): Move up here.
    (eglot--managed-mode): Set eglot--current-flymake-report-fn to nil
    on teardown.
    (eglot--maybe-activate-editing-mode): Simplify.
    (eglot-handle-notification textDocument/publishDiagnostics): Set 
unreported-diagnostics to a cons.
    (eglot-handle-notification eglot-rls window/progress): Simplify.
    * eglot-tests.el (rls-basic-diagnostics): Simplify test.
 eglot-tests.el |  7 ++++---
 eglot.el       | 24 +++++++++---------------
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/eglot-tests.el b/eglot-tests.el
index 699f52b..1a60fce 100644
--- a/eglot-tests.el
+++ b/eglot-tests.el
@@ -266,21 +266,22 @@ Pass TIMEOUT to `eglot--with-timeout'."
                           (= type 3)))))))))))
 (ert-deftest rls-basic-diagnostics ()
-  "Hover and highlightChanges are tricky in RLS."
+  "Test basic diagnostics in RLS."
   (skip-unless (executable-find "rls"))
   (skip-unless (executable-find "cargo"))
-      '(("diag-project" . (("main.rs" . "bla"))))
+      '(("diag-project" . (("main.rs" . "fn main() {\nprintfoo!(\"Hello, 
     (eglot--with-timeout 3
           (eglot--find-file-noselect "diag-project/main.rs")
         (should (zerop (shell-command "cargo init")))
         (eglot--sniffing (:server-notifications s-notifs)
-          (insert "fn main() {\nprintfoo!(\"Hello, world!\");\n}")
           (apply #'eglot (eglot--interactive))
           (eglot--wait-for (s-notifs 1)
               (&key _id method &allow-other-keys)
             (string= method "textDocument/publishDiagnostics"))
+          (flymake-start)
+          (goto-char (point-min))
           (should (eq 'flymake-error (face-at-point))))))))
diff --git a/eglot.el b/eglot.el
index 5fab574..ce13195 100644
--- a/eglot.el
+++ b/eglot.el
@@ -833,6 +833,9 @@ If optional MARKERS, make markers."
 (defvar eglot-mode-map (make-sparse-keymap))
+(defvar-local eglot--current-flymake-report-fn nil
+  "Current flymake report function for this buffer")
 (define-minor-mode eglot--managed-mode
   "Mode for source buffers managed by some EGLOT project."
   nil nil eglot-mode-map
@@ -862,7 +865,8 @@ If optional MARKERS, make markers."
     (remove-hook 'completion-at-point-functions #'eglot-completion-at-point t)
     (remove-function (local 'eldoc-documentation-function)
-    (remove-function (local imenu-create-index-function) #'eglot-imenu))))
+    (remove-function (local imenu-create-index-function) #'eglot-imenu)
+    (setq eglot--current-flymake-report-fn nil))))
 (defun eglot--managed-mode-onoff (server arg)
   "Proxy for function `eglot--managed-mode' with ARG and SERVER."
@@ -876,9 +880,6 @@ If optional MARKERS, make markers."
 (add-hook 'eglot--managed-mode-hook 'flymake-mode)
 (add-hook 'eglot--managed-mode-hook 'eldoc-mode)
-(defvar-local eglot--current-flymake-report-fn nil
-  "Current flymake report function for this buffer")
 (defun eglot--maybe-activate-editing-mode (&optional server)
   "Maybe activate mode function `eglot--managed-mode'.
 If SERVER is supplied, do it only if BUFFER is managed by it.  In
@@ -888,9 +889,7 @@ that case, also signal textDocument/didOpen."
          (server (or (and (null server) cur) (and server (eq server cur) 
     (when server
       (eglot--managed-mode-onoff server 1)
-      (eglot--signal-textDocument/didOpen)
-      (flymake-start)
-      (funcall (or eglot--current-flymake-report-fn #'ignore) nil))))
+      (eglot--signal-textDocument/didOpen))))
 (add-hook 'find-file-hook 'eglot--maybe-activate-editing-mode)
@@ -1046,7 +1045,7 @@ function with the server still running."
                         (funcall eglot--current-flymake-report-fn diags)
                         (setq eglot--unreported-diagnostics nil))
-                        (setq eglot--unreported-diagnostics diags)))))
+                        (setq eglot--unreported-diagnostics (cons t diags))))))
     (eglot--debug server "Diagnostics received for unvisited %s" uri)))
 (cl-defun eglot--register-unregister (server jsonrpc-id things how)
@@ -1221,7 +1220,7 @@ Calls REPORT-FN maybe if server publishes diagnostics in 
   (setq eglot--current-flymake-report-fn report-fn)
   ;; Report anything unreported
   (when eglot--unreported-diagnostics
-    (funcall report-fn eglot--unreported-diagnostics)
+    (funcall report-fn (cdr eglot--unreported-diagnostics))
     (setq eglot--unreported-diagnostics nil)))
 (defun eglot-xref-backend ()
@@ -1598,12 +1597,7 @@ Proceed? "
   ((server eglot-rls) (_method (eql :window/progress))
    &key id done title message &allow-other-keys)
   "Handle notification window/progress"
-  (setf (eglot--spinner server) (list id title done message))
-  (when (and (equal "Indexing" title) done)
-    (dolist (buffer (eglot--managed-buffers server))
-      (with-current-buffer buffer
-        (funcall (or eglot--current-flymake-report-fn #'ignore)
-                 eglot--unreported-diagnostics)))))
+  (setf (eglot--spinner server) (list id title done message)))
 ;;; cquery-specific

reply via email to

[Prev in Thread] Current Thread [Next in Thread]