-
-
Notifications
You must be signed in to change notification settings - Fork 141
add nerd-icons support to dashboard #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add nerd-icons support to dashboard #451
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits. Everything else LGTM!
Can you resolve the compile error? See https://github.com/emacs-dashboard/emacs-dashboard/actions/runs/4864724799/jobs/8675087587?pr=451#step:5:116.
Yeah, you are right. Users will have to set up the dashboard config early. If you want to change the icon type, they would have to restart Emacs or set them all manually. I don't know if there is a better solution than this, but I don't think this is a huge issue since people normally start the dashboard at the beginning and hope it works. There isn't a lot of runtime tweaking throughout the lifecycle.
No, the |
Thank you so much for the detailed explanation! I just fixed the compile error and replaced those |
dashboard-widgets.el
Outdated
ARGS should be a plist containing `:height', `:v-adjust', | ||
or `:face' properties." | ||
(cond ((eq dashboard-icon-type 'all-the-icons) (apply #'all-the-icons-octicon name args)) | ||
((eq dashboard-icon-type 'nerd-icons) (apply #'nerd-icons-octicon name args)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe all these places, use pcase
for consistency. :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah I should do a search for all of the occurrences. Sorry about that!
BTW is there any advantage of using pcase
over cond
? or it doesn't matter and we just want consistency here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a matter of taste. I prefer pcase
since the code is cleaner. The downside of this, it will add up startup time due to loading the pcase.el
module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a matter of taste. I prefer pcase
since the code is cleaner. The downside of this, it will add up startup time due to loading the pcase.el
module.
No, I should say thank you to you! Thanks for creating nerd-icons! ❤️ It's amazing! I've added all of the nerd-icons related packages to my config! See here. |
I just replaced other Yeah I felt jealous when I saw Vim users had Nerd icons and we didn't. That's why I made nerd-icons lol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some clean up! ;)
@@ -98,6 +102,53 @@ preserved." | |||
:type 'integer | |||
:group 'dashboard) | |||
|
|||
(defcustom dashboard-icon-type (or (require 'nerd-icons nil t) | |||
(require 'all-the-icons nil t)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to prevent require in the top level. Let's prevent it by making sure the dashboard-set-heading-icons
is non-nil:
(and dashboard-set-heading-icons
(or (require 'nerd-icons nil t)
(require 'all-the-icons nil t)))
Make sure to place dashboard-set-heading-icons
to the front to avoid compile error.
:set | ||
(lambda (k v) | ||
(and (eq v 'all-the-icons) (not (require 'all-the-icons nil t)) (setq v nil)) | ||
(and (eq v 'nerd-icons) (not (require 'nerd-icons nil t)) (setq v nil)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use pcase
here too?
(pcase v
('all-the-icons
(unless (require 'all-the-icons nil t)
(setq v nil)))
('nerd-icons
(unless (require 'nerd-icons nil t)
(setq v nil))))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some work needs to be done on our side. Anyways, the PR is good to be merged! :D
Thank you for your contribution! ❤️ 🚀
Sorry I was a bit busy just now. The clean up looks good, and I think we also need to modify the README regarding using nerd-icons. Thank you for your guidance! |
No worries! The code quality is there, therefore it's good to merge! :D
Can you open another PR for this. Thanks! :) |
demo

(Ubuntu 20.04, Gnome Desktop, Alacritty terminal, FiraCode Nerd Fonts)
Major Changes
I added
dashboard-icon-type
which specifies which icon package to use (either'all-the-icons
or'nerd-icons
). Based ondashboard-icon-type
, other icon related custom variables such asdashboard-heading-icons
will have corresponding default values.Configuration for using Nerd Icons
Things I am not sure about
I'm not sure if my implementation for setting default values for some custom variables based on
dashboard-icon-type
is good. Let's say I setdashboard-icon-type
to'nerd-icons
. My current implementation for setting the default value ofdashboard-heading-icons
is to use apcase
statement. Does settingdashboard-icon-type
trigger the evaluation ofdashboard-heading-icons
'spcase
? If I want to set a new value fordashboard-heading-icons
in a init file, does it require some kind of ordering like I must settingdashboard-icon-type
before settingdashboard-heading-icons
?Other comments
I have been using this dashboard for a few weeks now, and no issues so far. However, it might still have bugs that I did not think of. I'll be tracking nerd icons related issues here in emacs-dashboard, and I will try my best to solve them :)