mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
Improve LSP segment.
This commit is contained in:
parent
6f54eb240e
commit
4a694ece9b
1 changed files with 71 additions and 73 deletions
|
@ -1588,42 +1588,39 @@ 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))
|
||||||
" "
|
(face (if workspaces 'success 'warning))
|
||||||
(let* ((workspaces (lsp-workspaces))
|
(icon (doom-modeline-lsp-icon "LSP" face)))
|
||||||
(face (if workspaces 'success 'warning))
|
(propertize icon
|
||||||
(icon (doom-modeline-lsp-icon "LSP" face)))
|
'face `(:inherit ,(get-text-property 0 'face icon))
|
||||||
(propertize icon
|
'help-echo (if workspaces
|
||||||
'face `(:inherit ,(get-text-property 0 'face icon))
|
(concat "LSP Connected "
|
||||||
'help-echo (if workspaces
|
(string-join (--map (format "[%s]\n" (lsp--workspace-print it))
|
||||||
(concat "LSP Connected "
|
workspaces))
|
||||||
(string-join (--map (format "[%s]\n" (lsp--workspace-print it))
|
"C-mouse-1: Switch to another workspace folder
|
||||||
workspaces))
|
|
||||||
"C-mouse-1: Switch to another workspace folder
|
|
||||||
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-1: Reload to start server")
|
mouse-1: Reload to start server")
|
||||||
'mouse-face '(:box 0)
|
'mouse-face '(:box 0)
|
||||||
'local-map (let ((map (make-sparse-keymap)))
|
'local-map (let ((map (make-sparse-keymap)))
|
||||||
(if workspaces
|
(if workspaces
|
||||||
(progn
|
(progn
|
||||||
(define-key map [mode-line C-mouse-1]
|
(define-key map [mode-line C-mouse-1]
|
||||||
#'lsp-workspace-folders-switch)
|
#'lsp-workspace-folders-switch)
|
||||||
(define-key map [mode-line mouse-1]
|
(define-key map [mode-line mouse-1]
|
||||||
#'lsp-describe-session)
|
#'lsp-describe-session)
|
||||||
(define-key map [mode-line mouse-2]
|
(define-key map [mode-line mouse-2]
|
||||||
#'lsp-shutdown-workspace)
|
#'lsp-shutdown-workspace)
|
||||||
(define-key map [mode-line mouse-3]
|
(define-key map [mode-line mouse-3]
|
||||||
#'lsp-restart-workspace))
|
#'lsp-restart-workspace))
|
||||||
(progn
|
(progn
|
||||||
(define-key map [mode-line mouse-1]
|
(define-key map [mode-line mouse-1]
|
||||||
(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,60 +1641,61 @@ 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
|
||||||
" "
|
'face `(:inherit ,(get-text-property 0 'face icon))
|
||||||
(propertize icon
|
'help-echo (cond
|
||||||
'face `(:inherit ,(get-text-property 0 'face icon))
|
(last-error
|
||||||
'help-echo (cond
|
(format "EGLOT\nAn error occured: %s
|
||||||
(last-error
|
|
||||||
(format "EGLOT\nAn error occured: %s
|
|
||||||
mouse-3: clear this status" (plist-get last-error :message)))
|
mouse-3: clear this status" (plist-get last-error :message)))
|
||||||
((and doing (not done-p))
|
((and doing (not done-p))
|
||||||
(format "EGLOT\n%s%s" doing
|
(format "EGLOT\n%s%s" doing
|
||||||
(if detail (format "%s" detail) "")))
|
(if detail (format "%s" detail) "")))
|
||||||
((and pending (cl-plusp pending))
|
((and pending (cl-plusp pending))
|
||||||
(format "EGLOT\n%d outstanding requests" pending))
|
(format "EGLOT\n%d outstanding requests" pending))
|
||||||
(nick (format "EGLOT Connected (%s/%s)
|
(nick (format "EGLOT Connected (%s/%s)
|
||||||
C-mouse-1: Disply server errors
|
C-mouse-1: Disply server errors
|
||||||
mouse-1: Display server events
|
mouse-1: Display server events
|
||||||
mouse-2: Quit server
|
mouse-2: Quit server
|
||||||
mouse-3: Reconnect to server" nick (eglot--major-mode server)))
|
mouse-3: Reconnect to server" nick (eglot--major-mode server)))
|
||||||
(t "EGLOT Disconnected"))
|
(t "EGLOT Disconnected"))
|
||||||
'mouse-face '(:box 0)
|
'mouse-face '(:box 0)
|
||||||
'local-map (let ((map (make-sparse-keymap)))
|
'local-map (let ((map (make-sparse-keymap)))
|
||||||
(cond
|
(cond
|
||||||
(last-error
|
(last-error
|
||||||
(define-key map [mode-line mouse-3]
|
(define-key map [mode-line mouse-3]
|
||||||
#'eglot-clear-status))
|
#'eglot-clear-status))
|
||||||
((and pending (cl-plusp pending))
|
((and pending (cl-plusp pending))
|
||||||
(define-key map [mode-line mouse-3]
|
(define-key map [mode-line mouse-3]
|
||||||
#'eglot-forget-pending-continuations))
|
#'eglot-forget-pending-continuations))
|
||||||
(nick
|
(nick
|
||||||
(define-key map [mode-line C-mouse-1]
|
(define-key map [mode-line C-mouse-1]
|
||||||
#'eglot-stderr-buffer)
|
#'eglot-stderr-buffer)
|
||||||
(define-key map [mode-line mouse-1]
|
(define-key map [mode-line mouse-1]
|
||||||
#'eglot-events-buffer)
|
#'eglot-events-buffer)
|
||||||
(define-key map [mode-line mouse-2]
|
(define-key map [mode-line mouse-2]
|
||||||
#'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))))
|
||||||
(propertize icon 'face `(:inherit
|
(concat
|
||||||
,(get-text-property 1 'face icon)
|
(propertize " " 'face (if active 'mode-line 'mode-line-inactive))
|
||||||
:inherit
|
(propertize icon 'face `(:inherit
|
||||||
,(if (doom-modeline--active)
|
,(get-text-property 0 'face icon)
|
||||||
'mode-line
|
:inherit
|
||||||
'mode-line-inactive))))))
|
,(if (doom-modeline--active)
|
||||||
|
'mode-line
|
||||||
|
'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."
|
||||||
|
|
Loading…
Reference in a new issue