Update modeline

This commit is contained in:
Wojciech Kozlowski 2019-12-18 00:53:04 +01:00
parent 6bc8c71dc8
commit 218165ba3d

View File

@ -53,37 +53,27 @@
doom-modeline-env-python-executable "python3") doom-modeline-env-python-executable "python3")
;; Convenience function for correct active/inactive handling. ;; Convenience function for correct active/inactive handling.
(defun x-doom-active-switch (str) (defun emodule/modeline-inactive-switch (str)
"Correctly apply active/inactive mode line face to STR." "Apply inactive mode line face to STR if necessary."
(if (doom-modeline--active) (if (doom-modeline--active)
str str
(propertize str 'face 'mode-line-inactive))) (propertize str 'face 'mode-line-inactive)))
;; Custom perspective display - display only the active perspective. ;; Custom perspective display - display only the active perspective.
(doom-modeline-def-segment perspective-name (defun emodule/modeline-persp ()
"Perspectives list and selection. Requires `persp-mode' to be enabled." "Return the formatted perspective name."
(if (bound-and-true-p persp-mode) (if (bound-and-true-p persp-mode)
(x-doom-active-switch (persp-format-name (persp-name (persp-curr)))
(persp-format-name (persp-name (persp-curr))))
"")) ""))
;; Display active python virtualenv. (doom-modeline-def-segment emodule/modeline-persp-segment
(defface pyvenv-active-face "Currently chose perspective."
'((t (:inherit persp-selected-face))) (emodule/modeline-inactive-switch
"The face used to highlight the active virtualenv on the modeline.") (concat "[" (emodule/modeline-persp) "]")))
(doom-modeline-def-segment pyvenv-venv
"Active Python virtualenv. Requires `pyvenv' to be enabled."
(if (bound-and-true-p pyvenv-virtual-env-name)
(x-doom-active-switch
(propertize pyvenv-virtual-env-name 'face 'pyvenv-active-face))
""))
(doom-modeline-def-segment workspace-number
"The current workspace name or number.
Requires `eyebrowse-mode' to be enabled."
;; The current eyebrowse workspace number.
(defun emodule/modeline-eyebrowse ()
"Return the currently active eyebrowse workspace."
(if (bound-and-true-p eyebrowse-mode) (if (bound-and-true-p eyebrowse-mode)
(let* ((num (eyebrowse--get 'current-slot)) (let* ((num (eyebrowse--get 'current-slot))
(tag (when num (tag (when num
@ -91,21 +81,57 @@
(str (if (and tag (< 0 (length tag))) (str (if (and tag (< 0 (length tag)))
tag tag
(when num (int-to-string num))))) (when num (int-to-string num)))))
(x-doom-active-switch (propertize str 'face 'eyebrowse-mode-line-active))
(propertize str 'face 'eyebrowse-mode-line-active)))
"")) ""))
(doom-modeline-def-segment left-bracket (x-doom-active-switch "[")) (doom-modeline-def-segment emodule/modeline-eyebrowse-segment
(doom-modeline-def-segment right-bracket (x-doom-active-switch "]")) "The current workspace name or number."
(doom-modeline-def-segment colon (x-doom-active-switch ":")) (emodule/modeline-inactive-switch (emodule/modeline-eyebrowse)))
;; A combined segment.
(doom-modeline-def-segment emodule/modeline-persp-eyebrowse-segment
(emodule/modeline-inactive-switch
(concat "[" (emodule/modeline-persp)
":" (emodule/modeline-eyebrowse)
"]")))
;; Display active python virtualenv.
(defface pyvenv-active-face
'((t (:inherit persp-selected-face)))
"The face used to highlight the active virtualenv on the modeline."
:group 'emodule/modeline-faces)
(defun emodule/modeline-pyvenv ()
"Return the formatted virtualenv name."
(if (bound-and-true-p pyvenv-virtual-env-name)
(propertize pyvenv-virtual-env-name 'face 'pyvenv-active-face)
""))
(doom-modeline-def-segment emodule/modeline-pyvenv-segment
"Active Python virtualenv."
(emodule/modeline-inactive-switch (emodule/modeline-pyvenv)))
;; Define custom modeline. ;; Define custom modeline.
(doom-modeline-def-modeline 'my-line (doom-modeline-def-modeline 'my-line
'(bar '(bar
left-bracket perspective-name colon workspace-number right-bracket emodule/modeline-persp-eyebrowse-segment
window-number matches buffer-info remote-host window-number matches buffer-info remote-host
buffer-position selection-info) buffer-position selection-info)
'(lsp debug pyvenv-venv major-mode vcs checker)) '(lsp debug emodule/modeline-pyvenv-segment major-mode vcs checker))
;; Project modeline (used in Dired).
(doom-modeline-def-modeline 'project
'(bar
emodule/modeline-persp-eyebrowse-segment
window-number buffer-default-directory)
'(debug major-mode process))
;; VCS modeline (used in magit).
(doom-modeline-def-modeline 'vcs
'(bar
emodule/modeline-persp-eyebrowse-segment
window-number matches buffer-info buffer-position selection-info)
'(debug minor-modes buffer-encoding major-mode process))
(add-hook 'doom-modeline-mode-hook (add-hook 'doom-modeline-mode-hook
(lambda () (doom-modeline-set-modeline 'my-line 'default)))) (lambda () (doom-modeline-set-modeline 'my-line 'default))))