feat(theme): improve doom-themes overrides by using a proper theme

Instead of manually just setting faces after loading a doom-themes
theme, let's use a custom override theme which we apply right after
applying any doom-themes theme.

The override theme uses various doom-color helpers, so the colors it
uses will be based on the most recently applied doom-themes theme.
This commit is contained in:
2021-04-07 23:05:16 +01:00
parent 4e50263ded
commit 5f4aa98abd
5 changed files with 142 additions and 129 deletions

View File

@@ -60,6 +60,9 @@
(setq custom-file (expand-file-name "custom.el" siren-dir))
(load-file custom-file)
;; Enable custom themes
(require 'siren-core-themes)
;; The modules
(require 'siren-core-modules)

View File

@@ -10,14 +10,14 @@
"Root directory for Emacs Siren modules.")
(siren-recursive-add-to-load-path siren-modules-dir)
;; Theme
(require 'siren-doom-themes)
;; Core
(require 'siren-aliases)
(require 'siren-global-keybindings)
(require 'siren-packages)
;; Theme
(require 'siren-doom-themes)
;; Completion
(require 'siren-company)

14
core/siren-core-themes.el Normal file
View File

@@ -0,0 +1,14 @@
;;; siren-core-themes.el --- jimeh's Emacs Siren: Custom themes.
;;; Commentary:
;; Enable loading custom themes.
;;; Code:
(defvar siren-themes-dir (expand-file-name "themes" siren-dir)
"Root directory for Emacs Siren custom themes.")
(add-to-list 'custom-theme-load-path siren-themes-dir)
(provide 'siren-core-themes)
;;; siren-core-themes.el ends here

View File

@@ -47,11 +47,20 @@
(interactive (list (completing-read "Choose theme: "
(siren-doom-themes-list))))
;; disable all themes
(dolist (theme custom-enabled-themes)
(when (not (string= theme "use-package"))
(disable-theme theme)))
;; load doom theme
(load-theme (if (string= (type-of theme) "string") (intern theme) theme) t)
(siren-doom-themes-overrides))
;; load overrides theme: ../../themes/siren-doom-themes-overrides-theme.el
(load-theme 'siren-doom-themes-overrides t)
;; execute custom function after loading/switching theme
(with-eval-after-load 'highlight-indent-guides
(highlight-indent-guides-auto-set-faces)))
(defun siren-doom-themes-vibrant-theme ()
(interactive)
@@ -64,131 +73,7 @@
(defun siren-doom-themes-list ()
(seq-filter
(lambda (n) (string-prefix-p "doom-" (symbol-name n)))
(custom-available-themes)))
(defun siren-doom-themes-overrides ()
(interactive)
;; Override some of doom-vibrant's colors.
(set-face-attribute 'font-lock-variable-name-face nil
:foreground (doom-lighten 'blue 0.25))
(set-face-attribute 'vertical-border nil
:foreground (doom-darken 'vertical-bar 0.3)
:background (doom-darken 'vertical-bar 0.3))
(set-face-attribute 'font-lock-comment-face nil
:foreground (doom-lighten 'comments 0.15))
(when (not (version< emacs-version "27.0"))
(set-face-attribute 'fill-column-indicator nil
:foreground (doom-lighten 'base3 0.10)))
(with-eval-after-load 'diff-hl
(set-face-attribute 'diff-hl-insert nil
:foreground (doom-blend 'vc-added 'bg 0.7)
:background (doom-blend 'vc-added 'bg 0.2))
(set-face-attribute 'diff-hl-delete nil
:foreground (doom-blend 'vc-deleted 'bg 0.7)
:background (doom-blend 'vc-deleted 'bg 0.2))
(set-face-attribute 'diff-hl-change nil
:foreground (doom-blend 'vc-modified 'bg 0.7)
:background (doom-blend 'vc-modified 'bg 0.2))
(set-face-attribute 'siren-diff-hl-insert nil
:foreground (doom-blend 'vc-added 'bg 0.7)
:background (doom-color 'bg))
(set-face-attribute 'siren-diff-hl-delete nil
:foreground (doom-blend 'vc-deleted 'bg 0.7)
:background (doom-color 'bg))
(set-face-attribute 'siren-diff-hl-change nil
:foreground (doom-blend 'vc-modified 'bg 0.7)
:background (doom-color 'bg)))
(with-eval-after-load 'diff-hl-margin
(set-face-attribute 'diff-hl-margin-insert nil
:foreground (doom-blend 'vc-added 'bg 0.6)
:background (doom-blend 'vc-added 'bg 0.1))
(set-face-attribute 'diff-hl-margin-delete nil
:foreground (doom-blend 'vc-deleted 'bg 0.7)
:background (doom-blend 'vc-deleted 'bg 0.1))
(set-face-attribute 'diff-hl-margin-change nil
:foreground (doom-blend 'vc-modified 'bg 0.5)
:background (doom-blend 'vc-modified 'bg 0.1)))
(with-eval-after-load 'git-gutter
(set-face-attribute 'git-gutter:added nil
:foreground (doom-blend 'vc-added 'bg 0.9))
(set-face-attribute 'git-gutter:deleted nil
:foreground (doom-blend 'vc-deleted 'bg 0.9))
(set-face-attribute 'git-gutter:modified nil
:foreground (doom-blend 'vc-modified 'bg 0.7)))
(with-eval-after-load 'git-gutter-fringe
(set-face-attribute 'git-gutter-fr:added nil
:foreground (doom-blend 'vc-added 'bg 0.7)
:background (doom-blend 'vc-added 'bg 0.0))
(set-face-attribute 'git-gutter-fr:deleted nil
:foreground (doom-blend 'vc-deleted 'bg 0.7)
:background (doom-blend 'vc-deleted 'bg 0.0))
(set-face-attribute 'git-gutter-fr:modified nil
:foreground (doom-blend 'vc-modified 'bg 0.7)
:background (doom-blend 'vc-modified 'bg 0.0)))
(with-eval-after-load 'hideshowvis
(set-face-attribute 'hideshowvis-hidable-face nil
:foreground (doom-color 'base7)))
(with-eval-after-load 'auto-highlight-symbol
(set-face-attribute 'ahs-definition-face nil
:foreground 'unspecified
:background (doom-lighten 'bg 0.1)
:underline t)
(set-face-attribute 'ahs-edit-mode-face nil
:foreground (doom-lighten 'fg 1.0)
:background (doom-darken 'red 0.25))
(set-face-attribute 'ahs-face nil
:foreground 'unspecified
:background (doom-lighten 'bg 0.1))
(set-face-attribute 'ahs-plugin-bod-face nil
:foreground 'unspecified
:background (doom-color 'bg-alt))
(set-face-attribute 'ahs-plugin-defalt-face nil
:foreground 'unspecified
:background (doom-color 'bg-alt))
(set-face-attribute 'ahs-plugin-whole-buffer-face nil
:foreground 'unspecified
:background (doom-color 'bg-alt))
(set-face-attribute 'ahs-warning-face nil
:foreground (doom-color 'red)
:background 'unspecified))
(with-eval-after-load 'dired+
(set-face-attribute 'diredp-dir-heading nil
:weight 'bold
:foreground (doom-color 'magenta))
(set-face-attribute 'diredp-dir-name nil
:weight 'bold
:foreground (doom-lighten 'magenta 0.25))
(set-face-attribute 'diredp-flag-mark nil
:foreground (doom-color 'green)
:background (doom-blend 'bg 'orange 0.5))
(set-face-attribute 'diredp-flag-mark-line nil
:foreground (doom-color 'base8)
:background (doom-blend 'bg 'orange 0.7))
(set-face-attribute 'diredp-deletion nil
:foreground (doom-color 'yellow)
:background (doom-darken 'red 0.25))
(set-face-attribute 'diredp-deletion-file-name nil
:foreground (doom-color 'red))
(set-face-attribute 'diredp-compressed-file-name nil
:foreground (doom-color 'blue)))
(with-eval-after-load 'highlight-indent-guides
(highlight-indent-guides-auto-set-faces))
(with-eval-after-load 'zoom-window
(setq zoom-window-mode-line-color (doom-blend 'magenta 'bg 0.2)))
(with-eval-after-load 'fill-column-indicator
(setq fci-rule-color (doom-lighten (doom-color 'base3) 0.10)))))
(custom-available-themes))))
(provide 'siren-doom-themes)
;;; siren-doom-themes.el ends here

View File

@@ -0,0 +1,111 @@
;;; siren-doom-themes-theme.el --- jimeh's Emacs Siren: doom-themes.
;;; Commentary:
;; Custom overrides for doom-themes.
;;
;; This theme is only to be used as a secondary theme applied after applying a
;; theme from the doom-themes package. It adds customizations for a few things
;; not covered by doom-themes, and also customizes a number of minor things more
;; to my liking.
;;; Code:
(deftheme siren-doom-themes-overrides
"Siren overrides for doom-themes.")
(custom-theme-set-faces
'siren-doom-themes-overrides
`(font-lock-variable-name-face ((t (:foreground ,(doom-lighten 'blue 0.25)))))
`(vertical-border ((t ( :foreground ,(doom-darken 'vertical-bar 0.3)
:background ,(doom-darken 'vertical-bar 0.3) ))))
`(font-lock-comment-face ((t ( :foreground ,(doom-lighten 'comments 0.15) ))))
;; fill-column-indicator
`(fill-column-indicator ((t ( :foreground ,(doom-lighten 'base3 0.10) ))))
;; diff-hl
`(diff-hl-insert ((t ( :foreground ,(doom-blend 'vc-added 'bg 0.7)
:background ,(doom-blend 'vc-added 'bg 0.2)))))
`(diff-hl-delete ((t ( :foreground ,(doom-blend 'vc-deleted 'bg 0.7)
:background ,(doom-blend 'vc-deleted 'bg 0.2)))))
`(diff-hl-change ((t ( :foreground ,(doom-blend 'vc-modified 'bg 0.7)
:background ,(doom-blend 'vc-modified 'bg 0.2)))))
`(siren-diff-hl-insert ((t ( :foreground ,(doom-blend 'vc-added 'bg 0.7)
:background ,(doom-color 'bg)))))
`(siren-diff-hl-delete ((t ( :foreground ,(doom-blend 'vc-deleted 'bg 0.7)
:background ,(doom-color 'bg)))))
`(siren-diff-hl-change ((t ( :foreground ,(doom-blend 'vc-modified 'bg 0.7)
:background ,(doom-color 'bg)))))
;; diff-hl-margin
`(diff-hl-margin-insert ((t ( :foreground ,(doom-blend 'vc-added 'bg 0.6)
:background ,(doom-blend 'vc-added 'bg 0.1) ))))
`(diff-hl-margin-delete ((t ( :foreground ,(doom-blend 'vc-deleted 'bg 0.7)
:background
,(doom-blend 'vc-deleted 'bg 0.1) ))))
`(diff-hl-margin-change ((t ( :foreground ,(doom-blend 'vc-modified 'bg 0.5)
:background
,(doom-blend 'vc-modified 'bg 0.1) ))))
;; git-gutter
`(git-gutter:added ((t ( :foreground ,(doom-blend 'vc-added 'bg 0.9) ))))
`(git-gutter:deleted ((t ( :foreground ,(doom-blend 'vc-deleted 'bg 0.9) ))))
`(git-gutter:modified ((t ( :foreground ,(doom-blend 'vc-modified 'bg 0.7) ))))
;; git-gutter-fringe
`(git-gutter-fr:added ((t ( :foreground ,(doom-blend 'vc-added 'bg 0.7)
:background ,(doom-blend 'vc-added 'bg 0.0) ))))
`(git-gutter-fr:deleted ((t ( :foreground ,(doom-blend 'vc-deleted 'bg 0.7)
:background
,(doom-blend 'vc-deleted 'bg 0.0) ))))
`(git-gutter-fr:modified ((t ( :foreground ,(doom-blend 'vc-modified 'bg 0.7)
:background
,(doom-blend 'vc-modified 'bg 0.0) ))))
;; hideshowvis
`(hideshowvis-hidable-face ((t ( :foreground ,(doom-color 'base7) ))))
;; auto-highlight-symbol
`(ahs-definition-face ((t ( :foreground 'unspecified
:background ,(doom-lighten 'bg 0.1)
:underline t ))))
`(ahs-edit-mode-face ((t ( :foreground ,(doom-lighten 'fg 1.0)
:background ,(doom-darken 'red 0.25) ))))
`(ahs-face ((t ( :foreground 'unspecified
:background ,(doom-lighten 'bg 0.1) ))))
`(ahs-plugin-bod-face ((t ( :foreground 'unspecified
:background ,(doom-color 'bg-alt) ))))
`(ahs-plugin-defalt-face ((t ( :foreground 'unspecified
:background ,(doom-color 'bg-alt) ))))
`(ahs-plugin-whole-buffer-face ((t ( :foreground 'unspecified
:background ,(doom-color 'bg-alt) ))))
`(ahs-warning-face ((t ( :foreground ,(doom-color 'red)
:background 'unspecified ))))
;; dired+
`(diredp-dir-heading ((t ( ;; :weight 'bold
:foreground ,(doom-color 'magenta) ))))
`(diredp-dir-name ((t ( ;; :weight 'bold
:foreground ,(doom-lighten 'magenta 0.25) ))))
`(diredp-flag-mark ((t ( :foreground ,(doom-color 'green)
:background ,(doom-blend 'bg 'orange 0.5) ))))
`(diredp-flag-mark-line ((t ( :foreground ,(doom-color 'base8)
:background ,(doom-blend 'bg 'orange 0.7) ))))
`(diredp-deletion ((t ( :foreground ,(doom-color 'yellow)
:background ,(doom-darken 'red 0.25) ))))
`(diredp-deletion-file-name ((t ( :foreground ,(doom-color 'red) ))))
`(diredp-compressed-file-name ((t ( :foreground ,(doom-color 'blue) )))))
(custom-theme-set-variables
'siren-doom-themes-overrides
;; fill-column-indicator
`(fci-rule-color ,(doom-lighten 'base3 0.10))
;; zoom-window
`(zoom-window-mode-line-color ,(doom-blend 'magenta 'bg 0.2)))
(provide-theme 'siren-doom-themes-overrides)