[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 1.2 3b3c1db 036/101: Close #73: Prompt for server in interactive
From: |
Christian Johansson |
Subject: |
[elpa] 1.2 3b3c1db 036/101: Close #73: Prompt for server in interactive eglot-shutdown |
Date: |
Thu, 29 Apr 2021 15:08:56 -0400 (EDT) |
tag: 1.2
commit 3b3c1db68b21198e5ae49f03e3f2202fc4d70abf
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Close #73: Prompt for server in interactive eglot-shutdown
* eglot.el (eglot--read-server): New helper.
(eglot-shutdown): Use it.
---
eglot.el | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/eglot.el b/eglot.el
index 43334ad..88c6b45 100644
--- a/eglot.el
+++ b/eglot.el
@@ -261,12 +261,18 @@ let the buffer grow forever."
(defun eglot-shutdown (server &optional _interactive timeout preserve-buffers)
"Politely ask SERVER to quit.
+Interactively, read SERVER from the minibuffer unless there is
+only one and it's managing the current buffer.
+
Forcefully quit it if it doesn't respond within TIMEOUT seconds.
+Don't leave this function with the server still running.
+
If PRESERVE-BUFFERS is non-nil (interactively, when called with a
prefix argument), do not kill events and output buffers of
-SERVER. Don't leave this function with the server still
-running."
- (interactive (list (eglot--current-server-or-lose) t nil current-prefix-arg))
+SERVER. ."
+ (interactive (list (eglot--read-server "Shutdown which server"
+ (eglot--current-server))
+ t nil current-prefix-arg))
(eglot--message "Asking %s politely to terminate" (jsonrpc-name server))
(unwind-protect
(progn
@@ -737,6 +743,32 @@ If optional MARKERS, make markers."
(end (eglot--lsp-position-to-point (plist-get range :end) markers)))
(cons beg end)))
+(defun eglot--read-server (prompt &optional dont-if-just-the-one)
+ "Read a running Eglot server from minibuffer using PROMPT.
+If DONT-IF-JUST-THE-ONE and there's only one server, don't prompt
+and just return it. PROMPT shouldn't end with a question mark."
+ (let ((servers (cl-loop for servers
+ being hash-values of eglot--servers-by-project
+ append servers))
+ (name (lambda (srv)
+ (format "%s/%s" (eglot--project-nickname srv)
+ (eglot--major-mode srv)))))
+ (cond ((null servers)
+ (eglot--error "No servers!"))
+ ((or (cdr servers) (not dont-if-just-the-one))
+ (let* ((default (when-let ((current (eglot--current-server)))
+ (funcall name current)))
+ (read (completing-read
+ (if default
+ (format "%s (default %s)? " prompt default)
+ (concat prompt "? "))
+ (mapcar name servers)
+ nil t
+ nil nil
+ default)))
+ (cl-find read servers :key name :test #'equal)))
+ (t (car servers)))))
+
;;; Minor modes
;;;
- [elpa] 1.2 cf3376a 034/101: Close #64: handle edits to same position in the correct order, (continued)
- [elpa] 1.2 cf3376a 034/101: Close #64: handle edits to same position in the correct order, Christian Johansson, 2021/04/29
- [elpa] 1.2 5e30066 032/101: Update README.md, Christian Johansson, 2021/04/29
- [elpa] 1.2 afa5439 027/101: Kill server's output and events buffers from eglot-shutdown (#66), Christian Johansson, 2021/04/29
- [elpa] 1.2 d6b49d8 028/101: * README.md (Build Status): Show status for master, Christian Johansson, 2021/04/29
- [elpa] 1.2 c2e05a3 030/101: Close #68: Implement asynchronous server connection, Christian Johansson, 2021/04/29
- [elpa] 1.2 3432d21 037/101: Per #74: Fix eglot-capabilities when querying for multiple features, Christian Johansson, 2021/04/29
- [elpa] 1.2 6eac51f 061/101: Sort references and definitions by line number, Christian Johansson, 2021/04/29
- [elpa] 1.2 88a4f8c 044/101: Actually add snippet example gif referenced in README.md, Christian Johansson, 2021/04/29
- [elpa] 1.2 29d641b 066/101: Handle case when project was not found in eclipse.jdt.ls contact, Christian Johansson, 2021/04/29
- [elpa] 1.2 2971683 075/101: Rework test macros for hopefully more stable testing, Christian Johansson, 2021/04/29
- [elpa] 1.2 3b3c1db 036/101: Close #73: Prompt for server in interactive eglot-shutdown,
Christian Johansson <=
- [elpa] 1.2 a1cc0ad 043/101: * README.md (Obligatory animated gif section): Add snippet gif., Christian Johansson, 2021/04/29
- [elpa] 1.2 3532bd0 064/101: Per #63: Add support for eclipse.jdt.ls server, Christian Johansson, 2021/04/29
- [elpa] 1.2 0ef245f 051/101: Fix serious breakage introduced by #93, Christian Johansson, 2021/04/29
- [elpa] 1.2 71012bc 067/101: Add tests for eclipse.jdt.ls connection, Christian Johansson, 2021/04/29
- [elpa] 1.2 ea2fcc7 087/101: * eglot-tests.el (eclipse-connect): Increase connect timeout to 20., Christian Johansson, 2021/04/29
- [elpa] 1.2 7f1a0e3 100/101: * eglot.el (eglot-completion-at-point): Less chatter., Christian Johansson, 2021/04/29
- [elpa] 1.2 477e15d 018/101: * eglot.el (eglot-initialization-options): Fix spurious typo., Christian Johansson, 2021/04/29
- [elpa] 1.2 802dea3 033/101: Close #41: Control the size of the events buffer, Christian Johansson, 2021/04/29
- [elpa] 1.2 8ed2524 038/101: Close #50: Support snippet completions, Christian Johansson, 2021/04/29
- [elpa] 1.2 7583849 058/101: eglot-ignored-server-capabilites: Prefer all choices over "Other", Christian Johansson, 2021/04/29