ui/doom-modeline: optimize vcs segment (experimental)
This commit is contained in:
parent
fbce2388ab
commit
9ae99deb65
1 changed files with 40 additions and 34 deletions
|
@ -376,40 +376,46 @@ directory, the file name, and its state (modified, read-only or non-existent)."
|
||||||
;; vcs
|
;; vcs
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(def-modeline-segment! vcs
|
(defvar +doom-modeline--vcs nil)
|
||||||
"Displays the current branch, colored based on its state."
|
(defun +doom-modeline--update-vcs ()
|
||||||
(when (and vc-mode buffer-file-name)
|
(setq +doom-modeline--vcs
|
||||||
(let* ((backend (vc-backend buffer-file-name))
|
(when (and vc-mode buffer-file-name)
|
||||||
(state (vc-state buffer-file-name backend)))
|
(let* ((backend (vc-backend buffer-file-name))
|
||||||
(let ((face 'mode-line-inactive)
|
(state (vc-state buffer-file-name backend)))
|
||||||
(active (active))
|
(let ((face 'mode-line-inactive)
|
||||||
(all-the-icons-default-adjust -0.1))
|
(active (active))
|
||||||
(concat " "
|
(all-the-icons-default-adjust -0.1))
|
||||||
(cond ((memq state '(edited added))
|
(concat " "
|
||||||
(if active (setq face 'doom-modeline-info))
|
(cond ((memq state '(edited added))
|
||||||
(all-the-icons-octicon
|
(if active (setq face 'doom-modeline-info))
|
||||||
"git-compare"
|
(all-the-icons-octicon
|
||||||
:face face
|
"git-compare"
|
||||||
:v-adjust -0.05))
|
:face face
|
||||||
((eq state 'needs-merge)
|
:v-adjust -0.05))
|
||||||
(if active (setq face 'doom-modeline-info))
|
((eq state 'needs-merge)
|
||||||
(all-the-icons-octicon "git-merge" :face face))
|
(if active (setq face 'doom-modeline-info))
|
||||||
((eq state 'needs-update)
|
(all-the-icons-octicon "git-merge" :face face))
|
||||||
(if active (setq face 'doom-modeline-warning))
|
((eq state 'needs-update)
|
||||||
(all-the-icons-octicon "arrow-down" :face face))
|
(if active (setq face 'doom-modeline-warning))
|
||||||
((memq state '(removed conflict unregistered))
|
(all-the-icons-octicon "arrow-down" :face face))
|
||||||
(if active (setq face 'doom-modeline-urgent))
|
((memq state '(removed conflict unregistered))
|
||||||
(all-the-icons-octicon "alert" :face face))
|
(if active (setq face 'doom-modeline-urgent))
|
||||||
(t
|
(all-the-icons-octicon "alert" :face face))
|
||||||
(if active (setq face 'font-lock-doc-face))
|
(t
|
||||||
(all-the-icons-octicon
|
(if active (setq face 'font-lock-doc-face))
|
||||||
"git-compare"
|
(all-the-icons-octicon
|
||||||
:face face
|
"git-compare"
|
||||||
:v-adjust -0.05)))
|
:face face
|
||||||
" "
|
:v-adjust -0.05)))
|
||||||
(propertize (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))
|
" "
|
||||||
'face (if active face))
|
(propertize (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2))
|
||||||
" ")))))
|
'face (if active face))
|
||||||
|
" "))))))
|
||||||
|
(add-hook 'after-save-hook #'+doom-modeline--update-vcs)
|
||||||
|
(add-hook 'find-file-hook #'+doom-modeline--update-vcs t)
|
||||||
|
|
||||||
|
(def-modeline-var! vcs +doom-modeline--vcs
|
||||||
|
"Displays the current branch, colored based on its state.")
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue