[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa b4dd4f8 022/139: Report server status in the mode-
From: |
Jo�o T�vora |
Subject: |
[elpa] externals/elpa b4dd4f8 022/139: Report server status in the mode-line |
Date: |
Mon, 14 May 2018 09:53:27 -0400 (EDT) |
branch: externals/elpa
commit b4dd4f850e4af8b202b47c3a6a2c0664ebbeaa30
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Report server status in the mode-line
* eglot.el (eglot--status): New var.
(eglot--log-event): Try to be more useful for other stuff.
(eglot--protocol-initialize): Set status to nil on
successful connect.
(eglot--window/showMessage): Set status to error if needed.
(eglot--mode-line-format): Display status if serious.
---
eglot.el | 57 +++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 47 insertions(+), 10 deletions(-)
diff --git a/eglot.el b/eglot.el
index e5d6937..44023b7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -92,6 +92,10 @@
"\"Spinner\" used by some servers.
A list (ID WHAT DONE-P).")
+(eglot--define-process-var eglot--status `(:unknown nil)
+ "Status as declared by the server.
+A list (WHAT SERIOUS-P).")
+
(defun eglot--command (&optional errorp)
(let ((probe (cdr (assoc major-mode eglot-executables))))
(unless (or (not errorp)
@@ -265,15 +269,22 @@ INTERACTIVE is t if called interactively."
(display-buffer buffer))
buffer))
-(defun eglot--log-event (proc type message id error)
+(defun eglot--log-event (proc type message &optional id error)
+ "Log an eglot-related event.
+PROC is the current process. TYPE is an identifier. MESSAGE is
+a JSON-like plist or anything else. ID is a continuation
+identifier. ERROR is non-nil if this is an error."
(with-current-buffer (eglot-events-buffer proc)
(let ((inhibit-read-only t))
(goto-char (point-max))
- (insert (format "%s%s%s:\n%s\n"
- type
- (if id (format " (id:%s)" id) "")
- (if error " ERROR" "")
- (pp-to-string message))))))
+ (let ((msg (format "%s%s%s:\n%s\n"
+ type
+ (if id (format " (id:%s)" id) "")
+ (if error " ERROR" "")
+ (pp-to-string message))))
+ (when error
+ (setq msg (propertize msg 'face 'error)))
+ (insert msg)))))
(defvar eglot--environment-vars
'(eglot--current-flymake-report-fn)
@@ -445,6 +456,7 @@ INTERACTIVE is t if caller was called interactively."
(lambda (&key capabilities)
(setf (eglot--capabilities process) capabilities)
(when interactive
+ (setf (eglot--status process) nil)
(eglot--message
"So yeah I got lots (%d) of capabilities"
(length capabilities)))))))
@@ -535,6 +547,16 @@ running. INTERACTIVE is t if called interactively."
(t
(eglot--message "OK so %s isn't visited" filename)))))
+(cl-defun eglot--window/showMessage
+ (process &key type message)
+ "Handle notification window/showMessage"
+ (when (<= 1 type)
+ (setf (eglot--status process) '("error" t))
+ (eglot--log-event process
+ (propertize "server-error" 'face 'error)
+ message))
+ (eglot--message "Server reports (type=%s): %s" type message))
+
;;; Helpers
;;;
@@ -603,8 +625,12 @@ running. INTERACTIVE is t if called interactively."
(pending (and proc
(hash-table-count
(eglot--pending-continuations proc))))
- (`(,_id ,what ,done-p) (and proc
- (eglot--spinner))))
+ (`(,_id ,doing ,done-p)
+ (and proc
+ (eglot--spinner proc)))
+ (`(,status ,serious-p)
+ (and proc
+ (eglot--status proc))))
(append
`((:propertize "eglot"
face eglot-mode-line
@@ -629,10 +655,21 @@ running. INTERACTIVE is t if called interactively."
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))
+ ,@(when serious-p
+ `("/"
+ (:propertize
+ ,status
+ help-echo ,(concat "mouse-1: go to events buffer")
+ mouse-face mode-line-highlight
+ face compilation-mode-line-fail
+ keymap ,(let ((map (make-sparse-keymap)))
+ (define-key map [mode-line mouse-1]
+ 'eglot-events-buffer)
+ map))))
+ ,@(when (and doing (not done-p))
`("/"
(:propertize
- ,what
+ ,doing
help-echo ,(concat "mouse-1: go to events buffer")
mouse-face mode-line-highlight
face compilation-mode-line-run
- [elpa] externals/elpa e60c7fc 013/139: Overhaul async mechanism safety, (continued)
- [elpa] externals/elpa e60c7fc 013/139: Overhaul async mechanism safety, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa a3545fb 050/139: Rename RPC methods for clarity, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa 4d4b85d 061/139: eglot-editing-mode becomes eglot--managed-mode, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa 4f246b5 017/139: * eglot.el (eglot-mode-map): Move up before minor mode., Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa a4f99e0 005/139: Introduce and use `eglot--current-process-or-lose', Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa 8e6488f 023/139: Don't switch to possibly dead buffer in sentinel, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa be52e1e 037/139: Rework connection restarting again, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa cc183a6 043/139: Fix assorted bugs, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa e8f859e 031/139: Rework commands for connecting and reconnecting, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa b511b7d 036/139: Redesign and simplify parser, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa b4dd4f8 022/139: Report server status in the mode-line,
Jo�o T�vora <=
- [elpa] externals/elpa 46bb1c0 049/139: Reorganize file, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa b69302c 060/139: Make M-x eglot's interactive spec a separate function, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa b657b32 068/139: Use rootUri instead of rootPath, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa eebd32b 059/139: When user declines to reconnect, first quit existing server, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa f1b6485 053/139: Trim some edges and add a bunch of boring RPC methods, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa df5d76d 065/139: Reply to client/registerCapability (don't handle it yet), Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa f76f04e 057/139: More correctly keep track of didOpen/didClose per buffer, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa a199c8e 070/139: Honour textDocumentSync, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa 79a2a1e 069/139: Be quite explicit about our lack of capabilities right now, Jo�o T�vora, 2018/05/14
- [elpa] externals/elpa ff5a03d 074/139: Very basic xref support, Jo�o T�vora, 2018/05/14