refactor!: replace all-the-icons with nerd-icons

BREAKING CHANGE: This commit replaces all-the-icons with nerd-fonts. Any
all-the-icons-* function calls or variable references in your private
config will break and should be replaced with their nerd-icons-*
equivalent. That said, Doom will continue to install all-the-icons for
a while, so feel free to load it if you don't want to fully commit to
the change yet.

This change is happening because nerd-icon has wider support for GUI and
TUI Emacs; has a larger, more consistent selection of symbols; plus unicode
coverage.

Fix: #7368
Close: #6675
Close: #7364
This commit is contained in:
Ellis Kenyő 2023-09-14 00:03:55 +01:00 committed by GitHub
parent 7bdf7cf7c0
commit 9787022b83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 293 additions and 407 deletions

View file

@ -41,9 +41,9 @@ Besides eye candy, the dashboard serves two other purposes:
* Installation
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
This module only requires that ~all-the-icons~'s icon fonts are installed, which
This module only requires that ~nerd-icons~'s icon fonts are installed, which
should've been installed when you ran ~$ doom install~. Otherwise, use ~M-x
all-the-icons-install-fonts~ to install them.
nerd-icons-install-fonts~ to install them.
* Usage
Once this module is enabled, the dashboard will present itself after opening a
@ -88,7 +88,7 @@ color from the theme) you can make use of ~custom-set-faces!~ or
(custom-set-faces!
'(doom-dashboard-banner :foreground "red" :background "#000000" :weight bold)
'(doom-dashboard-footer :inherit font-lock-constant-face)
'(doom-dashboard-footer-icon :inherit all-the-icons-red)
'(doom-dashboard-footer-icon :inherit nerd-icons-red)
'(doom-dashboard-loaded :inherit font-lock-warning-face)
'(doom-dashboard-menu-desc :inherit font-lock-string-face)
'(doom-dashboard-menu-title :inherit font-lock-function-name-face))
@ -99,7 +99,7 @@ or for a per-theme setting
(custom-theme-set-faces! 'doom-tomorrow-night
'(doom-dashboard-banner :foreground "red" :background "#000000" :weight bold)
'(doom-dashboard-footer :inherit font-lock-constant-face)
'(doom-dashboard-footer-icon :inherit all-the-icons-red)
'(doom-dashboard-footer-icon :inherit nerd-icons-red)
'(doom-dashboard-loaded :inherit font-lock-warning-face)
'(doom-dashboard-menu-desc :inherit font-lock-string-face)
'(doom-dashboard-menu-title :inherit font-lock-function-name-face))

View file

@ -47,32 +47,31 @@ Possible values:
(defvar +doom-dashboard-menu-sections
'(("Recently opened files"
:icon (all-the-icons-octicon "file-text" :face 'doom-dashboard-menu-title)
:face (:inherit (doom-dashboard-menu-title bold))
:icon (nerd-icons-faicon "nf-fa-file_text" :face 'doom-dashboard-menu-title)
:action recentf-open-files)
("Reload last session"
:icon (all-the-icons-octicon "history" :face 'doom-dashboard-menu-title)
:icon (nerd-icons-octicon "nf-oct-history" :face 'doom-dashboard-menu-title)
:when (cond ((modulep! :ui workspaces)
(file-exists-p (expand-file-name persp-auto-save-fname persp-save-dir)))
((require 'desktop nil t)
(file-exists-p (desktop-full-file-name))))
:action doom/quickload-session)
("Open org-agenda"
:icon (all-the-icons-octicon "calendar" :face 'doom-dashboard-menu-title)
:icon (nerd-icons-octicon "nf-oct-calendar" :face 'doom-dashboard-menu-title)
:when (fboundp 'org-agenda)
:action org-agenda)
("Open project"
:icon (all-the-icons-octicon "briefcase" :face 'doom-dashboard-menu-title)
:icon (nerd-icons-octicon "nf-oct-briefcase" :face 'doom-dashboard-menu-title)
:action projectile-switch-project)
("Jump to bookmark"
:icon (all-the-icons-octicon "bookmark" :face 'doom-dashboard-menu-title)
:icon (nerd-icons-octicon "nf-oct-bookmark" :face 'doom-dashboard-menu-title)
:action bookmark-jump)
("Open private configuration"
:icon (all-the-icons-octicon "tools" :face 'doom-dashboard-menu-title)
:icon (nerd-icons-octicon "nf-oct-tools" :face 'doom-dashboard-menu-title)
:when (file-directory-p doom-user-dir)
:action doom/open-private-config)
("Open documentation"
:icon (all-the-icons-octicon "book" :face 'doom-dashboard-menu-title)
:icon (nerd-icons-octicon "nf-oct-book" :face 'doom-dashboard-menu-title)
:action doom/help))
"An alist of menu buttons used by `doom-dashboard-widget-shortmenu'. Each
element is a cons cell (LABEL . PLIST). LABEL is a string to display after the
@ -98,9 +97,6 @@ PLIST can have the following properties:
(defvar +doom-dashboard--pwd-alist ())
(defvar +doom-dashboard--reload-timer nil)
(defvar all-the-icons-scale-factor)
(defvar all-the-icons-default-adjust)
;;
;;; Bootstrap
@ -151,7 +147,7 @@ PLIST can have the following properties:
"Face used for the footer on the dashboard"
:group 'doom-dashboard)
(defface doom-dashboard-footer-icon '((t (:inherit all-the-icons-green)))
(defface doom-dashboard-footer-icon '((t (:inherit nerd-icons-green)))
"Face used for the icon of the footer on the dashboard"
:group 'doom-dashboard)
@ -456,60 +452,58 @@ What it is set to is controlled by `+doom-dashboard-pwd-policy'."
"\n")))
(defun doom-dashboard-widget-shortmenu ()
(let ((all-the-icons-scale-factor 1.45)
(all-the-icons-default-adjust -0.02))
(insert "\n")
(dolist (section +doom-dashboard-menu-sections)
(cl-destructuring-bind (label &key icon action when face key) section
(when (and (fboundp action)
(or (null when)
(eval when t)))
(insert
(+doom-dashboard--center
(- +doom-dashboard--width 1)
(let ((icon (if (stringp icon) icon (eval icon t))))
(format (format "%s%%s%%-10s" (if icon "%3s\t" "%3s"))
(or icon "")
(with-temp-buffer
(insert-text-button
label
'action
`(lambda (_)
(call-interactively (or (command-remapping #',action)
#',action)))
'face (or face 'doom-dashboard-menu-title)
'follow-link t
'help-echo
(format "%s (%s)" label
(propertize (symbol-name action) 'face 'doom-dashboard-menu-desc)))
(format "%-37s" (buffer-string)))
;; Lookup command keys dynamically
(propertize
(or key
(when-let*
((keymaps
(delq
nil (list (when (bound-and-true-p evil-local-mode)
(evil-get-auxiliary-keymap +doom-dashboard-mode-map 'normal))
+doom-dashboard-mode-map)))
(key
(or (when keymaps
(where-is-internal action keymaps t))
(where-is-internal action nil t))))
(with-temp-buffer
(save-excursion (insert (key-description key)))
(while (re-search-forward "<\\([^>]+\\)>" nil t)
(let ((str (match-string 1)))
(replace-match
(upcase (if (< (length str) 3)
str
(substring str 0 3))))))
(buffer-string)))
"")
'face 'doom-dashboard-menu-desc))))
(if (display-graphic-p)
"\n\n"
"\n")))))))
(insert "\n")
(dolist (section +doom-dashboard-menu-sections)
(cl-destructuring-bind (label &key icon action when face key) section
(when (and (fboundp action)
(or (null when)
(eval when t)))
(insert
(+doom-dashboard--center
(- +doom-dashboard--width 1)
(let ((icon (if (stringp icon) icon (eval icon t))))
(format (format "%s%%s%%-10s" (if icon "%3s\t" "%3s"))
(or icon "")
(with-temp-buffer
(insert-text-button
label
'action
`(lambda (_)
(call-interactively (or (command-remapping #',action)
#',action)))
'face (or face 'doom-dashboard-menu-title)
'follow-link t
'help-echo
(format "%s (%s)" label
(propertize (symbol-name action) 'face 'doom-dashboard-menu-desc)))
(format "%-37s" (buffer-string)))
;; Lookup command keys dynamically
(propertize
(or key
(when-let*
((keymaps
(delq
nil (list (when (bound-and-true-p evil-local-mode)
(evil-get-auxiliary-keymap +doom-dashboard-mode-map 'normal))
+doom-dashboard-mode-map)))
(key
(or (when keymaps
(where-is-internal action keymaps t))
(where-is-internal action nil t))))
(with-temp-buffer
(save-excursion (insert (key-description key)))
(while (re-search-forward "<\\([^>]+\\)>" nil t)
(let ((str (match-string 1)))
(replace-match
(upcase (if (< (length str) 3)
str
(substring str 0 3))))))
(buffer-string)))
"")
'face 'doom-dashboard-menu-desc))))
(if (display-graphic-p)
"\n\n"
"\n"))))))
(defun doom-dashboard-widget-footer ()
(insert
@ -517,7 +511,7 @@ What it is set to is controlled by `+doom-dashboard-pwd-policy'."
(+doom-dashboard--center
(- +doom-dashboard--width 2)
(with-temp-buffer
(insert-text-button (or (all-the-icons-octicon "octoface" :face 'doom-dashboard-footer-icon :height 1.3 :v-adjust -0.15)
(insert-text-button (or (nerd-icons-codicon "nf-cod-octoface" :face 'doom-dashboard-footer-icon :height 1.3 :v-adjust -0.15)
(propertize "github" 'face 'doom-dashboard-footer))
'action (lambda (_) (browse-url "https://github.com/hlissner/doom-emacs"))
'follow-link t

View file

@ -86,8 +86,8 @@ core/core-ui.el has four relevant variables:
** Strange font symbols
If you're seeing strange unicode symbols, this is likely because you don't have
~all-the-icons~'s font icon installed. You can install them with ~M-x
all-the-icons-install-fonts~.
~nerd-icons~'s font icon installed. You can install them with ~M-x
nerd-icons-install-fonts~.
** Ugly background colors in tty Emacs for daemon users
[[doom-package:solaire-mode]] is an aesthetic plugin that makes non-file-visiting buffers darker

View file

@ -113,11 +113,9 @@ side of the modeline, and whose CDR is the right-hand side.")
"Build from ICON-SET the ICON with LABEL.
Using optionals attributes FACE, HELP-ECHO and VOFFSET."
(let ((icon-set-fn (pcase icon-set
('octicon #'all-the-icons-octicon)
('faicon #'all-the-icons-faicon)
('material #'all-the-icons-material)
('alltheicon #'all-the-icons-alltheicon)
('fileicon #'all-the-icons-fileicon))))
('octicon #'nerd-icons-octicon)
('faicon #'nerd-icons-faicon)
('material #'nerd-icons-mdicon))))
(propertize (concat (funcall icon-set-fn
icon
:face face
@ -290,7 +288,7 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
(evil-mc-frozen 'doom-modeline-highlight)
('doom-modeline-alternate-highlight))))
(concat (propertize " " 'face face)
(all-the-icons-faicon "i-cursor" :face face :v-adjust -0.0575)
(nerd-icons-faicon "nf-fa-i_cursor" :face face :v-adjust -0.0575)
(propertize " " 'face `(:inherit (variable-pitch ,face)))
(propertize (format "%d " count)
'face face)))))))
@ -332,7 +330,7 @@ Requires `anzu', also `evil-anzu' if using `evil-mode' for compatibility with
"Macro")
'face 'doom-modeline-highlight)
sep
(all-the-icons-octicon "triangle-right"
(nerd-icons-octicon "nf-oct-triangle_right"
:face 'doom-modeline-highlight
:v-adjust -0.05)
sep))))
@ -532,7 +530,7 @@ lines are selected, or the NxM dimensions of a block selection.")
mode-line-misc-info
+modeline-modes
(vc-mode (" "
,(all-the-icons-octicon "git-branch" :v-adjust 0.0)
,(nerd-icons-octicon "nf-oct-git_branch" :v-adjust 0.0)
vc-mode " "))
" "
+modeline-encoding
@ -540,8 +538,8 @@ lines are selected, or the NxM dimensions of a block selection.")
(def-modeline! 'project
`(" "
,(all-the-icons-octicon
"file-directory"
,(nerd-icons-octicon
"nf-oct-file_directory"
:face 'bold
:v-adjust -0.06
:height 1.1)

View file

@ -73,11 +73,11 @@ I rarely need to know what minor modes are active, so I removed them. ~M-x
doom/describe-active-minor-mode~ was written to substitute for it.
** Icons in my modeline look strange
1. Check whether ~all-the-icons~ are installed. Run ~M-x
all-the-icons-install-fonts~ to install the resource fonts. Note that
~all-the-icons~ only support GUI. See [[https://github.com/domtronn/all-the-icons.el][all-the-icons]] for details.
1. Check whether ~nerd-icons~ are installed. Run ~M-x
nerd-icons-install-fonts~ to install the resource fonts. Note that
~nerd-icons~ only support GUI. See [[https://github.com/domtronn/nerd-icons.el][nerd-icons]] for details.
2. ~cnfonts~ will conflict with ~all-the-icons~. You can refer the following
2. ~cnfonts~ will conflict with ~nerd-icons~. You can refer the following
workaround:
#+begin_src emacs-lisp
;; See https://github.com/seagle0128/doom-modeline/issues/278#issuecomment-569510336
@ -87,18 +87,11 @@ doom/describe-active-minor-mode~ was written to substitute for it.
(add-hook 'after-setting-font-hook #'cnfonts-set-font)
#+end_src
3. If ~all-the-icons~ fonts are installed while the icons cannot display
correctly, please install the non-free font [[https://dn-works.com/wp-content/uploads/2020/UFAS-Fonts/Symbola.zip][Symbola]]. This issue usually
occurs on Windows.
** The right side of the modeline is cut off
I believe the consensus is: this is due to oversized icons, i.e. a font issue.
Some possible solutions:
1. Tweak ~all-the-icons-scale-factor~ (1.2 by default): ~(setq
all-the-icons-scale-factor 1.1)~
2. Add some padding to the modeline definition:
1. Add some padding to the modeline definition:
#+begin_src emacs-lisp
(after! doom-modeline
(doom-modeline-def-modeline 'main
@ -106,7 +99,7 @@ Some possible solutions:
'(misc-info minor-modes checker input-method buffer-encoding major-mode process vcs " "))) ; <-- added padding here
#+end_src
3. Use another font for the mode line (or a different ~:height~) (source)
2. Use another font for the mode line (or a different ~:height~) (source)
#+begin_src emacs-lisp
(custom-set-faces!
'(mode-line :family "Noto Sans" :height 0.9)

View file

@ -37,21 +37,7 @@
(IS-WINDOWS 1)
(0)))
;; Fix modeline icons in daemon-spawned graphical frames. We have our own
;; mechanism for disabling all-the-icons, so we don't need doom-modeline to do
;; it for us. However, this may cause unwanted padding in the modeline in
;; daemon-spawned terminal frames. If it bothers you, you may prefer
;; `doom-modeline-icon' set to `nil'.
(when (daemonp)
(setq doom-modeline-icon t))
:config
;; HACK Fix #4102 due to empty all-the-icons return value (caused by
;; `doom--disable-all-the-icons-in-tty-a' advice) in tty daemon frames.
(defadvice! +modeline-disable-icon-in-daemon-a (fn &rest args)
:around #'doom-modeline-propertize-icon
(when (display-graphic-p)
(apply fn args)))
;; Fix an issue where these two variables aren't defined in TTY Emacs on MacOS
(defvar mouse-wheel-down-event nil)
(defvar mouse-wheel-up-event nil)

View file

@ -2,7 +2,7 @@
;;; ui/modeline/packages.el
(unless (modulep! +light)
(package! doom-modeline :pin "f45a5a200313568d54d73dd38bae76930c2008b5"))
(package! doom-modeline :pin "173ad0a27f2c3babe2009a3b760b92d3c8718f5a"))
(package! anzu :pin "5abb37455ea44fa401d5f4c1bdc58adb2448db67")
(when (modulep! :editor evil)
(package! evil-anzu :pin "d1e98ee6976437164627542909a25c6946497899"))