doomemacs/core/core-ui.el

199 lines
7.2 KiB
EmacsLisp
Raw Normal View History

2016-05-08 09:57:43 +08:00
;;; core-ui.el --- interface & mode-line config
2015-06-15 15:05:52 +08:00
2016-05-25 10:15:44 +08:00
(defconst doom-fringe-size '3 "Default fringe width")
2016-05-24 05:13:59 +08:00
2016-05-20 21:23:46 +08:00
;; y/n instead of yes/no
(fset 'yes-or-no-p 'y-or-n-p)
2015-06-05 06:23:21 +08:00
(setq-default
2016-05-24 05:13:59 +08:00
indicate-buffer-boundaries nil ; don't show where buffer starts/ends
2016-05-25 10:15:44 +08:00
indicate-empty-lines nil ; don't show empty lines
2016-05-24 05:13:59 +08:00
fringes-outside-margins t ; switches order of fringe and margin
2016-05-08 09:57:43 +08:00
;; Keep cursors and highlights in current window only
cursor-in-non-selected-windows nil
2016-04-09 04:15:37 +08:00
highlight-nonselected-windows nil
2016-05-24 05:13:59 +08:00
;; Disable bidirectional text support for slight performance bonus
bidi-display-reordering nil
;; Remove continuation arrow on right fringe
fringe-indicator-alist (delq (assq 'continuation fringe-indicator-alist)
fringe-indicator-alist)
2016-04-09 04:15:37 +08:00
2016-05-24 05:13:59 +08:00
blink-matching-paren nil ; don't blink--too distracting
show-paren-delay 0.075
uniquify-buffer-name-style nil
2016-04-09 04:15:37 +08:00
visible-bell nil
visible-cursor nil
x-stretch-cursor t
use-dialog-box nil ; always avoid GUI
redisplay-dont-pause t ; don't pause display on input
split-width-threshold nil ; favor horizontal splits
show-help-function nil ; hide :help-echo text
2016-04-26 14:00:19 +08:00
jit-lock-defer-time nil
2016-04-09 04:15:37 +08:00
jit-lock-stealth-nice 0.1
jit-lock-stealth-time 0.2
jit-lock-stealth-verbose nil
NARF v0.7.0 vcs: + +git-gutter to conf-modes; -git-gutter from evil-insert-state-exit + switch github-browse-file for browse-at-remote + fix <leader>ob; add <leader>d[./sr] vc bindings + vc-annotate bindings and initial state Workgroups2 integration: + don't mess with buffers (speeds up emacs a lot!) + unicode numbers in display + single display function + remember workgroup uid instead (and smarter :tabrename) + clean up after wg update Org-mode + give highlight precedence to links in org-mode + enable encryption + config clean up + use different font for org + exclude attachments in recentf + redo latex and inline-image config + add narf/org-open-notes + update file templates for org CRM Mode-line + polish mode-line + decouple from spaceline-segments.el + refactor narf|spaceline-env-update + add macro-recording and buffer-size indicators to mode-line + python: '2>&1' in env-command + flycheck fringe indicator: change to arrow Aesthetics + update narf-dark-theme + add narf-minibuffer-active face + change writing indicator in writing-mode Misc + fix whitespace in display-startup-echo-area-message + reset fonts for more unicode characters + custom imenu entries + helm-imenu fontification + enable yascroll-bar in REPLs + reorganize my-commands.el + force quit iedit on ESC in normal mode + update snippets submodule + remove ido init (helm handles it all) [EXPERIMENTAL] + back to Terminus(TTF) font + popwin: update config for git-gutter and vc-diff windows + highlight :g[lobal] and :al[ign] matches + decouple narf/get-buffers+narf/get-all-buffers from wg-mess-with-buffer-list + fix narf/helm-buffers-dwim (add interactive form)
2015-12-12 05:51:04 +08:00
;; Minibuffer resizing
2016-05-01 13:05:25 +08:00
resize-mini-windows 'grow-only
max-mini-window-height 0.3
2016-05-24 05:13:59 +08:00
;; Ask for confirmation on exit only if there are real buffers left
confirm-kill-emacs
(lambda (_) (if (doom/get-real-buffers) (y-or-n-p " Quit?") t) t))
2016-05-24 05:13:59 +08:00
;; Initialize UI
2016-05-20 21:23:46 +08:00
(tooltip-mode -1) ; show tooltips in echo area
(if (not window-system)
2016-03-04 04:04:14 +08:00
(menu-bar-mode -1)
2016-03-26 13:19:31 +08:00
(scroll-bar-mode -1) ; no scrollbar
(tool-bar-mode -1) ; no toolbar
2016-03-30 11:48:06 +08:00
;; full filename in frame title
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
2016-09-12 22:34:29 +08:00
;; set font
(with-demoted-errors "FONT ERROR: %s"
2016-08-21 22:48:09 +08:00
(set-frame-font doom-default-font t)
(set-face-attribute 'default t :font doom-current-font))
2016-05-21 12:13:50 +08:00
;; standardize fringe width
2016-05-25 10:15:44 +08:00
(fringe-mode doom-fringe-size)
2016-05-21 12:13:50 +08:00
(push `(left-fringe . ,doom-fringe-size) default-frame-alist)
(push `(right-fringe . ,doom-fringe-size) default-frame-alist)
2016-09-12 22:34:29 +08:00
;; default frame size on startup
2016-05-21 12:13:50 +08:00
(push '(width . 120) default-frame-alist)
2016-05-31 09:19:10 +08:00
(push '(height . 40) default-frame-alist)
2016-05-21 05:19:59 +08:00
;; no fringe in the minibuffer
2016-05-24 05:13:59 +08:00
(add-hook! (emacs-startup minibuffer-setup)
(set-window-fringes (minibuffer-window) 0 0 nil))
2016-03-30 11:48:06 +08:00
;; Show tilde in margin on empty lines
2016-03-04 04:04:14 +08:00
(define-fringe-bitmap 'tilde [64 168 16] nil nil 'center)
2016-05-21 05:19:59 +08:00
(set-fringe-bitmap-face 'tilde 'fringe)
2016-05-24 08:56:19 +08:00
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
2016-06-06 11:03:47 +08:00
;; Fallback to `doom-unicode-font' for Unicode characters
(set-fontset-font t 'unicode doom-unicode-font))
2015-11-14 15:35:15 +08:00
2016-05-24 08:56:19 +08:00
;; Hide mode-line in help/compile window
(add-hook 'help-mode-hook 'doom-hide-mode-line-mode)
(add-hook 'compilation-mode-hook 'doom-hide-mode-line-mode)
2016-03-04 04:04:14 +08:00
2016-05-24 05:13:59 +08:00
;; On by default in Emacs 25. I'll enable it manually, so disable it globally
(when (and (> emacs-major-version 24) (featurep 'eldoc))
2016-01-31 10:16:10 +08:00
(global-eldoc-mode -1))
2015-11-11 07:01:57 +08:00
2016-03-04 04:04:14 +08:00
;; Highlight TODO/FIXME/NOTE tags
(add-hook! (prog-mode emacs-lisp-mode css-mode)
2016-04-26 14:00:19 +08:00
(font-lock-add-keywords
2016-05-24 05:14:37 +08:00
nil '(("\\<\\(TODO\\(?:(.*)\\)?:?\\)\\>" 1 'warning prepend)
("\\<\\(FIXME\\(?:(.*)\\)?:?\\)\\>" 1 'error prepend)
("\\<\\(NOTE\\(?:(.*)\\)?:?\\)\\>" 1 'success prepend))))
2015-06-05 06:23:21 +08:00
2016-03-04 04:04:14 +08:00
;;
;; Plugins
;;
2016-09-19 23:38:10 +08:00
;; The native vertical border "consumes" a pixel of the fringe area on
;; righter-most window splits in emacs-mac. `window-divider-mode' does not.
(when (boundp 'window-divider-mode)
(window-divider-mode +1)
(setq window-divider-default-places 'right-only
window-divider-default-bottom-width 1
window-divider-default-right-width 1))
2016-09-15 07:50:49 +08:00
(use-package doom-themes
2016-09-07 23:16:13 +08:00
:config
2016-09-15 07:50:49 +08:00
(load-theme doom-current-theme t)
(require 'doom-neotree)
(add-hook 'minibuffer-setup-hook 'doom-brighten-minibuffer)
(add-hook 'find-file-hook 'doom-buffer-mode))
2016-09-07 23:16:13 +08:00
2016-08-29 04:08:48 +08:00
(use-package beacon
:config
(beacon-mode +1)
(setq beacon-color (face-attribute 'highlight :background nil t)
beacon-blink-when-buffer-changes t
beacon-blink-when-point-moves-vertically 10))
2016-05-01 13:05:25 +08:00
(use-package hl-line
2016-08-29 04:54:48 +08:00
:init (add-hook 'prog-mode-hook 'hl-line-mode)
2016-05-01 13:05:25 +08:00
:config
2016-06-05 12:56:28 +08:00
;; Doesn't seem to play nice in emacs 25+
2016-06-09 02:43:40 +08:00
(setq hl-line-sticky-flag nil
global-hl-line-sticky-flag nil)
2016-05-01 13:05:25 +08:00
2016-06-05 12:56:28 +08:00
(defvar-local doom--hl-line-mode nil)
2016-05-21 10:37:30 +08:00
(defun doom|hl-line-on () (if doom--hl-line-mode (hl-line-mode +1)))
(defun doom|hl-line-off () (if doom--hl-line-mode (hl-line-mode -1)))
(add-hook! hl-line-mode (if hl-line-mode (setq doom--hl-line-mode t)))
2016-05-01 13:05:25 +08:00
;; Disable line highlight in visual mode
2016-05-21 10:37:30 +08:00
(add-hook 'evil-visual-state-entry-hook 'doom|hl-line-off)
(add-hook 'evil-visual-state-exit-hook 'doom|hl-line-on))
2016-05-01 13:05:25 +08:00
2016-04-12 14:59:36 +08:00
(use-package highlight-indentation
:commands (highlight-indentation-mode
highlight-indentation-current-column-mode)
2016-04-12 14:59:36 +08:00
:init
(after! editorconfig
(advice-add 'highlight-indentation-guess-offset
2016-05-21 10:37:30 +08:00
:override 'doom*hl-indent-guess-offset))
2016-04-12 14:59:36 +08:00
;; A long-winded method for ensuring whitespace is maintained (so that
;; highlight-indentation-mode can display them consistently)
(add-hook! highlight-indentation-mode
(if highlight-indentation-mode
(progn
2016-05-21 10:37:30 +08:00
(doom/add-whitespace)
(add-hook 'after-save-hook 'doom/add-whitespace nil t))
2016-05-21 10:37:30 +08:00
(remove-hook 'after-save-hook 'doom/add-whitespace t)
(delete-trailing-whitespace))))
2016-04-12 14:59:36 +08:00
(use-package highlight-numbers :commands (highlight-numbers-mode))
2015-10-26 13:29:38 +08:00
(use-package nlinum
2015-10-28 15:31:51 +08:00
:commands nlinum-mode
2015-06-06 18:40:33 +08:00
:preface
(setq linum-format "%3d ")
(defvar nlinum-format "%4d ")
2016-05-21 10:37:30 +08:00
(defvar doom--hl-nlinum-overlay nil)
(defvar doom--hl-nlinum-line nil)
2015-11-10 04:52:42 +08:00
:init
2015-11-11 07:01:57 +08:00
(add-hook!
(markdown-mode prog-mode scss-mode web-mode conf-mode groovy-mode
nxml-mode snippet-mode php-mode)
2016-05-01 11:13:39 +08:00
'nlinum-mode)
2016-08-29 04:54:48 +08:00
;; FIXME This only works if hl-line is active!
(add-hook! nlinum-mode
2016-05-27 06:51:39 +08:00
(if nlinum-mode-hook
(add-hook 'post-command-hook 'doom|nlinum-hl-line nil t)
(remove-hook 'post-command-hook 'doom|nlinum-hl-line t)))
2015-10-03 16:56:33 +08:00
:config
2016-05-25 10:50:39 +08:00
;; Calculate line number column width
2015-06-15 15:05:52 +08:00
(add-hook! nlinum-mode
2016-05-24 05:13:59 +08:00
(setq nlinum--width (length (save-excursion (goto-char (point-max))
2016-05-25 10:50:39 +08:00
(format-mode-line "%l")))))
2016-08-29 04:54:48 +08:00
2016-05-25 10:50:39 +08:00
;; Disable nlinum when making frames, otherwise we get linum face error
;; messages that prevent frame creation.
(add-hook 'before-make-frame-hook 'doom|nlinum-disable)
(add-hook 'after-make-frame-functions 'doom|nlinum-enable))
2015-10-26 13:29:38 +08:00
2016-08-29 04:54:48 +08:00
(use-package rainbow-delimiters
:commands rainbow-delimiters-mode
:config (setq rainbow-delimiters-max-face-count 3)
:init
(add-hook! (emacs-lisp-mode lisp-mode js-mode css-mode c-mode-common)
'rainbow-delimiters-mode))
;; NOTE hl-line-mode and rainbow-mode don't play well together
(use-package rainbow-mode
:commands rainbow-mode
:init (after! hl-line (add-hook 'rainbow-mode-hook 'doom|hl-line-off)))
(use-package stripe-buffer
:commands stripe-buffer-mode
:init (add-hook 'dired-mode-hook 'stripe-buffer-mode))
(use-package visual-fill-column :defer t
:config
(setq-default visual-fill-column-center-text nil
visual-fill-column-width fill-column
split-window-preferred-function 'visual-line-mode-split-window-sensibly))
2015-06-05 06:23:21 +08:00
(provide 'core-ui)
;;; core-ui.el ends here