doomemacs/modules/ui/doom/config.el
Henrik Lissner 149b2617b0
💥 revise hook/var fns naming convention (2/2)
This is second of three big naming convention changes. In this commit,
we change the naming conventions for hook functions and variable
functions:

1. Replace the bar | to indicate a hook function with a -h suffix, e.g.

     doom|init-ui -> doom-init-ui-h
     doom|run-local-var-hooks -> doom-run-local-var-hooks-h

2. And add a -fn suffix for functions meant to be set on variables,
   e.g.

     (setq magit-display-buffer-function #'+magit-display-buffer-fn)

See ccf327f8 for the reasoning behind these changes.
2019-07-22 02:30:38 +02:00

98 lines
3.5 KiB
EmacsLisp

;;; ui/doom/config.el -*- lexical-binding: t; -*-
(defvar +doom-solaire-themes
'((doom-city-lights . t)
(doom-dracula . t)
(doom-molokai)
(doom-nord . t)
(doom-nord-light . t)
(doom-nova)
(doom-one . t)
(doom-one-light . t)
(doom-opera . t)
(doom-solarized-light)
(doom-spacegrey)
(doom-vibrant)
(doom-tomorrow-night))
"An alist of themes that support `solaire-mode'. If CDR is t, then use
`solaire-mode-swap-bg'.")
;;
;; Packages
;; <https://github.com/hlissner/emacs-doom-theme>
(def-package! doom-themes
:defer t
:init
(unless doom-theme
(setq doom-theme 'doom-one))
:config
;; improve integration w/ org-mode
(add-hook 'doom-load-theme-hook #'doom-themes-org-config)
;; more Atom-esque file icons for neotree/treemacs
(when (featurep! :ui neotree)
(add-hook 'doom-load-theme-hook #'doom-themes-neotree-config)
(setq doom-neotree-enable-variable-pitch t
doom-neotree-file-icons 'simple
doom-neotree-line-spacing 2))
(when (featurep! :ui treemacs)
(add-hook 'doom-load-theme-hook #'doom-themes-treemacs-config)
(setq doom-treemacs-enable-variable-pitch t)))
(def-package! solaire-mode
:defer t
:init
(add-hook 'doom-load-theme-hook
(defun +doom--solaire-mode-swap-bg-maybe-h ()
(when-let (rule (assq doom-theme +doom-solaire-themes))
(require 'solaire-mode)
(when (cdr rule)
(solaire-mode-swap-bg)
(with-eval-after-load 'ansi-color
(when-let (color (face-background 'default))
(setf (aref ansi-color-names-vector 0) color))))))
'append)
:config
;; fringe can become unstyled when deleting or focusing frames
(add-hook 'focus-in-hook #'solaire-mode-reset)
;; Prevent color glitches when reloading either DOOM or loading a new theme
(add-hook! :append '(doom-load-theme-hook doom-reload-hook)
#'solaire-mode-reset)
;; org-capture takes an org buffer and narrows it. The result is erroneously
;; considered an unreal buffer, so solaire-mode must be restored.
(add-hook 'org-capture-mode-hook #'turn-on-solaire-mode)
;; On Emacs 26+, when point is on the last line and solaire-mode is remapping
;; the hl-line face, hl-line's highlight bleeds into the rest of the window
;; after eob.
(when EMACS26+
(defun +doom--line-range-fn ()
(cons (line-beginning-position)
(cond ((let ((eol (line-end-position)))
(and (= eol (point-max))
(/= eol (line-beginning-position))))
(1- (line-end-position)))
((or (eobp)
(= (line-end-position 2) (point-max)))
(line-end-position))
((line-beginning-position 2)))))
(setq hl-line-range-function #'+doom--line-range-fn))
;; Because fringes can't be given a buffer-local face, they can look odd, so
;; we remove them in the minibuffer and which-key popups (they serve no
;; purpose there anyway).
(add-hook 'solaire-mode-hook
(defun +doom-disable-fringes-in-minibuffer-h (&rest _)
(set-window-fringes (minibuffer-window) 0 0 nil)))
(def-advice! +doom--no-fringes-in-which-key-buffer-a (&rest _)
:after 'which-key--show-buffer-side-window
(+doom-disable-fringes-in-minibuffer-h)
(set-window-fringes (get-buffer-window which-key--buffer) 0 0 nil))
(add-hook! '(minibuffer-setup-hook window-configuration-change-hook)
#'+doom-disable-fringes-in-minibuffer-h)
(solaire-global-mode +1))