Refactor :ui modeline +light
This commit is contained in:
parent
e00bfc7612
commit
0252f4f36f
1 changed files with 230 additions and 226 deletions
|
@ -50,17 +50,17 @@ side of the modeline, and whose CDR is the right-hand side.")
|
||||||
;;
|
;;
|
||||||
;;; Faces
|
;;; Faces
|
||||||
|
|
||||||
(defface +modeline-bar-active '((t (:inherit highlight)))
|
(defface doom-modeline-bar '((t (:inherit highlight)))
|
||||||
"Face used for left-most bar on the mode-line of an active window.")
|
"Face used for left-most bar on the mode-line of an active window.")
|
||||||
|
|
||||||
(defface +modeline-bar-inactive '((t (:inherit mode-line-inactive)))
|
(defface doom-modeline-bar-inactive '((t (:inherit mode-line-inactive)))
|
||||||
"Face used for left-most bar on the mode-line of an inactive window.")
|
"Face used for left-most bar on the mode-line of an inactive window.")
|
||||||
|
|
||||||
(defface +modeline-highlight
|
(defface doom-modeline-highlight
|
||||||
'((t (:inherit mode-line-highlight)))
|
'((t (:inherit mode-line-highlight)))
|
||||||
"Face used for highlighted modeline panels (like search counts).")
|
"Face used for highlighted modeline panels (like search counts).")
|
||||||
|
|
||||||
(defface +modeline-alternate-highlight
|
(defface doom-modeline-alternate-highlight
|
||||||
'((t (:inherit mode-line-highlight)))
|
'((t (:inherit mode-line-highlight)))
|
||||||
"Alternative face used for highlighted modeline panels (like search counts).")
|
"Alternative face used for highlighted modeline panels (like search counts).")
|
||||||
|
|
||||||
|
@ -175,26 +175,33 @@ LHS and RHS will accept."
|
||||||
|
|
||||||
|
|
||||||
;;; `+modeline-bar'
|
;;; `+modeline-bar'
|
||||||
(progn
|
(def-modeline-var! +modeline-bar "")
|
||||||
(def-modeline-var! +modeline-bar "")
|
|
||||||
(def-modeline-var! +modeline-inactive-bar "")
|
|
||||||
|
|
||||||
(add-hook! '(doom-init-ui-hook doom-load-theme-hook) :append
|
(defvar +modeline-active-bar "")
|
||||||
|
(defvar +modeline-inactive-bar "")
|
||||||
|
|
||||||
|
(add-hook! '(doom-init-ui-hook doom-load-theme-hook) :append
|
||||||
(defun +modeline-refresh-bars-h ()
|
(defun +modeline-refresh-bars-h ()
|
||||||
(let ((width (or +modeline-bar-width 1))
|
(let ((width (or +modeline-bar-width 1))
|
||||||
(height (max +modeline-height 0)))
|
(height (max +modeline-height 0))
|
||||||
(setq +modeline-bar
|
(active-bg (face-background 'doom-modeline-bar nil t))
|
||||||
(+modeline--make-xpm
|
(inactive-bg (face-background 'doom-modeline-bar-inactive nil t)))
|
||||||
(and +modeline-bar-width
|
(when (or (null +modeline-bar-width)
|
||||||
(face-background '+modeline-bar-active nil t))
|
(= +modeline-bar-width 0))
|
||||||
|
(setq active-bg nil
|
||||||
|
inactive-bg nil))
|
||||||
|
(setq +modeline-active-bar
|
||||||
|
(+modeline--make-xpm (and +modeline-bar-width active-bg)
|
||||||
width height)
|
width height)
|
||||||
+modeline-inactive-bar
|
+modeline-inactive-bar
|
||||||
(+modeline--make-xpm
|
(+modeline--make-xpm (and +modeline-bar-width inactive-bg)
|
||||||
(and +modeline-bar-width
|
width height)
|
||||||
(face-background '+modeline-bar-inactive nil t))
|
+modeline-bar
|
||||||
width height)))))
|
'(:eval (if (+modeline-active)
|
||||||
|
+modeline-active-bar
|
||||||
|
+modeline-inactive-bar))))))
|
||||||
|
|
||||||
(add-hook! 'doom-change-font-size-hook
|
(add-hook! 'doom-change-font-size-hook
|
||||||
(defun +modeline-adjust-height-h ()
|
(defun +modeline-adjust-height-h ()
|
||||||
(defvar +modeline--old-height +modeline-height)
|
(defvar +modeline--old-height +modeline-height)
|
||||||
(let ((default-height +modeline--old-height)
|
(let ((default-height +modeline--old-height)
|
||||||
|
@ -205,12 +212,11 @@ LHS and RHS will accept."
|
||||||
doom-font-increment))
|
doom-font-increment))
|
||||||
default-height))
|
default-height))
|
||||||
(when doom-init-time
|
(when doom-init-time
|
||||||
(+modeline-refresh-bars-h))))))
|
(+modeline-refresh-bars-h)))))
|
||||||
|
|
||||||
|
|
||||||
;;; `+modeline-matches'
|
;;; `+modeline-matches'
|
||||||
(progn
|
(use-package! anzu
|
||||||
(use-package! anzu
|
|
||||||
:after-call isearch-mode
|
:after-call isearch-mode
|
||||||
:config
|
:config
|
||||||
;; We manage our own modeline segments
|
;; We manage our own modeline segments
|
||||||
|
@ -226,14 +232,13 @@ LHS and RHS will accept."
|
||||||
anzu--cached-count
|
anzu--cached-count
|
||||||
anzu--cached-positions anzu--last-command
|
anzu--cached-positions anzu--last-command
|
||||||
anzu--last-isearch-string anzu--overflow-p))
|
anzu--last-isearch-string anzu--overflow-p))
|
||||||
|
(global-anzu-mode +1))
|
||||||
|
|
||||||
(anzu-mode +1))
|
(use-package! evil-anzu
|
||||||
|
|
||||||
(use-package! evil-anzu
|
|
||||||
:when (featurep! :editor evil)
|
:when (featurep! :editor evil)
|
||||||
:after-call evil-ex-start-search evil-ex-start-word-search evil-ex-search-activate-highlight)
|
:after-call evil-ex-start-search evil-ex-start-word-search evil-ex-search-activate-highlight)
|
||||||
|
|
||||||
(defun +modeline--anzu ()
|
(defun +modeline--anzu ()
|
||||||
"Show the match index and total number thereof.
|
"Show the match index and total number thereof.
|
||||||
Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
||||||
`evil-search'."
|
`evil-search'."
|
||||||
|
@ -250,9 +255,9 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
||||||
(format " %s+ " total))
|
(format " %s+ " total))
|
||||||
(t
|
(t
|
||||||
(format " %s/%d " here total))))
|
(format " %s/%d " here total))))
|
||||||
'face (if (+modeline-active) '+modeline-highlight))))
|
'face (if (+modeline-active) 'doom-modeline-highlight))))
|
||||||
|
|
||||||
(defun +modeline--evil-substitute ()
|
(defun +modeline--evil-substitute ()
|
||||||
"Show number of matches for evil-ex substitutions and highlights in real time."
|
"Show number of matches for evil-ex substitutions and highlights in real time."
|
||||||
(when (and (bound-and-true-p evil-local-mode)
|
(when (and (bound-and-true-p evil-local-mode)
|
||||||
(or (assq 'evil-ex-substitute evil-ex-active-highlights-alist)
|
(or (assq 'evil-ex-substitute evil-ex-active-highlights-alist)
|
||||||
|
@ -266,27 +271,27 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
||||||
(if pattern
|
(if pattern
|
||||||
(format " %s matches " (how-many pattern (car range) (cdr range)))
|
(format " %s matches " (how-many pattern (car range) (cdr range)))
|
||||||
" - "))
|
" - "))
|
||||||
'face (if (+modeline-active) '+modeline-highlight))))
|
'face (if (+modeline-active) 'doom-modeline-highlight))))
|
||||||
|
|
||||||
(defun +modeline--multiple-cursors ()
|
(defun +modeline--multiple-cursors ()
|
||||||
"Show the number of multiple cursors."
|
"Show the number of multiple cursors."
|
||||||
(when (bound-and-true-p evil-mc-cursor-list)
|
(when (bound-and-true-p evil-mc-cursor-list)
|
||||||
(let ((count (length evil-mc-cursor-list)))
|
(let ((count (length evil-mc-cursor-list)))
|
||||||
(when (> count 0)
|
(when (> count 0)
|
||||||
(let ((face (cond ((not (+modeline-active)) 'mode-line-inactive)
|
(let ((face (cond ((not (+modeline-active)) 'mode-line-inactive)
|
||||||
(evil-mc-frozen '+modeline-highlight)
|
(evil-mc-frozen 'doom-modeline-highlight)
|
||||||
('+modeline-alternate-highlight))))
|
('doom-modeline-alternate-highlight))))
|
||||||
(concat (propertize " " 'face face)
|
(concat (propertize " " 'face face)
|
||||||
(all-the-icons-faicon "i-cursor" :face face :v-adjust -0.0575)
|
(all-the-icons-faicon "i-cursor" :face face :v-adjust -0.0575)
|
||||||
(propertize " " 'face `(:inherit (variable-pitch ,face)))
|
(propertize " " 'face `(:inherit (variable-pitch ,face)))
|
||||||
(propertize (format "%d " count)
|
(propertize (format "%d " count)
|
||||||
'face face)))))))
|
'face face)))))))
|
||||||
|
|
||||||
(defun +modeline--overlay< (a b)
|
(defun +modeline--overlay< (a b)
|
||||||
"Sort overlay A and B."
|
"Sort overlay A and B."
|
||||||
(< (overlay-start a) (overlay-start b)))
|
(< (overlay-start a) (overlay-start b)))
|
||||||
|
|
||||||
(defun +modeline--iedit ()
|
(defun +modeline--iedit ()
|
||||||
"Show the number of iedit regions matches + what match you're on."
|
"Show the number of iedit regions matches + what match you're on."
|
||||||
(when (and (bound-and-true-p iedit-mode)
|
(when (and (bound-and-true-p iedit-mode)
|
||||||
(bound-and-true-p iedit-occurrences-overlays))
|
(bound-and-true-p iedit-occurrences-overlays))
|
||||||
|
@ -305,26 +310,26 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
||||||
-1)
|
-1)
|
||||||
"-")
|
"-")
|
||||||
length))
|
length))
|
||||||
'face (if (+modeline-active) '+modeline-highlight))))
|
'face (if (+modeline-active) 'doom-modeline-highlight))))
|
||||||
|
|
||||||
(defun +modeline--macro-recording ()
|
(defun +modeline--macro-recording ()
|
||||||
"Display current Emacs or evil macro being recorded."
|
"Display current Emacs or evil macro being recorded."
|
||||||
(when (and (+modeline-active)
|
(when (and (+modeline-active)
|
||||||
(or defining-kbd-macro
|
(or defining-kbd-macro
|
||||||
executing-kbd-macro))
|
executing-kbd-macro))
|
||||||
(let ((sep (propertize " " 'face '+modeline-highlight)))
|
(let ((sep (propertize " " 'face 'doom-modeline-highlight)))
|
||||||
(concat sep
|
(concat sep
|
||||||
(propertize (if (bound-and-true-p evil-this-macro)
|
(propertize (if (bound-and-true-p evil-this-macro)
|
||||||
(char-to-string evil-this-macro)
|
(char-to-string evil-this-macro)
|
||||||
"Macro")
|
"Macro")
|
||||||
'face '+modeline-highlight)
|
'face 'doom-modeline-highlight)
|
||||||
sep
|
sep
|
||||||
(all-the-icons-octicon "triangle-right"
|
(all-the-icons-octicon "triangle-right"
|
||||||
:face '+modeline-highlight
|
:face 'doom-modeline-highlight
|
||||||
:v-adjust -0.05)
|
:v-adjust -0.05)
|
||||||
sep))))
|
sep))))
|
||||||
|
|
||||||
(def-modeline-var! +modeline-matches
|
(def-modeline-var! +modeline-matches
|
||||||
'(:eval
|
'(:eval
|
||||||
(let ((meta (concat (+modeline--macro-recording)
|
(let ((meta (concat (+modeline--macro-recording)
|
||||||
(+modeline--anzu)
|
(+modeline--anzu)
|
||||||
|
@ -332,7 +337,7 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
||||||
(+modeline--iedit)
|
(+modeline--iedit)
|
||||||
(+modeline--multiple-cursors))))
|
(+modeline--multiple-cursors))))
|
||||||
(or (and (not (equal meta "")) meta)
|
(or (and (not (equal meta "")) meta)
|
||||||
" %I ")))))
|
" %I "))))
|
||||||
|
|
||||||
|
|
||||||
;;; `+modeline-modes'
|
;;; `+modeline-modes'
|
||||||
|
@ -340,7 +345,7 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
||||||
'(""
|
'(""
|
||||||
(:propertize mode-name
|
(:propertize mode-name
|
||||||
face bold
|
face bold
|
||||||
mouse-face +modeline-highlight)
|
mouse-face doom-modeline-highlight)
|
||||||
mode-line-process
|
mode-line-process
|
||||||
"%n"
|
"%n"
|
||||||
" "))
|
" "))
|
||||||
|
@ -369,12 +374,11 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
||||||
|
|
||||||
|
|
||||||
;;; `+modeline-checker'
|
;;; `+modeline-checker'
|
||||||
(progn
|
(def-modeline-var! +modeline-checker nil
|
||||||
(def-modeline-var! +modeline-checker nil
|
|
||||||
"Displays color-coded error status & icon for the current buffer."
|
"Displays color-coded error status & icon for the current buffer."
|
||||||
:local t)
|
:local t)
|
||||||
|
|
||||||
(add-hook! '(flycheck-status-changed-functions
|
(add-hook! '(flycheck-status-changed-functions
|
||||||
flycheck-mode-hook)
|
flycheck-mode-hook)
|
||||||
(defun +modeline-checker-update (&optional status)
|
(defun +modeline-checker-update (&optional status)
|
||||||
"Update flycheck text via STATUS."
|
"Update flycheck text via STATUS."
|
||||||
|
@ -399,23 +403,22 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
||||||
(`running (+modeline-format-icon "access_time" "*" 'font-lock-comment-face "Running..."))
|
(`running (+modeline-format-icon "access_time" "*" 'font-lock-comment-face "Running..."))
|
||||||
(`errored (+modeline-format-icon "sim_card_alert" "!" 'error "Errored!"))
|
(`errored (+modeline-format-icon "sim_card_alert" "!" 'error "Errored!"))
|
||||||
(`interrupted (+modeline-format-icon "pause" "!" 'font-lock-comment-face "Interrupted"))
|
(`interrupted (+modeline-format-icon "pause" "!" 'font-lock-comment-face "Interrupted"))
|
||||||
(`suspicious (+modeline-format-icon "priority_high" "!" 'error "Suspicious")))))))
|
(`suspicious (+modeline-format-icon "priority_high" "!" 'error "Suspicious"))))))
|
||||||
|
|
||||||
|
|
||||||
;;; `+modeline-selection-info'
|
;;; `+modeline-selection-info'
|
||||||
(progn
|
(defsubst +modeline--column (pos)
|
||||||
(defsubst +modeline--column (pos)
|
|
||||||
"Get the column of the position `POS'."
|
"Get the column of the position `POS'."
|
||||||
(save-excursion (goto-char pos)
|
(save-excursion (goto-char pos)
|
||||||
(current-column)))
|
(current-column)))
|
||||||
|
|
||||||
(def-modeline-var! +modeline-selection-info
|
(def-modeline-var! +modeline-selection-info
|
||||||
'(:eval
|
'(:eval
|
||||||
(when (or mark-active
|
(when (or (and (bound-and-true-p evil-local-mode)
|
||||||
(and (bound-and-true-p evil-local-mode)
|
(eq evil-state 'visual))
|
||||||
(eq evil-state 'visual)))
|
mark-active)
|
||||||
(cl-destructuring-bind (beg . end)
|
(cl-destructuring-bind (beg . end)
|
||||||
(if (boundp 'evil-local-mode)
|
(if (bound-and-true-p evil-visual-selection)
|
||||||
(cons evil-visual-beginning evil-visual-end)
|
(cons evil-visual-beginning evil-visual-end)
|
||||||
(cons (region-beginning) (region-end)))
|
(cons (region-beginning) (region-end)))
|
||||||
(propertize
|
(propertize
|
||||||
|
@ -440,17 +443,17 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
|
||||||
"Information about the current selection, such as how many characters and
|
"Information about the current selection, such as how many characters and
|
||||||
lines are selected, or the NxM dimensions of a block selection.")
|
lines are selected, or the NxM dimensions of a block selection.")
|
||||||
|
|
||||||
(defun +modeline-add-selection-segment-h ()
|
(defun +modeline-add-selection-segment-h ()
|
||||||
(add-to-list '+modeline-format-left '+modeline-selection-info 'append))
|
(add-to-list '+modeline-format-left '+modeline-selection-info 'append))
|
||||||
(defun +modeline-remove-selection-segment-h ()
|
(defun +modeline-remove-selection-segment-h ()
|
||||||
(delq! '+modeline-selection-info +modeline-format-left))
|
(delq! '+modeline-selection-info +modeline-format-left))
|
||||||
|
|
||||||
(if (featurep 'evil)
|
(if (featurep 'evil)
|
||||||
(progn
|
(progn
|
||||||
(add-hook 'evil-visual-state-entry-hook #'+modeline-add-selection-segment-h)
|
(add-hook 'evil-visual-state-entry-hook #'+modeline-add-selection-segment-h)
|
||||||
(add-hook 'evil-visual-state-exit-hook #'+modeline-remove-selection-segment-h))
|
(add-hook 'evil-visual-state-exit-hook #'+modeline-remove-selection-segment-h))
|
||||||
(add-hook 'activate-mark-hook #'+modeline-add-selection-segment-h)
|
(add-hook 'activate-mark-hook #'+modeline-add-selection-segment-h)
|
||||||
(add-hook 'deactivate-mark-hook #'+modeline-remove-selection-segment-h)))
|
(add-hook 'deactivate-mark-hook #'+modeline-remove-selection-segment-h))
|
||||||
|
|
||||||
|
|
||||||
;;; `+modeline-encoding'
|
;;; `+modeline-encoding'
|
||||||
|
@ -496,8 +499,8 @@ lines are selected, or the NxM dimensions of a block selection.")
|
||||||
,(all-the-icons-octicon
|
,(all-the-icons-octicon
|
||||||
"file-directory"
|
"file-directory"
|
||||||
:face 'bold
|
:face 'bold
|
||||||
:v-adjust -0.05
|
:v-adjust -0.06
|
||||||
:height 1.25)
|
:height 1.1)
|
||||||
(:propertize (" " (:eval (abbreviate-file-name default-directory)))
|
(:propertize (" " (:eval (abbreviate-file-name default-directory)))
|
||||||
face bold))
|
face bold))
|
||||||
'("" mode-line-misc-info +modeline-modes))
|
'("" mode-line-misc-info +modeline-modes))
|
||||||
|
@ -507,7 +510,8 @@ lines are selected, or the NxM dimensions of a block selection.")
|
||||||
" " +modeline-buffer-identification)
|
" " +modeline-buffer-identification)
|
||||||
'("" +modeline-modes))
|
'("" +modeline-modes))
|
||||||
|
|
||||||
;; TODO (def-modeline! pdf ...)
|
;; (def-modeline! pdf
|
||||||
|
;; '("" +modeline-matches))
|
||||||
;; TODO (def-modeline! helm ...)
|
;; TODO (def-modeline! helm ...)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue