2019-07-21 00:37:46 +02:00
|
|
|
;;; modeline.el --- Module file for configuring the modeline.
|
|
|
|
;;
|
|
|
|
;; Copyright (C) 2018-2019 Wojciech Kozlowski
|
|
|
|
;;
|
|
|
|
;; Author: Wojciech Kozlowski <wk@wojciechkozlowski.eu>
|
|
|
|
;; Created: 2018-02-11
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; Commentary:
|
|
|
|
;;
|
|
|
|
;; This module is used for configuring the modeline.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
;;; Required packages:
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(defvar emodule/modeline-packages
|
|
|
|
|
|
|
|
'(anzu
|
|
|
|
doom-modeline)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
;;; Configuration:
|
|
|
|
|
|
|
|
(defun emodule/modeline-init ()
|
|
|
|
"Initialise the `modeline' module."
|
|
|
|
|
|
|
|
;; --------------------------------------------------------------------------
|
|
|
|
;; `anzu'
|
|
|
|
;; --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(use-package anzu
|
|
|
|
:config
|
|
|
|
(global-anzu-mode 1))
|
|
|
|
|
|
|
|
;; --------------------------------------------------------------------------
|
|
|
|
;; `doom-modeline' - note that doom-modeline requires all-the-icons which in
|
|
|
|
;; turn require the user to manually install the fonts with the command `M-x
|
|
|
|
;; all-the-icons-install-fonts'.
|
|
|
|
;; --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
(use-package doom-modeline
|
|
|
|
:hook
|
|
|
|
(after-init . doom-modeline-mode)
|
|
|
|
:config
|
|
|
|
(setq column-number-mode t
|
2019-12-17 11:52:56 +01:00
|
|
|
doom-modeline-height 25
|
2019-07-21 00:37:46 +02:00
|
|
|
doom-modeline-checker-simple-format nil
|
|
|
|
doom-modeline-env-python-executable "python3")
|
|
|
|
|
2019-12-17 11:52:56 +01:00
|
|
|
;; Convenience function for correct active/inactive handling.
|
|
|
|
(defun x-doom-active-switch (str)
|
|
|
|
"Correctly apply active/inactive mode line face to STR."
|
|
|
|
(if (doom-modeline--active)
|
|
|
|
str
|
|
|
|
(propertize str 'face 'mode-line-inactive)))
|
|
|
|
|
2019-07-21 00:37:46 +02:00
|
|
|
;; Custom perspective display - display only the active perspective.
|
|
|
|
(doom-modeline-def-segment perspective-name
|
|
|
|
"Perspectives list and selection. Requires `persp-mode' to be enabled."
|
|
|
|
(if (bound-and-true-p persp-mode)
|
2019-12-17 11:52:56 +01:00
|
|
|
(x-doom-active-switch
|
|
|
|
(persp-format-name (persp-name (persp-curr))))
|
2019-07-21 00:37:46 +02:00
|
|
|
""))
|
|
|
|
|
2019-08-07 11:55:30 +02:00
|
|
|
;; Display active python virtualenv.
|
|
|
|
(defface pyvenv-active-face
|
|
|
|
'((t (:inherit persp-selected-face)))
|
|
|
|
"The face used to highlight the active virtualenv on the modeline.")
|
|
|
|
|
|
|
|
(doom-modeline-def-segment pyvenv-venv
|
|
|
|
"Active Python virtualenv. Requires `pyvenv' to be enabled."
|
|
|
|
(if (bound-and-true-p pyvenv-virtual-env-name)
|
2019-12-17 11:52:56 +01:00
|
|
|
(x-doom-active-switch
|
|
|
|
(propertize pyvenv-virtual-env-name 'face 'pyvenv-active-face))
|
2019-08-07 11:55:30 +02:00
|
|
|
""))
|
|
|
|
|
2019-12-15 16:36:30 +01:00
|
|
|
(doom-modeline-def-segment workspace-number
|
|
|
|
"The current workspace name or number.
|
|
|
|
|
|
|
|
Requires `eyebrowse-mode' to be enabled."
|
|
|
|
|
|
|
|
(if (bound-and-true-p eyebrowse-mode)
|
|
|
|
(let* ((num (eyebrowse--get 'current-slot))
|
2019-12-17 11:52:56 +01:00
|
|
|
(tag (when num
|
|
|
|
(nth 2 (assoc num (eyebrowse--get 'window-configs)))))
|
2019-12-15 16:36:30 +01:00
|
|
|
(str (if (and tag (< 0 (length tag)))
|
|
|
|
tag
|
|
|
|
(when num (int-to-string num)))))
|
2019-12-17 11:52:56 +01:00
|
|
|
(x-doom-active-switch
|
|
|
|
(propertize str 'face 'eyebrowse-mode-line-active)))
|
2019-12-15 16:36:30 +01:00
|
|
|
""))
|
|
|
|
|
2019-12-17 11:52:56 +01:00
|
|
|
(doom-modeline-def-segment left-bracket (x-doom-active-switch "["))
|
|
|
|
(doom-modeline-def-segment right-bracket (x-doom-active-switch "]"))
|
|
|
|
(doom-modeline-def-segment colon (x-doom-active-switch ":"))
|
2019-07-21 00:37:46 +02:00
|
|
|
|
|
|
|
;; Define custom modeline.
|
|
|
|
(doom-modeline-def-modeline 'my-line
|
2019-12-17 11:52:56 +01:00
|
|
|
'(bar
|
|
|
|
left-bracket perspective-name colon workspace-number right-bracket
|
|
|
|
window-number matches buffer-info remote-host
|
|
|
|
buffer-position selection-info)
|
|
|
|
'(lsp debug pyvenv-venv major-mode vcs checker))
|
2019-07-21 00:37:46 +02:00
|
|
|
|
|
|
|
(add-hook 'doom-modeline-mode-hook
|
|
|
|
(lambda () (doom-modeline-set-modeline 'my-line 'default))))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
(provide 'emodule/modeline)
|
|
|
|
;;; modeline.el ends here
|