Merge pull request #3307 from ericdallo/add-lsp-modeline

Add lsp and repl to +light modeline
This commit is contained in:
Henrik Lissner 2021-05-15 17:54:53 -04:00 committed by GitHub
commit 7383ed4dc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 14 deletions

View file

@ -94,6 +94,25 @@
(evil-make-overriding-map cider--debug-mode-map 'normal)
(evil-normalize-keymaps))))
(when (featurep! :ui modeline +light)
(defvar-local cider-modeline-icon nil)
(add-hook! '(cider-connected-hook
cider-disconnected-hook
cider-mode-hook)
(defun +clojure--cider-update-modeline ()
"Update modeline with cider connection state."
(let* ((connected (cider-connected-p))
(face (if connected 'success 'warning))
(label (if connected "Cider connected" "Cider disconnected")))
(setq cider-modeline-icon (concat
" "
(+modeline-format-icon 'faicon "terminal" "" face label -0.0575)
" "))
(add-to-list 'global-mode-string
'(t (:eval cider-modeline-icon))
'append)))))
;; The CIDER welcome message obscures error messages that the above code is
;; supposed to be make visible.
(setq cider-repl-display-help-banner nil)

View file

@ -130,7 +130,28 @@ server getting expensively restarted when reverting buffers."
(or doom-debug-p
(not (eq +lsp-prompt-to-install-server 'quiet)))))
(doom-shut-up-a #'lsp--info "No language server available for %S"
major-mode))))))
major-mode)))))
(when (featurep! :ui modeline +light)
(defvar-local lsp-modeline-icon nil)
(add-hook! '(lsp-before-initialize-hook
lsp-after-initialize-hook
lsp-after-uninitialized-functions
lsp-before-open-hook
lsp-after-open-hook)
(defun +lsp-update-modeline (&rest _)
"Update modeline with lsp state."
(let* ((workspaces (lsp-workspaces))
(face (if workspaces 'success 'warning))
(label (if workspaces "LSP Connected" "LSP Disconnected")))
(setq lsp-modeline-icon (concat
" "
(+modeline-format-icon 'faicon "rocket" "" face label -0.0575)
" "))
(add-to-list 'global-mode-string
'(t (:eval lsp-modeline-icon))
'append))))))
(use-package! lsp-ui

View file

@ -109,14 +109,22 @@ side of the modeline, and whose CDR is the right-hand side.")
(if (eq idx len) "\"};" "\",\n")))))
'xpm t :ascent 'center)))))
(defun +modeline-format-icon (icon label &optional face help-echo voffset)
(propertize (concat (all-the-icons-material
icon
:face face
:height 1.1
:v-adjust (or voffset -0.225))
(propertize label 'face face))
'help-echo help-echo))
(defun +modeline-format-icon (icon-set icon label &optional face help-echo voffset)
"Build from ICON-SET the ICON with LABEL.
Using optionals attributes FACE, HELP-ECHO and VOFFSET."
(let ((icon-set-fn (pcase icon-set
('octicon #'all-the-icons-octicon)
('faicon #'all-the-icons-faicon)
('material #'all-the-icons-material)
('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)
"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))
(warning (or .warning 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))
(cond ((> error 0) 'error)
((> warning 0) 'warning)
@ -420,10 +428,11 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
warning
info))))
(+modeline-format-icon "check" "" 'success)))
(`running (+modeline-format-icon "access_time" "*" 'mode-line-inactive "Running..."))
(`errored (+modeline-format-icon "sim_card_alert" "!" 'error "Errored!"))
(`interrupted (+modeline-format-icon "pause" "!" 'mode-line-inactive "Interrupted"))
(`suspicious (+modeline-format-icon "priority_high" "!" 'error "Suspicious"))))))
(`running (+modeline-format-icon'material "access_time" "*" 'mode-line-inactive "Running..."))
(`errored (+modeline-format-icon'material "sim_card_alert" "!" 'error "Errored!"))
(`interrupted (+modeline-format-icon'material "pause" "!" 'mode-line-inactive "Interrupted"))
(`suspicious (+modeline-format-icon'material "priority_high" "!" 'error "Suspicious"))))))
;;; `+modeline-selection-info'