[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 1dc2a9f 021/139: Implement spinners and RLS's win
From: |
João Távora |
Subject: |
[elpa] externals/eglot 1dc2a9f 021/139: Implement spinners and RLS's window/progress |
Date: |
Mon, 14 May 2018 09:54:44 -0400 (EDT) |
branch: externals/eglot
commit 1dc2a9fe3521586b15f90ed74d06f586fe478dfd
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Implement spinners and RLS's window/progress
* eglot.el (eglot--window/progress): New.
(eglot--mode-line-format): Rework.
(eglot--snpinner): New var.
(compile): require it.
---
eglot.el | 107 ++++++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 64 insertions(+), 43 deletions(-)
diff --git a/eglot.el b/eglot.el
index ab13b3a..e5d6937 100644
--- a/eglot.el
+++ b/eglot.el
@@ -30,6 +30,7 @@
(require 'url-parse)
(require 'url-util)
(require 'pcase)
+(require 'compile) ; for some faces
(defgroup eglot nil
"Interaction with Language Server Protocol servers"
@@ -87,6 +88,10 @@
(eglot--define-process-var eglot--moribund nil
"Non-nil if process is about to exit")
+(eglot--define-process-var eglot--spinner `(nil nil t)
+ "\"Spinner\" used by some servers.
+A list (ID WHAT DONE-P).")
+
(defun eglot--command (&optional errorp)
(let ((probe (cdr (assoc major-mode eglot-executables))))
(unless (or (not errorp)
@@ -591,17 +596,15 @@ running. INTERACTIVE is t if called interactively."
(defun eglot--mode-line-format ()
"Compose the mode-line format spec."
- (let* ((proc (eglot--current-process))
- (name (and proc
- (process-live-p proc)
- (eglot--short-name proc)))
- (pending (and proc
- (hash-table-count
- (eglot--pending-continuations proc))))
- (format-number (lambda (n) (cond ((and n (not (zerop n)))
- (format "%d" n))
- (n "-")
- (t "*")))))
+ (pcase-let* ((proc (eglot--current-process))
+ (name (and proc
+ (process-live-p proc)
+ (eglot--short-name proc)))
+ (pending (and proc
+ (hash-table-count
+ (eglot--pending-continuations proc))))
+ (`(,_id ,what ,done-p) (and proc
+ (eglot--spinner))))
(append
`((:propertize "eglot"
face eglot-mode-line
@@ -612,41 +615,51 @@ running. INTERACTIVE is t if called interactively."
mouse-face mode-line-highlight
help-echo "mouse-1: pop-up EGLOT menu"
))
- (if name
- `(" "
- (:propertize
- ,name
- face eglot-mode-line
- keymap ,(let ((map (make-sparse-keymap)))
- (define-key map [mode-line mouse-1] 'eglot-events-buffer)
- (define-key map [mode-line mouse-2] 'eglot-quit-server)
- (define-key map [mode-line mouse-3] 'eglot-new-process)
- map)
- mouse-face mode-line-highlight
- help-echo ,(concat "mouse-1: events buffer\n"
- "mouse-2: quit server\n"
- "mouse-3: new process"))
- "/"
- (:propertize
- ,(funcall format-number pending)
- help-echo ,(if name
- (format
- "%s pending events outgoing\n%s"
+ (when name
+ `(":"
+ (:propertize
+ ,name
+ face eglot-mode-line
+ keymap ,(let ((map (make-sparse-keymap)))
+ (define-key map [mode-line mouse-1] 'eglot-events-buffer)
+ (define-key map [mode-line mouse-2] 'eglot-quit-server)
+ (define-key map [mode-line mouse-3] 'eglot-new-process)
+ map)
+ mouse-face mode-line-highlight
+ help-echo ,(concat "mouse-1: go to events buffer\n"
+ "mouse-2: quit server\n"
+ "mouse-3: new process"))
+ ,@(when (and what (not done-p))
+ `("/"
+ (:propertize
+ ,what
+ help-echo ,(concat "mouse-1: go to events buffer")
+ mouse-face mode-line-highlight
+ face compilation-mode-line-run
+ keymap ,(let ((map (make-sparse-keymap)))
+ (define-key map [mode-line mouse-1]
+ 'eglot-events-buffer)
+ map))))
+ ,@(when (cl-plusp pending)
+ `("/"
+ (:propertize
+ (format "%d" pending)
+ help-echo ,(format
+ "%s unanswered requests\n%s"
pending
(concat "mouse-1: go to events buffer"
"mouse-3: forget pending continuations"))
- "No current connection")
- mouse-face mode-line-highlight
- face ,(cond ((and pending (cl-plusp pending))
- 'warning)
- (t
- 'eglot-mode-line))
- keymap ,(let ((map (make-sparse-keymap)))
- (define-key map [mode-line mouse-1]
- 'eglot-events-buffer)
- (define-key map [mode-line mouse-3]
- 'eglot-forget-pending-continuations)
- map)))))))
+ mouse-face mode-line-highlight
+ face ,(cond ((and pending (cl-plusp pending))
+ 'warning)
+ (t
+ 'eglot-mode-line))
+ keymap ,(let ((map (make-sparse-keymap)))
+ (define-key map [mode-line mouse-1]
+ 'eglot-events-buffer)
+ (define-key map [mode-line mouse-3]
+ 'eglot-forget-pending-continuations)
+ map)))))))))
(add-to-list 'mode-line-misc-info
`(eglot-mode
@@ -728,5 +741,13 @@ running. INTERACTIVE is t if called interactively."
(setq eglot--current-flymake-report-fn report-fn)
(eglot--maybe-signal-didChange))
+
+;;; Rust-specific
+;;;
+(cl-defun eglot--window/progress
+ (process &key id done title )
+ "Handle notification window/progress"
+ (setf (eglot--spinner process) (list id title done)))
+
(provide 'eglot)
;;; eglot.el ends here
- [elpa] externals/eglot 6f6f01d 018/139: Doc fixes, (continued)
- [elpa] externals/eglot 6f6f01d 018/139: Doc fixes, João Távora, 2018/05/14
- [elpa] externals/eglot 7ec0dcf 029/139: Events buffer uses eglot-mode, source buffers use eglot-editing-mode, João Távora, 2018/05/14
- [elpa] externals/eglot 22dc2f7 034/139: Ready to start fixing flymake integration, João Távora, 2018/05/14
- [elpa] externals/eglot e8f859e 031/139: Rework commands for connecting and reconnecting, João Távora, 2018/05/14
- [elpa] externals/eglot 92bf3a0 038/139: Signal textDocument/didClose, João Távora, 2018/05/14
- [elpa] externals/eglot b511b7d 036/139: Redesign and simplify parser, João Távora, 2018/05/14
- [elpa] externals/eglot 328c7ae 025/139: Auto update mode-line after setting some process properties, João Távora, 2018/05/14
- [elpa] externals/eglot 2b61a3b 048/139: Delete two useless forward declarations, João Távora, 2018/05/14
- [elpa] externals/eglot 88e3655 040/139: Appease checkdoc.el, João Távora, 2018/05/14
- [elpa] externals/eglot c948713 035/139: Auto-reconnect on unexpected connection loss, João Távora, 2018/05/14
- [elpa] externals/eglot 1dc2a9f 021/139: Implement spinners and RLS's window/progress,
João Távora <=
- [elpa] externals/eglot 931093e 032/139: Don't clutter UI with warnings, João Távora, 2018/05/14
- [elpa] externals/eglot 95983c9 028/139: Change status to error everytime an error is found, João Távora, 2018/05/14
- [elpa] externals/eglot be52e1e 037/139: Rework connection restarting again, João Távora, 2018/05/14
- [elpa] externals/eglot d2eca65 045/139: Fix another Flymake sync bug, João Távora, 2018/05/14
- [elpa] externals/eglot f7f77e1 044/139: Make M-x eglot the main entry point, João Távora, 2018/05/14
- [elpa] externals/eglot d90efdf 001/139: Initial commit, João Távora, 2018/05/14
- [elpa] externals/eglot 1514e0f 052/139: Fix a couple of Rust-related edge cases, João Távora, 2018/05/14
- [elpa] externals/eglot b4dd4f8 022/139: Report server status in the mode-line, João Távora, 2018/05/14
- [elpa] externals/eglot 6689a15 026/139: Add eglot-clear-status interactive command, João Távora, 2018/05/14
- [elpa] externals/eglot a3545fb 050/139: Rename RPC methods for clarity, João Távora, 2018/05/14