doomemacs/modules/ui/doom/config.el

157 lines
5.2 KiB
EmacsLisp
Raw Normal View History

2017-02-03 19:44:14 -05:00
;;; ui/doom/config.el
2017-01-17 00:20:59 -05:00
(defvar +doom-theme 'doom-one
"The color theme to use.")
2017-01-17 00:20:59 -05:00
2017-01-31 05:09:20 -05:00
(defvar +doom-font
(font-spec :family "Fira Mono" :size 12)
"The font currently in use.")
2017-01-17 00:20:59 -05:00
2017-01-31 05:09:20 -05:00
(defvar +doom-variable-pitch-font
(font-spec :family "Fira Sans" :size 13)
2017-01-31 05:09:20 -05:00
"The font currently in use.")
2017-01-17 00:20:59 -05:00
2017-01-31 05:09:20 -05:00
(defvar +doom-unicode-font
(font-spec :family "DejaVu Sans Mono" :size 12)
"Fallback font for unicode glyphs.")
2017-01-17 00:20:59 -05:00
2017-02-03 19:44:14 -05:00
2017-01-31 05:09:20 -05:00
;;; Set fonts
(when (display-graphic-p)
(with-demoted-errors "FONT ERROR: %s"
(set-frame-font +doom-font t t)
;; Fallback to `doom-unicode-font' for Unicode characters
(when +doom-unicode-font
(set-fontset-font t 'unicode +doom-unicode-font))
;; ...and for variable-pitch mode
(when +doom-variable-pitch-font
(set-face-attribute 'variable-pitch nil :font +doom-variable-pitch-font))))
;;; More reliable inter-window border
2017-02-03 19:44:14 -05:00
;; The native border "consumes" a pixel of the fringe on righter-most splits,
;; `window-divider' does not. Available since Emacs 25.1.
2017-01-31 05:09:20 -05:00
(setq window-divider-default-places t
2017-05-01 14:52:29 -04:00
window-divider-default-bottom-width 0
2017-01-31 05:09:20 -05:00
window-divider-default-right-width 1)
(window-divider-mode +1)
2017-02-19 18:52:26 -05:00
;; doom-one: gives Emacs a look inspired by Dark One in Atom.
2017-01-31 05:09:20 -05:00
;; <https://github.com/hlissner/emacs-doom-theme>
(def-package! doom-themes :demand t
2017-02-03 19:44:14 -05:00
:config
2017-01-17 00:20:59 -05:00
(load-theme +doom-theme t)
;; Since Fira Mono doesn't have an italicized variant, highlight it instead
(set-face-attribute 'italic nil
:weight 'ultra-light
:foreground "#ffffff"
:background (face-background 'doom-hl-line))
2017-02-20 00:10:10 -05:00
(defface +doom-folded-face
`((((background dark))
(:inherit font-lock-comment-face :background ,(doom-color 'black)))
(((background light))
(:inherit font-lock-comment-face :background ,(doom-color 'light-grey))))
2017-02-20 00:10:10 -05:00
"Face to hightlight `hideshow' overlays."
:group 'doom)
2017-02-21 16:04:35 -05:00
;; Dark frames by default
2017-04-22 01:49:15 -04:00
(when (display-graphic-p)
(push (cons 'background-color (face-background 'default)) default-frame-alist)
(push (cons 'foreground-color (face-foreground 'default)) default-frame-alist))
2017-02-19 18:52:26 -05:00
(defun +doom|buffer-mode-on ()
2017-03-15 22:42:05 -04:00
"Enable `doom-buffer-mode' in buffers that are real (see
`doom-real-buffer-p')."
(when (and (not doom-buffer-mode)
(doom-real-buffer-p))
2017-02-19 18:52:26 -05:00
(doom-buffer-mode +1)))
(add-hook 'after-change-major-mode-hook #'+doom|buffer-mode-on)
2017-02-19 18:52:26 -05:00
(defun +doom|buffer-mode-off ()
2017-03-15 22:42:05 -04:00
"Disable `doom-buffer-mode' in popup buffers."
(when doom-buffer-mode
(doom-buffer-mode -1)))
(add-hook 'doom-popup-mode-hook #'+doom|buffer-mode-off)
2017-02-19 18:52:26 -05:00
(when (featurep! :feature workspaces)
(defun +doom|restore-bright-buffers (&rest _)
2017-02-19 18:52:26 -05:00
"Restore `doom-buffer-mode' in buffers when `persp-mode' loads a session."
(dolist (buf (persp-buffer-list))
(with-current-buffer buf
(+doom|buffer-mode-on))))
(add-hook '+workspaces-load-session-hook #'+doom|restore-bright-buffers))
2017-01-17 00:20:59 -05:00
2017-01-31 05:09:20 -05:00
;; Add file icons to doom-neotree
(doom-themes-neotree-config)
2017-01-31 05:09:20 -05:00
(setq doom-neotree-enable-variable-pitch t
doom-neotree-file-icons 'simple
2017-05-13 22:39:50 +02:00
doom-neotree-line-spacing 2))
2017-01-31 05:09:20 -05:00
2017-03-15 22:00:03 -04:00
;; Flashes the line around the cursor after any motion command that might
;; reasonably send the cursor somewhere the eyes can't follow. Tremendously
;; helpful on a 30" 2560x1600 display.
(def-package! nav-flash
:commands nav-flash-show
:init
(defun doom*blink-cursor-maybe (orig-fn &rest args)
2017-03-15 22:00:03 -04:00
"Blink line, to keep track of the cursor."
(interactive)
(let ((point (point-marker)))
(apply orig-fn args)
(unless (equal point (point-marker))
(doom/blink-cursor))))
(defun doom/blink-cursor (&rest _)
(unless (minibufferp)
(nav-flash-show)
;; only show in the current window
(overlay-put compilation-highlight-overlay 'window (selected-window))))
2017-03-15 22:00:03 -04:00
(add-hook!
'(imenu-after-jump-hook evil-jumps-post-jump-hook find-file-hook)
#'doom/blink-cursor)
2017-03-15 22:00:03 -04:00
(advice-add #'windmove-do-window-select :around #'doom*blink-cursor-maybe)
(advice-add #'recenter :after #'doom/blink-cursor)
2017-03-15 22:00:03 -04:00
(after! evil
(dolist (fn '(evil-window-bottom evil-window-middle evil-window-top))
(advice-add fn :around #'doom*blink-cursor-maybe))))
(after! hideshow
2017-02-19 18:52:26 -05:00
;; Nicer code-folding overlays
2017-01-31 05:09:20 -05:00
(setq hs-set-up-overlay
(lambda (ov)
(when (eq 'code (overlay-get ov 'hs))
2017-05-15 20:20:06 +02:00
(when (featurep 'vimish-fold)
(overlay-put
ov 'before-string
(propertize "" 'display
(list vimish-fold-indication-mode
'empty-line
'vimish-fold-fringe))))
2017-01-31 05:09:20 -05:00
(overlay-put
2017-02-20 00:10:10 -05:00
ov 'display (propertize " [...] " 'face '+doom-folded-face))))))
2017-01-31 05:09:20 -05:00
2017-02-19 18:39:54 -05:00
;; subtle diff indicators in the fringe
(when (display-graphic-p)
(after! git-gutter-fringe
;; places the git gutter outside the margins.
(setq-default fringes-outside-margins t)
;; thin fringe bitmaps
(fringe-helper-define 'git-gutter-fr:added '(center repeated)
"XXX.....")
(fringe-helper-define 'git-gutter-fr:modified '(center repeated)
"XXX.....")
(fringe-helper-define 'git-gutter-fr:deleted 'bottom
"X......."
"XX......"
"XXX....."
"XXXX....")))