]> git.eshelyaron.com Git - emacs.git/commitdiff
Slightly more user friendly start
authorJoão Távora <joaotavora@gmail.com>
Wed, 2 May 2018 14:36:26 +0000 (15:36 +0100)
committerJoão Távora <joaotavora@gmail.com>
Wed, 2 May 2018 14:50:17 +0000 (15:50 +0100)
* eglot.el (eglot-new-process): signal DidOpen for every file in project.
(eglot-editing-mode): Offer to start process.

lisp/progmodes/eglot.el

index 6e5954ca80769b911821bdf64ab80504e16e93a3..d3428a73a74f2157fdb941a059c1c85db515a543 100644 (file)
@@ -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