[Enhancement] Improve lsp indicator.

This commit is contained in:
Vincent Zhang 2019-03-22 22:40:08 +08:00
parent aebaa760c6
commit 5774186d18

View file

@ -138,6 +138,7 @@
(declare-function image-get-display-property 'image-mode) (declare-function image-get-display-property 'image-mode)
(declare-function jsonrpc--request-continuations 'jsonrpc) (declare-function jsonrpc--request-continuations 'jsonrpc)
(declare-function jsonrpc-last-error 'jsonrpc) (declare-function jsonrpc-last-error 'jsonrpc)
(declare-function lsp--cleanup-hanging-watches 'lsp-mode)
(declare-function lsp--workspace-print 'lsp-mode) (declare-function lsp--workspace-print 'lsp-mode)
(declare-function lsp-describe-session 'lsp-mode) (declare-function lsp-describe-session 'lsp-mode)
(declare-function lsp-restart-workspace 'lsp-mode) (declare-function lsp-restart-workspace 'lsp-mode)
@ -1536,7 +1537,7 @@ mouse-3: Describe current input method")
;; ;;
(defvar doom-modeline--lsp nil) (defvar doom-modeline--lsp nil)
(defun doom-modeline-update-lsp () (defun doom-modeline-update-lsp (&rest _)
"Update `lsp-mode' status." "Update `lsp-mode' status."
(setq doom-modeline--lsp (setq doom-modeline--lsp
(concat (concat
@ -1558,21 +1559,29 @@ mouse-3: Describe current input method")
mouse-1: Describe current session mouse-1: Describe current session
mouse-2: Quit server mouse-2: Quit server
mouse-3: Reconnect to server") mouse-3: Reconnect to server")
"LSP Disconnected") "LSP Disconnected
'mouse-face (if workspaces '(:box 0)) mouse-1: Reload to start server")
'mouse-face '(:box 0)
'local-map (let ((map (make-sparse-keymap))) 'local-map (let ((map (make-sparse-keymap)))
(when workspaces (if workspaces
(define-key map [mode-line C-mouse-1] (progn
#'lsp-workspace-folders-switch) (define-key map [mode-line C-mouse-1]
(define-key map [mode-line mouse-1] #'lsp-workspace-folders-switch)
#'lsp-describe-session) (define-key map [mode-line mouse-1]
(define-key map [mode-line mouse-2] #'lsp-describe-session)
#'lsp-shutdown-workspace) (define-key map [mode-line mouse-2]
(define-key map [mode-line mouse-3] #'lsp-shutdown-workspace)
#'lsp-restart-workspace)) (define-key map [mode-line mouse-3]
#'lsp-restart-workspace))
(progn
(define-key map [mode-line mouse-1]
(lambda ()
(interactive)
(revert-buffer t t)))))
map))) map)))
" "))) " ")))
(add-hook 'lsp-mode-hook #'doom-modeline-update-lsp) (add-hook 'lsp-mode-hook #'doom-modeline-update-lsp)
(advice-add #'lsp--cleanup-hanging-watches :after #'doom-modeline-update-lsp)
(defvar doom-modeline--eglot nil) (defvar doom-modeline--eglot nil)
(defun doom-modeline-update-eglot () (defun doom-modeline-update-eglot ()
@ -1647,7 +1656,7 @@ mouse-3: Reconnect to server" nick (eglot--major-mode server)))
((bound-and-true-p lsp-mode) ((bound-and-true-p lsp-mode)
doom-modeline--lsp) doom-modeline--lsp)
((bound-and-true-p eglot--managed-mode) ((bound-and-true-p eglot--managed-mode)
doom-modeline--eglot)))) (doom-modeline-update-eglot)))))
(defun doom-modeline-override-eglot-modeline () (defun doom-modeline-override-eglot-modeline ()
"Override `eglot' mode-line." "Override `eglot' mode-line."