[Feature] Support evil state icon.

New option: doom-modeline-evil-state-icon.
The fallback is the unicode character.
Update evil state faces.
This commit is contained in:
Vincent Zhang 2019-11-06 00:26:26 +08:00
parent 44d0f7b871
commit e93660e93f
3 changed files with 90 additions and 78 deletions

View file

@ -208,16 +208,16 @@ Run `M-x customize-group RET doom-modeline RET` or set the variables.
;; Whether to use unicode as a fallback (instead of ASCII) when not using icons.
(setq doom-modeline-unicode-fallback t)
;; Whether display minor modes in mode-line.
;; Whether display the minor modes in mode-line.
(setq doom-modeline-minor-modes (featurep 'minions))
;; If non-nil, a word count will be added to the selection-info modeline segment.
(setq doom-modeline-enable-word-count nil)
;; Whether display buffer encoding.
;; Whether display the buffer encoding.
(setq doom-modeline-buffer-encoding t)
;; Whether display indentation information.
;; Whether display the indentation information.
(setq doom-modeline-indent-info nil)
;; If non-nil, only display one number for checker information if applicable.
@ -229,28 +229,31 @@ Run `M-x customize-group RET doom-modeline RET` or set the variables.
;; The maximum displayed length of the branch name of version control.
(setq doom-modeline-vcs-max-length 12)
;; Whether display perspective name. Non-nil to display in mode-line.
;; Whether display the perspective name. Non-nil to display in mode-line.
(setq doom-modeline-persp-name t)
;; Whether display `lsp' state. Non-nil to display in mode-line.
;; Whether display the `lsp' state. Non-nil to display in mode-line.
(setq doom-modeline-lsp t)
;; Whether display GitHub notifications. It requires `ghub` package.
;; Whether display the GitHub notifications. It requires `ghub` package.
(setq doom-modeline-github nil)
;; The interval of checking GitHub.
(setq doom-modeline-github-interval (* 30 60))
;; Whether display mu4e notifications. It requires `mu4e-alert' package.
;; Whether display the `evil' state icon.
(setq doom-modeline-evil-state-icon t)
;; Whether display the mu4e notifications. It requires `mu4e-alert' package.
(setq doom-modeline-mu4e t)
;; Whether display irc notifications. It requires `circe' package.
;; Whether display the irc notifications. It requires `circe' package.
(setq doom-modeline-irc t)
;; Function to stylize the irc buffer names.
(setq doom-modeline-irc-stylize 'identity)
;; Whether display environment version.
;; Whether display the environment version.
(setq doom-modeline-env-version t)
;; Or for individual languages
(setq doom-modeline-env-enable-python t)

View file

@ -198,7 +198,7 @@ Specify another one if you encounter the issue."
:group'doom-modeline)
(defcustom doom-modeline-icon (display-graphic-p)
"Whether display icons in mode-line.
"Whether display the icons in mode-line.
It respects `all-the-icons-color-icons'.
While using the server mode in GUI, should set the value explicitly."
@ -239,7 +239,7 @@ It respects `doom-modeline-icon' and `doom-modeline-buffer-state-icon'."
:group 'doom-modeline)
(defcustom doom-modeline-minor-modes (featurep 'minions)
"Whether display minor modes in mode-line."
"Whether display the minor modes in mode-line."
:type 'boolean
:group 'doom-modeline)
@ -249,12 +249,12 @@ It respects `doom-modeline-icon' and `doom-modeline-buffer-state-icon'."
:group 'doom-modeline)
(defcustom doom-modeline-buffer-encoding t
"Whether display buffer encoding."
"Whether display the buffer encoding."
:type 'boolean
:group 'doom-modeline)
(defcustom doom-modeline-indent-info nil
"Whether display indentation information."
"Whether display the indentation information."
:type 'boolean
:group 'doom-modeline)
@ -274,21 +274,21 @@ It respects `doom-modeline-icon' and `doom-modeline-buffer-state-icon'."
:group 'doom-modeline)
(defcustom doom-modeline-persp-name t
"Whether display perspective name.
"Whether display the perspective name.
Non-nil to display in mode-line."
:type 'boolean
:group 'doom-modeline)
(defcustom doom-modeline-lsp t
"Whether display `lsp' state.
"Whether display the `lsp' state.
Non-nil to display in mode-line."
:type 'boolean
:group 'doom-modeline)
(defcustom doom-modeline-github nil
"Whether display GitHub notifications/
"Whether display the GitHub notifications.
It requires `ghub' and `async' packages."
:type 'boolean
@ -300,19 +300,24 @@ It requires `ghub' and `async' packages."
:group 'doom-modeline)
(defcustom doom-modeline-env-version t
"Whether display environment version."
"Whether display the environment version."
:type 'boolean
:group 'doom-modeline)
(defcustom doom-modeline-evil-state-icon t
"Whether display the `evil' state icon."
:type 'boolean
:group 'doom-modeline)
(defcustom doom-modeline-mu4e t
"Whether display mu4e notifications.
"Whether display the mu4e notifications.
It requires `mu4e-alert' package."
:type 'boolean
:group 'doom-modeline)
(defcustom doom-modeline-irc t
"Whether display irc notifications.
"Whether display the irc notifications.
It requires `circe' package."
:type 'boolean
@ -420,7 +425,7 @@ It requires `circe' package."
:group 'doom-modeline-faces)
(defface doom-modeline-evil-emacs-state
'((t (:inherit doom-modeline-warning)))
'((t (:inherit (doom-modeline-highlight bold))))
"Face for the Emacs state tag in evil state indicator."
:group 'doom-modeline-faces)
@ -430,7 +435,7 @@ It requires `circe' package."
:group 'doom-modeline-faces)
(defface doom-modeline-evil-motion-state
'((t :inherit doom-modeline-buffer-path))
'((t :inherit doom-modeline-buffer-file))
"Face for the motion state tag in evil state indicator."
:group 'doom-modeline-faces)
@ -440,12 +445,12 @@ It requires `circe' package."
:group 'doom-modeline-faces)
(defface doom-modeline-evil-operator-state
'((t (:inherit doom-modeline-buffer-path)))
'((t (:inherit doom-modeline-buffer-file)))
"Face for the operator state tag in evil state indicator."
:group 'doom-modeline-faces)
(defface doom-modeline-evil-visual-state
'((t (:inherit doom-modeline-buffer-file)))
'((t (:inherit doom-modeline-warning)))
"Face for the visual state tag in evil state indicator."
:group 'doom-modeline-faces)

View file

@ -1513,8 +1513,13 @@ mouse-1: Display Line and Column Mode Menu"
(defsubst doom-modeline--evil ()
"The current evil state. Requires `evil-mode' to be enabled."
(when (bound-and-true-p evil-local-mode)
(let ((tag (evil-state-property evil-state :tag t)))
(propertize tag 'face
(propertize (concat
(doom-modeline-spc)
(doom-modeline-icon
'material
(when doom-modeline-evil-state-icon "fiber_manual_record")
""
(string-trim (evil-state-property evil-state :tag t))
(if (doom-modeline--active)
(cond ((evil-normal-state-p) 'doom-modeline-evil-normal-state)
((evil-emacs-state-p) 'doom-modeline-evil-emacs-state)
@ -1522,8 +1527,12 @@ mouse-1: Display Line and Column Mode Menu"
((evil-motion-state-p) 'doom-modeline-evil-motion-state)
((evil-visual-state-p) 'doom-modeline-evil-visual-state)
((evil-operator-state-p) 'doom-modeline-evil-operator-state)
((evil-replace-state-p) 'doom-modeline-evil-replace-state))
'mode-line-inactive)))))
((evil-replace-state-p) 'doom-modeline-evil-replace-state)
(t 'mode-line))
'mode-line-inactive)
:v-adjust -0.225)
(doom-modeline-spc))
'help-echo (evil-state-property evil-state :name t))))
(defsubst doom-modeline--overwrite ()
"The current overwrite state. Requires `overwrite-mode' to be enabled."
@ -1584,8 +1593,7 @@ mouse-1: Display Line and Column Mode Menu"
"The current objed state."
(when (and doom-modeline--objed-active
(doom-modeline--active))
(propertize
(format " %s(%s) "
(propertize (format " %s(%s) "
(symbol-name objed--object)
(char-to-string (aref (symbol-name objed--obj-state) 0)))
'face 'doom-modeline-evil-emacs-state
@ -1600,9 +1608,7 @@ mouse-1: Display Line and Column Mode Menu"
(doom-modeline-def-segment input-method
"The current input method."
(propertize
(cond
(current-input-method
(propertize (cond (current-input-method
(concat (doom-modeline-spc)
current-input-method-title
(doom-modeline-spc)))
@ -1718,8 +1724,7 @@ mouse-1: Reload to start server")
(jsonrpc--request-continuations server))))
(`(,_id ,doing ,done-p ,detail) (and server (eglot--spinner server)))
(last-error (and server (jsonrpc-last-error server)))
(face (cond
(last-error 'doom-modeline-lsp-error)
(face (cond (last-error 'doom-modeline-lsp-error)
((and doing (not done-p)) 'compilation-mode-line-run)
((and pending (cl-plusp pending)) 'doom-modeline-lsp-warning)
(nick 'doom-modeline-lsp-success)
@ -1743,8 +1748,7 @@ mouse-3: Reconnect to server" nick (eglot--major-mode server)))
(t "EGLOT Disconnected"))
'mouse-face '(:box 0)
'local-map (let ((map (make-sparse-keymap)))
(cond
(last-error
(cond (last-error
(define-key map [mode-line mouse-3]
#'eglot-clear-status))
((and pending (cl-plusp pending))