branch: externals/eglot
commit 75495dcb2ce2d1e4e0ee3ebfab990b8f1731ac01
Author: João Távora <joaotav...@gmail.com>
Commit: João Távora <joaotav...@gmail.com>

    Slightly more user friendly start
    
    * eglot.el (eglot-new-process): signal DidOpen for every file in project.
    (eglot-editing-mode): Offer to start process.
---
 eglot.el | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/eglot.el b/eglot.el
index 6e5954c..d3428a7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -193,7 +193,17 @@ INTERACTIVE is t if called interactively."
                                    major-mode))
                    probe)))
               (lambda ()
-                (eglot--message "Connected"))))))))
+                (eglot--message "Connected")
+                (dolist (buffer (buffer-list))
+                  (with-current-buffer buffer
+                    (if (and buffer-file-name
+                             (cl-some
+                              (lambda (root)
+                                (string-prefix-p
+                                 (expand-file-name root)
+                                 (expand-file-name buffer-file-name)))
+                              (project-roots project)))
+                        (eglot--signalDidOpen)))))))))))
 
 (defun eglot--process-sentinel (process change)
   "Called with PROCESS undergoes CHANGE."
@@ -647,16 +657,19 @@ running.  INTERACTIVE is t if called interactively."
   nil
   nil
   eglot-mode-map
-  (cond (eglot-editing-mode
-         (eglot-mode 1)
-         (add-hook 'after-change-functions 'eglot--after-change nil t)
-         (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)
-         (if (eglot--current-process)
-             (eglot--signalDidOpen)
-           (eglot--warn "No process")))
-        (t
-         (remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t)
-         (remove-hook 'after-change-functions 'eglot--after-change t))))
+  (cond
+   (eglot-editing-mode
+    (eglot-mode 1)
+    (add-hook 'after-change-functions 'eglot--after-change nil t)
+    (add-hook 'flymake-diagnostic-functions 'eglot-flymake-backend nil t)
+    (if (eglot--current-process)
+        (eglot--signalDidOpen)
+      (if (y-or-n-p "No process, try to start one with `eglot-new-process'? ")
+          (eglot-new-process t)
+        (eglot--warn "No process"))))
+   (t
+    (remove-hook 'flymake-diagnostic-functions 'eglot-flymake-backend t)
+    (remove-hook 'after-change-functions 'eglot--after-change t))))
 
 (define-minor-mode eglot-mode
   "Minor mode for all buffers managed by EGLOT in some way."  nil

Reply via email to