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.
|
2019-12-18 00:53:04 +01:00
|
|
|
(defun emodule/modeline-inactive-switch (str)
|
|
|
|
"Apply inactive mode line face to STR if necessary."
|
2019-12-17 11:52:56 +01:00
|
|
|
(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.
|
2019-12-18 00:53:04 +01:00
|
|
|
(defun emodule/modeline-persp ()
|
|
|
|
"Return the formatted perspective name."
|
2019-07-21 00:37:46 +02:00
|
|
|
(if (bound-and-true-p persp-mode)
|
2019-12-18 00:53:04 +01:00
|
|
|
(persp-format-name (persp-name (persp-curr)))
|
2019-07-21 00:37:46 +02:00
|
|
|
""))
|
|
|
|
|
2019-12-18 00:53:04 +01:00
|
|
|
(doom-modeline-def-segment emodule/modeline-persp-segment
|
|
|
|
"Currently chose perspective."
|
|
|
|
(emodule/modeline-inactive-switch
|
|
|
|
(concat "[" (emodule/modeline-persp) "]")))
|
2019-12-15 16:36:30 +01:00
|
|
|
|
2019-12-18 00:53:04 +01:00
|
|
|
;; The current eyebrowse workspace number.
|
|
|
|
(defun emodule/modeline-eyebrowse ()
|
|
|
|
"Return the currently active eyebrowse workspace."
|
2019-12-15 16:36:30 +01:00
|
|
|
(if (bound-and-true-p eyebrowse-mode)
|
2019-12-18 20:48:10 +01:00
|
|
|
(let* ((cur (eyebrowse--get 'current-slot))
|
2019-12-18 22:53:16 +01:00
|
|
|
(all (--map (car it) (eyebrowse--get 'window-configs)))
|
|
|
|
(str (--map (if (= cur it)
|
|
|
|
(propertize (int-to-string it)
|
|
|
|
'face
|
|
|
|
'eyebrowse-mode-line-active)
|
|
|
|
(int-to-string it))
|
|
|
|
all)))
|
|
|
|
(apply 'concat str))
|
2019-12-15 16:36:30 +01:00
|
|
|
""))
|
|
|
|
|
2019-12-18 00:53:04 +01:00
|
|
|
(doom-modeline-def-segment emodule/modeline-eyebrowse-segment
|
|
|
|
"The current workspace name or number."
|
|
|
|
(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)))
|
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
|
2019-12-18 00:53:04 +01:00
|
|
|
emodule/modeline-persp-eyebrowse-segment
|
2019-12-17 11:52:56 +01:00
|
|
|
window-number matches buffer-info remote-host
|
|
|
|
buffer-position selection-info)
|
2019-12-18 00:53:04 +01:00
|
|
|
'(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))
|
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
|