[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 0e95167 042/139: Watch for files opened under umb
From: |
João Távora |
Subject: |
[elpa] externals/eglot 0e95167 042/139: Watch for files opened under umbrella of existing process |
Date: |
Mon, 14 May 2018 09:54:50 -0400 (EDT) |
branch: externals/eglot
commit 0e951677e486a48a1ec583382d77e04b8a457d37
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Watch for files opened under umbrella of existing process
* eglot.el (eglot--connect): Call success-fn with a proc.
(eglot-reconnect): Adapt to new eglot--connect.
(eglot-new-process): Call eglot--maybe-activate-editing-mode
(eglot--maybe-activate-editing-mode): New function.
(find-file-hook): Add it here.
---
eglot.el | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/eglot.el b/eglot.el
index 10af6c5..f4ac858 100644
--- a/eglot.el
+++ b/eglot.el
@@ -190,7 +190,7 @@ SUCCESS-FN with no args if all goes well."
(lambda (&key capabilities)
(setf (eglot--capabilities proc) capabilities)
(setf (eglot--status proc) nil)
- (when success-fn (funcall success-fn)))))))))
+ (when success-fn (funcall success-fn proc)))))))))
(defun eglot-reconnect (process &optional interactive)
"Reconnect to PROCESS.
@@ -203,8 +203,8 @@ INTERACTIVE is t if called interactively."
(eglot--major-mode process)
(eglot--short-name process)
(eglot--bootstrap-fn process)
- (lambda ()
- (eglot--message "Reconnected"))))
+ (lambda (_proc)
+ (eglot--message "Reconnected!"))))
(defvar eglot--command-history nil
"History of COMMAND arguments to `eglot-new-process'.")
@@ -273,21 +273,15 @@ INTERACTIVE is t if called interactively."
(eglot-make-local-process
name
command))
- (lambda ()
- (eglot--message "Connected. Managing `%s' buffers in project %s."
- managed-major-mode short-name)
+ (lambda (proc)
+ (eglot--message "Connected! Process `%s' now managing `%s'\
+buffers in project %s."
+ proc
+ managed-major-mode
+ short-name)
(dolist (buffer (buffer-list))
(with-current-buffer buffer
- (when(and buffer-file-name
- (cl-some
- (lambda (root)
- (string-prefix-p
- (expand-file-name root)
- (expand-file-name buffer-file-name)))
- (project-roots project)))
- (unless eglot-editing-mode
- (eglot-editing-mode 1))
- (eglot--signalDidOpen)))))))))))
+ (eglot--maybe-activate-editing-mode proc))))))))))
(defun eglot--process-sentinel (process change)
"Called with PROCESS undergoes CHANGE."
@@ -706,7 +700,7 @@ running. INTERACTIVE is t if called interactively."
-;;; Mode line
+;;; Minor modes and mode-line
;;;
(defface eglot-mode-line
'((t (:inherit font-lock-constant-face :weight bold)))
@@ -717,6 +711,20 @@ running. INTERACTIVE is t if called interactively."
(defvar eglot-editing-mode-map (make-sparse-keymap))
+(defun eglot--maybe-activate-editing-mode (&optional proc)
+ "Maybe activate mode function `eglot-editing-mode'.
+If PROC is supplied, do it only if BUFFER is managed by it. In
+that case, also signal textDocument/didOpen."
+ (when buffer-file-name
+ (let ((cur (eglot--current-process)))
+ (when (or (and (null proc) cur)
+ (and proc (eq proc cur)))
+ (unless eglot-editing-mode
+ (eglot-editing-mode 1))
+ (eglot--signalDidOpen)))))
+
+(add-hook 'find-file-hook 'eglot--maybe-activate-editing-mode)
+
(define-minor-mode eglot-editing-mode
"Minor mode for source buffers where EGLOT helps you edit."
nil
- [elpa] externals/eglot f8bfb7e 064/139: Handle requests from server correctly, (continued)
- [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, 2018/05/14
- [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 <=
- [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
- [elpa] externals/eglot 46bb1c0 049/139: Reorganize file, João Távora, 2018/05/14
- [elpa] externals/eglot ff5a03d 074/139: Very basic xref support, João Távora, 2018/05/14
- [elpa] externals/eglot e9b5e54 077/139: ETOOMANYLAMBDAS, João Távora, 2018/05/14
- [elpa] externals/eglot dda11dd 095/139: Try to fix some textDocument/completion bugs, João Távora, 2018/05/14
- [elpa] externals/eglot ea918ab 066/139: Include source info in diagnostics, João Távora, 2018/05/14