Improve LSP segment.

This commit is contained in:
Vincent Zhang 2019-05-14 03:41:59 +08:00
parent 6f54eb240e
commit 4a694ece9b

View file

@ -1588,8 +1588,6 @@ mouse-3: Describe current input method")
(defun doom-modeline-update-lsp (&rest _) (defun doom-modeline-update-lsp (&rest _)
"Update `lsp-mode' status." "Update `lsp-mode' status."
(setq doom-modeline--lsp (setq doom-modeline--lsp
(concat
" "
(let* ((workspaces (lsp-workspaces)) (let* ((workspaces (lsp-workspaces))
(face (if workspaces 'success 'warning)) (face (if workspaces 'success 'warning))
(icon (doom-modeline-lsp-icon "LSP" face))) (icon (doom-modeline-lsp-icon "LSP" face)))
@ -1622,8 +1620,7 @@ mouse-1: Reload to start server")
(lambda () (lambda ()
(interactive) (interactive)
(revert-buffer t t))))) (revert-buffer t t)))))
map))) map)))))
" ")))
(add-hook 'lsp-mode-hook #'doom-modeline-update-lsp) (add-hook 'lsp-mode-hook #'doom-modeline-update-lsp)
(add-hook 'lsp-after-uninitialized-hook #'doom-modeline-update-lsp) (add-hook 'lsp-after-uninitialized-hook #'doom-modeline-update-lsp)
@ -1644,8 +1641,6 @@ mouse-1: Reload to start server")
(nick 'success) (nick 'success)
(t 'mode-line))) (t 'mode-line)))
(icon (doom-modeline-lsp-icon "EGLOT" face))) (icon (doom-modeline-lsp-icon "EGLOT" face)))
(concat
" "
(propertize icon (propertize icon
'face `(:inherit ,(get-text-property 0 'face icon)) 'face `(:inherit ,(get-text-property 0 'face icon))
'help-echo (cond 'help-echo (cond
@ -1681,23 +1676,26 @@ mouse-3: Reconnect to server" nick (eglot--major-mode server)))
#'eglot-shutdown) #'eglot-shutdown)
(define-key map [mode-line mouse-3] (define-key map [mode-line mouse-3]
#'eglot-reconnect))) #'eglot-reconnect)))
map)) map)))))
" "))))
(add-hook 'eglot--managed-mode-hook #'doom-modeline-update-eglot) (add-hook 'eglot--managed-mode-hook #'doom-modeline-update-eglot)
(doom-modeline-def-segment lsp (doom-modeline-def-segment lsp
"The LSP server state." "The LSP server state."
(when doom-modeline-lsp (when doom-modeline-lsp
(when-let ((icon (cond ((bound-and-true-p lsp-mode) (when-let ((active (doom-modeline--active))
(icon (cond ((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--eglot))))
(concat
(propertize " " 'face (if active 'mode-line 'mode-line-inactive))
(propertize icon 'face `(:inherit (propertize icon 'face `(:inherit
,(get-text-property 1 'face icon) ,(get-text-property 0 'face icon)
:inherit :inherit
,(if (doom-modeline--active) ,(if (doom-modeline--active)
'mode-line 'mode-line
'mode-line-inactive)))))) 'mode-line-inactive)))
(propertize " " 'face (if active 'mode-line 'mode-line-inactive))))))
(defun doom-modeline-override-eglot-modeline () (defun doom-modeline-override-eglot-modeline ()
"Override `eglot' mode-line." "Override `eglot' mode-line."