Add lsp modeline
This commit is contained in:
parent
4d0ac5f46c
commit
8e56aa8706
1 changed files with 45 additions and 13 deletions
|
@ -109,14 +109,22 @@ side of the modeline, and whose CDR is the right-hand side.")
|
||||||
(if (eq idx len) "\"};" "\",\n")))))
|
(if (eq idx len) "\"};" "\",\n")))))
|
||||||
'xpm t :ascent 'center)))))
|
'xpm t :ascent 'center)))))
|
||||||
|
|
||||||
(defun +modeline-format-icon (icon label &optional face help-echo voffset)
|
(defun +modeline-format-icon (icon-set icon label &optional face help-echo voffset)
|
||||||
(propertize (concat (all-the-icons-material
|
"Build from ICON-SET the ICON with LABEL.
|
||||||
icon
|
Using optionals attributes FACE, HELP-ECHO and VOFFSET."
|
||||||
:face face
|
(let ((icon-set-fn (pcase icon-set
|
||||||
:height 1.1
|
('octicon #'all-the-icons-octicon)
|
||||||
:v-adjust (or voffset -0.225))
|
('faicon #'all-the-icons-faicon)
|
||||||
(propertize label 'face face))
|
('material #'all-the-icons-material)
|
||||||
'help-echo help-echo))
|
('alltheicon #'all-the-icons-alltheicon)
|
||||||
|
('fileicon #'all-the-icons-fileicon))))
|
||||||
|
(propertize (concat (funcall icon-set-fn
|
||||||
|
icon
|
||||||
|
:face face
|
||||||
|
:height 1.1
|
||||||
|
:v-adjust (or voffset -0.225))
|
||||||
|
(propertize label 'face face))
|
||||||
|
'help-echo help-echo)))
|
||||||
|
|
||||||
(defun set-modeline! (name &optional default)
|
(defun set-modeline! (name &optional default)
|
||||||
"Set the modeline to NAME.
|
"Set the modeline to NAME.
|
||||||
|
@ -410,7 +418,7 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
||||||
(let ((error (or .error 0))
|
(let ((error (or .error 0))
|
||||||
(warning (or .warning 0))
|
(warning (or .warning 0))
|
||||||
(info (or .info 0)))
|
(info (or .info 0)))
|
||||||
(+modeline-format-icon "do_not_disturb_alt"
|
(+modeline-format-icon 'material "do_not_disturb_alt"
|
||||||
(number-to-string (+ error warning info))
|
(number-to-string (+ error warning info))
|
||||||
(cond ((> error 0) 'error)
|
(cond ((> error 0) 'error)
|
||||||
((> warning 0) 'warning)
|
((> warning 0) 'warning)
|
||||||
|
@ -420,10 +428,11 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
||||||
warning
|
warning
|
||||||
info))))
|
info))))
|
||||||
(+modeline-format-icon "check" "" 'success)))
|
(+modeline-format-icon "check" "" 'success)))
|
||||||
(`running (+modeline-format-icon "access_time" "*" 'mode-line-inactive "Running..."))
|
(`running (+modeline-format-icon'material "access_time" "*" 'mode-line-inactive "Running..."))
|
||||||
(`errored (+modeline-format-icon "sim_card_alert" "!" 'error "Errored!"))
|
(`errored (+modeline-format-icon'material "sim_card_alert" "!" 'error "Errored!"))
|
||||||
(`interrupted (+modeline-format-icon "pause" "!" 'mode-line-inactive "Interrupted"))
|
(`interrupted (+modeline-format-icon'material "pause" "!" 'mode-line-inactive "Interrupted"))
|
||||||
(`suspicious (+modeline-format-icon "priority_high" "!" 'error "Suspicious"))))))
|
(`suspicious (+modeline-format-icon'material "priority_high" "!" 'error "Suspicious"))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;; `+modeline-selection-info'
|
;;; `+modeline-selection-info'
|
||||||
|
@ -476,6 +485,26 @@ lines are selected, or the NxM dimensions of a block selection.")
|
||||||
(add-hook 'deactivate-mark-hook #'+modeline-remove-selection-segment-h))
|
(add-hook 'deactivate-mark-hook #'+modeline-remove-selection-segment-h))
|
||||||
|
|
||||||
|
|
||||||
|
;;; `+modeline-lsp'
|
||||||
|
(progn
|
||||||
|
(def-modeline-var! +modeline-lsp nil
|
||||||
|
"Display LSP connection status icon for the current buffer."
|
||||||
|
:local t)
|
||||||
|
|
||||||
|
(add-hook! '(lsp-before-initialize-hook
|
||||||
|
lsp-after-initialize-hook
|
||||||
|
lsp-after-uninitialized-functions
|
||||||
|
lsp-before-open-hook
|
||||||
|
lsp-after-open-hook)
|
||||||
|
(defun +modeline-lsp-update (&rest _)
|
||||||
|
"Update lsp state."
|
||||||
|
(let* ((workspaces (lsp-workspaces))
|
||||||
|
(face (if workspaces 'success 'warning))
|
||||||
|
(label (if workspaces "LSP Connected" "LSP Disconnected")))
|
||||||
|
(setq +modeline-lsp
|
||||||
|
(+modeline-format-icon 'faicon "rocket" "" face label -0.0575))))))
|
||||||
|
|
||||||
|
|
||||||
;;; `+modeline-encoding'
|
;;; `+modeline-encoding'
|
||||||
(def-modeline-var! +modeline-encoding
|
(def-modeline-var! +modeline-encoding
|
||||||
`(:eval
|
`(:eval
|
||||||
|
@ -508,6 +537,9 @@ lines are selected, or the NxM dimensions of a block selection.")
|
||||||
+modeline-position)
|
+modeline-position)
|
||||||
`(""
|
`(""
|
||||||
mode-line-misc-info
|
mode-line-misc-info
|
||||||
|
" "
|
||||||
|
+modeline-lsp
|
||||||
|
" "
|
||||||
+modeline-modes
|
+modeline-modes
|
||||||
(vc-mode (" "
|
(vc-mode (" "
|
||||||
,(all-the-icons-octicon "git-branch" :v-adjust 0.0)
|
,(all-the-icons-octicon "git-branch" :v-adjust 0.0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue