.emacs.d/elisp/init-all-the-icons.el

169 lines
8.9 KiB
EmacsLisp

;;; init-all-the-icons.el --- -*- lexical-binding: t -*-
;;
;; Filename: init-all-the-icons.el
;; Description: Initialize All-The-Icons
;; Author: Mingde (Matthew) Zeng
;; Copyright (C) 2019 Mingde (Matthew) Zeng
;; Created: Thu Mar 14 17:06:08 2019 (-0400)
;; Version: 2.0.0
;; Last-Updated: Tue Dec 24 11:47:45 2019 (-0500)
;; By: Mingde (Matthew) Zeng
;; URL: https://github.com/MatthewZMD/.emacs.d
;; Keywords: M-EMACS .emacs.d all-the-icons
;; Compatibility: emacs-version >= 26.1
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; This initializes all-the-icons, all-the-icons-dired, all-the-icons-ivy
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or (at
;; your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Code:
(eval-when-compile
(require 'init-const))
(use-package all-the-icons
:if *sys/gui*
:config
(with-no-warnings
;; FIXME: Align the directory icons
;; @see https://github.com/domtronn/all-the-icons.el/pull/173
(defun all-the-icons-icon-for-dir (dir &optional chevron padding)
"Format an icon for DIR with CHEVRON similar to tree based directories."
(let* ((matcher (all-the-icons-match-to-alist (file-name-base (directory-file-name dir)) all-the-icons-dir-icon-alist))
(path (expand-file-name dir))
(chevron (if chevron (all-the-icons-octicon (format "chevron-%s" chevron) :height 0.8 :v-adjust -0.1) ""))
(padding (or padding "\t"))
(icon (cond
((file-symlink-p path)
(all-the-icons-octicon "file-symlink-directory" :height 1.0 :v-adjust 0.0))
((all-the-icons-dir-is-submodule path)
(all-the-icons-octicon "file-submodule" :height 1.0 :v-adjust 0.0))
((file-exists-p (format "%s/.git" path))
(format "%s" (all-the-icons-octicon "repo" :height 1.1 :v-adjust 0.0)))
(t (apply (car matcher) (list (cadr matcher) :v-adjust 0.0))))))
(format "%s%s%s%s%s" padding chevron padding icon padding)))
(defun all-the-icons-reset ()
"Reset (unmemoize/memoize) the icons."
(interactive)
(dolist (f '(all-the-icons-icon-for-file
all-the-icons-icon-for-mode
all-the-icons-icon-for-url
all-the-icons-icon-family-for-file
all-the-icons-icon-family-for-mode
all-the-icons-icon-family))
(ignore-errors
(memoize-restore f)
(memoize f)))
(message "Reset all-the-icons")))
(add-to-list 'all-the-icons-mode-icon-alist
'(bongo-playlist-mode all-the-icons-material "playlist_play" :height 1.2 :v-adjust -0.2 :face 'all-the-icons-green))
(add-to-list 'all-the-icons-mode-icon-alist
'(bongo-library-mode all-the-icons-material "library_music" :height 1.1 :v-adjust -0.2 :face 'all-the-icons-dgreen))
(add-to-list 'all-the-icons-mode-icon-alist
'(gnus-group-mode all-the-icons-fileicon "gnu" :face 'all-the-icons-silver))
(add-to-list 'all-the-icons-mode-icon-alist
'(gnus-summary-mode all-the-icons-octicon "inbox" :height 1.0 :v-adjust 0.0 :face 'all-the-icons-orange))
(add-to-list 'all-the-icons-mode-icon-alist
'(gnus-article-mode all-the-icons-octicon "mail" :height 1.1 :v-adjust 0.0 :face 'all-the-icons-lblue))
(add-to-list 'all-the-icons-mode-icon-alist
'(message-mode all-the-icons-octicon "mail" :height 1.1 :v-adjust 0.0 :face 'all-the-icons-lblue))
(add-to-list 'all-the-icons-mode-icon-alist
'(diff-mode all-the-icons-octicon "git-compare" :v-adjust 0.0 :face all-the-icons-lred))
(add-to-list 'all-the-icons-mode-icon-alist
'(flycheck-error-list-mode all-the-icons-octicon "checklist" :height 1.1 :v-adjust 0.0 :face all-the-icons-lred))
(add-to-list 'all-the-icons-mode-icon-alist
'(elfeed-search-mode all-the-icons-faicon "rss-square" :v-adjust -0.1 :face all-the-icons-orange))
(add-to-list 'all-the-icons-mode-icon-alist
'(elfeed-show-mode all-the-icons-octicon "rss" :height 1.1 :v-adjust 0.0 :face all-the-icons-lorange))
(add-to-list 'all-the-icons-mode-icon-alist
'(newsticker-mode all-the-icons-faicon "rss-square" :v-adjust -0.1 :face all-the-icons-orange))
(add-to-list 'all-the-icons-mode-icon-alist
'(newsticker-treeview-mode all-the-icons-faicon "rss-square" :v-adjust -0.1 :face all-the-icons-orange))
(add-to-list 'all-the-icons-mode-icon-alist
'(newsticker-treeview-list-mode all-the-icons-octicon "rss" :height 1.1 :v-adjust 0.0 :face all-the-icons-orange))
(add-to-list 'all-the-icons-mode-icon-alist
'(newsticker-treeview-item-mode all-the-icons-octicon "rss" :height 1.1 :v-adjust 0.0 :face all-the-icons-lorange))
(add-to-list 'all-the-icons-icon-alist
'("\\.[bB][iI][nN]$" all-the-icons-octicon "file-binary" :v-adjust 0.0 :face all-the-icons-yellow))
(add-to-list 'all-the-icons-icon-alist
'("\\.c?make$" all-the-icons-fileicon "gnu" :face all-the-icons-dorange))
(add-to-list 'all-the-icons-icon-alist
'("\\.conf$" all-the-icons-octicon "settings" :v-adjust 0.0 :face all-the-icons-yellow))
(add-to-list 'all-the-icons-icon-alist
'("\\.toml$" all-the-icons-octicon "settings" :v-adjust 0.0 :face all-the-icons-yellow))
(add-to-list 'all-the-icons-mode-icon-alist
'(conf-mode all-the-icons-octicon "settings" :v-adjust 0.0 :face all-the-icons-yellow))
(add-to-list 'all-the-icons-mode-icon-alist
'(conf-space-mode all-the-icons-octicon "settings" :v-adjust 0.0 :face all-the-icons-yellow))
(add-to-list 'all-the-icons-mode-icon-alist
'(forge-topic-mode all-the-icons-alltheicon "git" :face all-the-icons-blue))
(add-to-list 'all-the-icons-icon-alist
'("\\.xpm$" all-the-icons-octicon "file-media" :v-adjust 0.0 :face all-the-icons-dgreen))
(add-to-list 'all-the-icons-mode-icon-alist
'(help-mode all-the-icons-faicon "info-circle" :height 1.1 :v-adjust -0.1 :face all-the-icons-purple))
(add-to-list 'all-the-icons-mode-icon-alist
'(helpful-mode all-the-icons-faicon "info-circle" :height 1.1 :v-adjust -0.1 :face all-the-icons-purple))
(add-to-list 'all-the-icons-mode-icon-alist
'(Info-mode all-the-icons-faicon "info-circle" :height 1.1 :v-adjust -0.1))
(add-to-list 'all-the-icons-icon-alist
'("NEWS$" all-the-icons-faicon "newspaper-o" :height 0.9 :v-adjust -0.2))
(add-to-list 'all-the-icons-icon-alist
'("Cask\\'" all-the-icons-fileicon "elisp" :height 1.0 :v-adjust -0.2 :face all-the-icons-blue))
(add-to-list 'all-the-icons-mode-icon-alist
'(cask-mode all-the-icons-fileicon "elisp" :height 1.0 :v-adjust -0.2 :face all-the-icons-blue))
(add-to-list 'all-the-icons-icon-alist
'(".*\\.ipynb\\'" all-the-icons-fileicon "jupyter" :height 1.2 :face all-the-icons-orange))
(add-to-list 'all-the-icons-mode-icon-alist
'(ein:notebooklist-mode all-the-icons-faicon "book" :face all-the-icons-lorange))
(add-to-list 'all-the-icons-mode-icon-alist
'(ein:notebook-mode all-the-icons-fileicon "jupyter" :height 1.2 :face all-the-icons-orange))
(add-to-list 'all-the-icons-mode-icon-alist
'(ein:notebook-multilang-mode all-the-icons-fileicon "jupyter" :height 1.2 :face all-the-icons-dorange))
(add-to-list 'all-the-icons-icon-alist
'("\\.epub\\'" all-the-icons-faicon "book" :height 1.0 :v-adjust -0.1 :face all-the-icons-green))
(add-to-list 'all-the-icons-mode-icon-alist
'(nov-mode all-the-icons-faicon "book" :height 1.0 :v-adjust -0.1 :face all-the-icons-green))
(add-to-list 'all-the-icons-mode-icon-alist
'(gfm-mode all-the-icons-octicon "markdown" :face all-the-icons-lblue)))
;; ATIDiredPac
(use-package all-the-icons-dired
:after all-the-icons
:if *sys/gui*
:diminish
:custom-face
(all-the-icons-dired-dir-face ((t `(:foreground ,(face-background 'default)))))
:hook (dired-mode . all-the-icons-dired-mode)
:config
;; Workaround for all-the-icons bug until PR merged https://github.com/domtronn/all-the-icons.el/pull/150
(when (require 'all-the-icons nil 'noerror)
(setq all-the-icons-mode-icon-alist
(delete '(erc-mode all-the-icons-faicon "commenting-o" :height 1.0 :v-adjust 0.0 :face all-the-icons-white) all-the-icons-mode-icon-alist))
(add-to-list 'all-the-icons-mode-icon-alist '(erc-mode all-the-icons-faicon "commenting-o" :height 1.0 :v-adjust 0.0))))
;; -ATIDiredPac
(provide 'init-all-the-icons)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; init-all-the-icons.el ends here