Finish core-ui.el
This commit is contained in:
parent
a02f1bec22
commit
b6d1d61496
1 changed files with 68 additions and 190 deletions
258
core/core-ui.el
258
core/core-ui.el
|
@ -1,27 +1,11 @@
|
||||||
;; core-ui.el --- draw me like one of your French editors
|
;; core-ui.el --- draw me like one of your French editors
|
||||||
|
|
||||||
(defvar doom-ui-fringe-size '3
|
(defvar doom-ui-fringe-size '3 "Default fringe width")
|
||||||
"Default fringe width")
|
|
||||||
|
|
||||||
(defvar doom-ui-theme 'doom-one
|
|
||||||
"The color theme currently in use.")
|
|
||||||
|
|
||||||
(defvar doom-ui-font
|
|
||||||
(font-spec :family "Fira Mono" :size 12)
|
|
||||||
"The font currently in use.")
|
|
||||||
|
|
||||||
(defvar doom-ui-variable-pitch-font
|
|
||||||
(font-spec :family "Fira Sans" :size 12)
|
|
||||||
"The font currently in use.")
|
|
||||||
|
|
||||||
(defvar doom-ui-unicode-font
|
|
||||||
(font-spec :family "DejaVu Sans Mono" :size 12)
|
|
||||||
"Fallback font for unicode glyphs.")
|
|
||||||
|
|
||||||
(setq bidi-display-reordering nil ; disable bidirectional text for tiny performance boost
|
(setq bidi-display-reordering nil ; disable bidirectional text for tiny performance boost
|
||||||
blink-matching-paren nil ; don't blink--too distracting
|
blink-matching-paren nil ; don't blink--too distracting
|
||||||
cursor-in-non-selected-windows nil
|
cursor-in-non-selected-windows nil ; hide cursors in other windows
|
||||||
echo-keystrokes 0.02
|
echo-keystrokes 0.02 ; show typed keys in minibuffer
|
||||||
frame-inhibit-implied-resize t
|
frame-inhibit-implied-resize t
|
||||||
;; remove continuation arrow on right fringe
|
;; remove continuation arrow on right fringe
|
||||||
fringe-indicator-alist (delq (assq 'continuation fringe-indicator-alist)
|
fringe-indicator-alist (delq (assq 'continuation fringe-indicator-alist)
|
||||||
|
@ -30,10 +14,6 @@
|
||||||
image-animate-loop t
|
image-animate-loop t
|
||||||
indicate-buffer-boundaries nil
|
indicate-buffer-boundaries nil
|
||||||
indicate-empty-lines nil
|
indicate-empty-lines nil
|
||||||
jit-lock-defer-time nil
|
|
||||||
jit-lock-stealth-nice 0.1
|
|
||||||
jit-lock-stealth-time 0.2
|
|
||||||
jit-lock-stealth-verbose nil
|
|
||||||
max-mini-window-height 0.3
|
max-mini-window-height 0.3
|
||||||
mode-line-default-help-echo nil ; disable mode-line mouseovers
|
mode-line-default-help-echo nil ; disable mode-line mouseovers
|
||||||
redisplay-dont-pause t ; don't pause display on input
|
redisplay-dont-pause t ; don't pause display on input
|
||||||
|
@ -45,9 +25,39 @@
|
||||||
split-width-threshold nil ; favor horizontal splits
|
split-width-threshold nil ; favor horizontal splits
|
||||||
uniquify-buffer-name-style nil
|
uniquify-buffer-name-style nil
|
||||||
use-dialog-box nil ; always avoid GUI
|
use-dialog-box nil ; always avoid GUI
|
||||||
visible-bell nil
|
|
||||||
visible-cursor nil
|
visible-cursor nil
|
||||||
x-stretch-cursor t)
|
x-stretch-cursor t
|
||||||
|
;; no beeping or blinking please
|
||||||
|
ring-bell-function 'ignore
|
||||||
|
visible-bell nil
|
||||||
|
;; Ask for confirmation on quit only if real buffers exist
|
||||||
|
confirm-kill-emacs (lambda (_) (if (doom-real-buffers-list) (y-or-n-p "››› Quit?") t)))
|
||||||
|
|
||||||
|
(fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
|
||||||
|
|
||||||
|
;; auto-enabled in Emacs 25+; I'd rather enable it manually
|
||||||
|
(global-eldoc-mode -1)
|
||||||
|
|
||||||
|
;; A minor mode for toggling the mode-line
|
||||||
|
(defvar doom--hidden-modeline-format nil
|
||||||
|
"The modeline format to use when `doom-hide-modeline-mode' is active. Don't
|
||||||
|
set this directly. Bind it in `let' instead.")
|
||||||
|
(defvar-local doom--old-modeline-format nil
|
||||||
|
"The old modeline format, so `doom-hide-modeline-mode' can revert when it's
|
||||||
|
disabled.")
|
||||||
|
(define-minor-mode doom-hide-modeline-mode
|
||||||
|
"Minor mode to hide the mode-line in the current buffer."
|
||||||
|
:init-value nil
|
||||||
|
:global nil
|
||||||
|
(if doom-hide-modeline-mode
|
||||||
|
(setq doom--old-modeline-format mode-line-format
|
||||||
|
mode-line-format doom--hidden-modeline-format)
|
||||||
|
(setq mode-line-format doom--old-modeline-format
|
||||||
|
doom--mode-line nil))
|
||||||
|
(force-mode-line-update))
|
||||||
|
;; Ensure major-mode or theme changes don't overwrite these variables
|
||||||
|
(put 'doom--old-modeline 'permanent-local t)
|
||||||
|
(put 'doom-hide-modeline-mode 'permanent-local t)
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -59,146 +69,43 @@
|
||||||
(when window-system
|
(when window-system
|
||||||
(scroll-bar-mode -1)
|
(scroll-bar-mode -1)
|
||||||
(tool-bar-mode -1)
|
(tool-bar-mode -1)
|
||||||
;; full filename in frame title
|
;; buffer name in frame title
|
||||||
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
|
(setq-default frame-title-format '("%b"))
|
||||||
;; Set theme and font
|
|
||||||
(with-demoted-errors "FONT ERROR: %s"
|
|
||||||
(set-frame-font doom-ui-font t t)
|
|
||||||
;; Fallback to `doom-unicode-font' for Unicode characters
|
|
||||||
(when doom-ui-unicode-font
|
|
||||||
(set-fontset-font t 'unicode doom-ui-unicode-font))
|
|
||||||
;; Set font for variable-pitch mode
|
|
||||||
(when doom-ui-variable-pitch-font
|
|
||||||
(set-face-attribute 'variable-pitch nil :font doom-ui-variable-pitch-font)))
|
|
||||||
;; standardize fringe width
|
;; standardize fringe width
|
||||||
(fringe-mode doom-ui-fringe-size)
|
(fringe-mode doom-ui-fringe-size)
|
||||||
(push `(left-fringe . ,doom-ui-fringe-size) default-frame-alist)
|
(push `(left-fringe . ,doom-ui-fringe-size) default-frame-alist)
|
||||||
(push `(right-fringe . ,doom-ui-fringe-size) default-frame-alist)
|
(push `(right-fringe . ,doom-ui-fringe-size) default-frame-alist)
|
||||||
;; no fringe in the minibuffer
|
;; no fringe in the minibuffer
|
||||||
(add-hook! (emacs-startup minibuffer-setup)
|
(add-hook! (emacs-startup minibuffer-setup)
|
||||||
(set-window-fringes (minibuffer-window) 0 0 nil))
|
(set-window-fringes (minibuffer-window) 0 0 nil)))
|
||||||
;; Show tilde in margin on empty lines
|
|
||||||
(define-fringe-bitmap 'tilde [64 168 16] nil nil 'center)
|
|
||||||
(set-fringe-bitmap-face 'tilde 'fringe)
|
|
||||||
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde))
|
|
||||||
|
|
||||||
(fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
|
|
||||||
(global-eldoc-mode -1) ; auto-enabled in Emacs 25+; I'd rather do this myself
|
|
||||||
|
|
||||||
;;; TODO Smart quit-confirmation prompt
|
|
||||||
;; Only prompt if there are real buffers left (see ;; `doom-real-buffer-p')
|
|
||||||
;;(setq confirm-kill-emacs
|
|
||||||
;; (lambda (_)
|
|
||||||
;; (if (ignore-errors (doom-get-real-buffers))
|
|
||||||
;; (y-or-n-p "››› Quit?")
|
|
||||||
;; t)))
|
|
||||||
|
|
||||||
;;; Flash the mode-line on error
|
|
||||||
;; TODO More flexible colors (only suits dark themes)
|
|
||||||
;; FIXME With a rapid key-repeat setting the mode-line bg can get stuck
|
|
||||||
(defvar doom--visual-bell-bg nil)
|
|
||||||
(setq ring-bell-function 'doom-visual-bell)
|
|
||||||
(defun doom-visual-bell ()
|
|
||||||
(unless doom--visual-bell-bg
|
|
||||||
(setq doom--visual-bell-bg (face-attribute 'mode-line :background)))
|
|
||||||
(set-face-attribute 'mode-line nil :background "#54252C")
|
|
||||||
(run-with-timer
|
|
||||||
0.1 nil
|
|
||||||
(lambda () (set-face-attribute 'mode-line nil :background doom--visual-bell-bg))))
|
|
||||||
|
|
||||||
;;; TODO/FIXME/NOTE highlighting in comments
|
|
||||||
(add-hook! (prog-mode emacs-lisp-mode css-mode)
|
|
||||||
(font-lock-add-keywords
|
|
||||||
nil '(("\\<\\(TODO\\(?:(.*)\\)?:?\\)\\>" 1 'warning prepend)
|
|
||||||
("\\<\\(FIXME\\(?:(.*)\\)?:?\\)\\>" 1 'error prepend)
|
|
||||||
("\\<\\(NOTE\\(?:(.*)\\)?:?\\)\\>" 1 'success prepend))))
|
|
||||||
|
|
||||||
;;; More reliable inter-window border
|
|
||||||
;; The native border "consumes" a pixel of the fringe on righter-most splits (in
|
|
||||||
;; Yamamoto's emacs-mac at least), `window-divider' does not.
|
|
||||||
;; NOTE available since Emacs 25.1
|
|
||||||
(setq window-divider-default-places t
|
|
||||||
window-divider-default-bottom-width 1
|
|
||||||
window-divider-default-right-width 1)
|
|
||||||
(window-divider-mode +1)
|
|
||||||
|
|
||||||
|
|
||||||
;;; Mode-line hiding minor mode
|
|
||||||
(defvar doom-hide-mode-line-format nil
|
|
||||||
"Format to use when `doom-hide-mode-line-mode' replaces the modeline")
|
|
||||||
|
|
||||||
(defvar-local doom--old-mode-line nil)
|
|
||||||
|
|
||||||
(define-minor-mode doom-hide-mode-line-mode
|
|
||||||
"Minor mode to hide the mode-line in the current buffer."
|
|
||||||
:init-value nil
|
|
||||||
:global nil
|
|
||||||
(if doom-hide-mode-line-mode
|
|
||||||
(setq doom--old-mode-line mode-line-format
|
|
||||||
mode-line-format doom-hide-mode-line-format)
|
|
||||||
(setq mode-line-format doom--old-mode-line
|
|
||||||
doom--mode-line doom-hide-mode-line-format))
|
|
||||||
(force-mode-line-update))
|
|
||||||
|
|
||||||
;; Ensure major-mode or theme changes don't overwrite these variables
|
|
||||||
(put 'doom--old-mode-line 'permanent-local t)
|
|
||||||
(put 'doom-hide-mode-line-mode 'permanent-local t)
|
|
||||||
|
|
||||||
;; mode-line is unimportant in some windows
|
|
||||||
(with-current-buffer "*Messages*" (doom-hide-mode-line-mode +1))
|
|
||||||
(add-hook! (help-mode compilation-mode messages-buffer-mode completion-list-mode)
|
|
||||||
'doom-hide-mode-line-mode)
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Plugins
|
;; Plugins
|
||||||
;;
|
;;
|
||||||
|
|
||||||
;; Causes a flash around the cursor when it moves across a "large" distance.
|
;; I modified the built-in `hideshow' package to enable itself when needed. A
|
||||||
;; Usually between windows, or across files. This makes it easier to keep track
|
;; better, more vim-like code-folding plugin would be the `origami' plugin, but
|
||||||
;; where your cursor is, which I find helpful on my 30" 2560x1600 display.
|
;; until certain breaking bugs are fixed in it, I won't switch over.
|
||||||
(package! beacon
|
(package! hideshow :ensure nil ; built-in
|
||||||
:config (beacon-mode +1)
|
|
||||||
(setq beacon-color (let ((bg (face-attribute 'highlight :background nil t)))
|
|
||||||
(if (eq bg 'unspecified) (face-attribute 'highlight :foreground nil t) bg))
|
|
||||||
beacon-blink-when-buffer-changes t
|
|
||||||
beacon-blink-when-point-moves-vertically 10))
|
|
||||||
|
|
||||||
;; I modified the built-in `hideshow' package to be prettier, autoload when
|
|
||||||
;; needed, and to behave as much like folding in vim does as possible. A better
|
|
||||||
;; option might be `origami', but certain bugs in it are preventing the switch
|
|
||||||
;; for now.
|
|
||||||
(package! hideshow :ensure nil
|
|
||||||
:commands (hs-minor-mode hs-toggle-hiding hs-already-hidden-p)
|
:commands (hs-minor-mode hs-toggle-hiding hs-already-hidden-p)
|
||||||
:init
|
:init
|
||||||
(defun doom*load-hs-minor-mode ()
|
(defun doom*autoload-hideshow ()
|
||||||
(hs-minor-mode 1)
|
(unless (bound-and-true-p hs-minor-mode)
|
||||||
(advice-remove 'evil-toggle-fold 'doom-load-hs-minor-mode))
|
(hs-minor-mode 1)))
|
||||||
(advice-add 'evil-toggle-fold :before 'doom*load-hs-minor-mode)
|
(advice-add 'evil-toggle-fold :before 'doom*autoload-hideshow))
|
||||||
|
|
||||||
:config
|
;; Show uninterrupted indentation markers with some whitespace voodoo.
|
||||||
;; Prettify code folding in emacs
|
|
||||||
(defface doom-folded-face '((t (:background "#ff8")))
|
|
||||||
"Face to hightlight `hideshow' overlays."
|
|
||||||
:group 'hideshow)
|
|
||||||
(setq hs-set-up-overlay
|
|
||||||
(lambda (ov)
|
|
||||||
(when (eq 'code (overlay-get ov 'hs))
|
|
||||||
(overlay-put
|
|
||||||
ov 'display (propertize " [...] " 'face 'doom-folded-face))))))
|
|
||||||
|
|
||||||
;; Show unintrusive indentation markers, and do some whitespace voodoo to
|
|
||||||
;; prevent the lack-of-indent-guides-on-blank-lines problem.
|
|
||||||
(package! highlight-indent-guides
|
(package! highlight-indent-guides
|
||||||
:commands highlight-indent-guides-mode
|
:commands highlight-indent-guides-mode
|
||||||
:config
|
:config
|
||||||
(setq highlight-indent-guides-method 'character)
|
(setq highlight-indent-guides-method 'character)
|
||||||
|
|
||||||
(defun doom|highlight-indent-guides-adjust-whitespace (&optional start end)
|
(defun doom|adjust-indent-guides (&optional start end)
|
||||||
"Consider this the opposite of `delete-trailing-whitespace'. Injects
|
"The opposite of `delete-trailing-whitespace'. Injects whitespace into
|
||||||
whitespace into buffer so that `highlight-indent-guides-mode' will display
|
buffer so that `highlight-indent-guides-mode' will display uninterrupted indent
|
||||||
consistent, unbroken indent markers. This whitespace is stripped out on save, as
|
markers. This whitespace is stripped out on save, as not to affect the resulting
|
||||||
not to affect the resulting file."
|
file."
|
||||||
(interactive (progn (barf-if-buffer-read-only)
|
(interactive (progn (barf-if-buffer-read-only)
|
||||||
(if (use-region-p)
|
(if (use-region-p)
|
||||||
(list (region-beginning) (region-end))
|
(list (region-beginning) (region-end))
|
||||||
|
@ -234,38 +141,23 @@ not to affect the resulting file."
|
||||||
(add-hook! highlight-indent-guides-mode
|
(add-hook! highlight-indent-guides-mode
|
||||||
(if highlight-indent-guides-mode
|
(if highlight-indent-guides-mode
|
||||||
(progn
|
(progn
|
||||||
(doom|highlight-indent-guides-adjust-whitespace)
|
(doom|adjust-indent-guides)
|
||||||
(add-hook 'after-save-hook 'doom|highlight-indent-guides-adjust-whitespace nil t))
|
(add-hook 'after-save-hook 'doom|adjust-indent-guides nil t))
|
||||||
(remove-hook 'after-save-hook 'doom|highlight-indent-guides-adjust-whitespace t)
|
(remove-hook 'after-save-hook 'doom|adjust-indent-guides t)
|
||||||
(delete-trailing-whitespace)))
|
(delete-trailing-whitespace))))
|
||||||
|
|
||||||
;; If all else fails, this package tries to guess the indentation, but does it
|
|
||||||
;; naively, so get default indentation from editorconfig instead.
|
|
||||||
(defun doom*highlight-indentation-guess-offset (&rest _)
|
|
||||||
(when (featurep 'editorconfig)
|
|
||||||
(setq-local highlight-indentation-offset
|
|
||||||
(string-to-int (gethash 'indent_size (editorconfig-get-properties))))))
|
|
||||||
(advice-add 'highlight-indentation-guess-offset :before 'doom*highlight-indentation-guess-offset))
|
|
||||||
|
|
||||||
;; Some modes don't adequately highlight numbers, therefore...
|
;; Some modes don't adequately highlight numbers, therefore...
|
||||||
(package! highlight-numbers :commands highlight-numbers-mode)
|
(package! highlight-numbers :commands highlight-numbers-mode)
|
||||||
|
|
||||||
;; Line highlighting (built-in)
|
;; Line highlighting
|
||||||
(package! hl-line :ensure nil
|
(package! hl-line :ensure nil ; built-in
|
||||||
:config
|
:config
|
||||||
;; stickiness doesn't play nice with emacs 25+
|
;; stickiness doesn't play nice with emacs 25+
|
||||||
(setq hl-line-sticky-flag nil
|
(setq hl-line-sticky-flag nil
|
||||||
global-hl-line-sticky-flag nil)
|
global-hl-line-sticky-flag nil))
|
||||||
|
|
||||||
;; Remember whether hl-line was initially on or off in the current buffer
|
;; Line number column. A faster (or equivalent, in the worst case) line number
|
||||||
(defvar-local doom--hl-line-mode nil)
|
;; plugin than the built-in `linum'.
|
||||||
(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))))
|
|
||||||
|
|
||||||
;; A faster (or equal, in the worst case) line number plugin than `linum'. I've
|
|
||||||
;; modified it to highlight the current line, and fixed some glaring problems
|
|
||||||
;; with nlinum and frames.
|
|
||||||
(package! nlinum
|
(package! nlinum
|
||||||
:commands nlinum-mode
|
:commands nlinum-mode
|
||||||
:preface (defvar nlinum-format "%4d ")
|
:preface (defvar nlinum-format "%4d ")
|
||||||
|
@ -276,10 +168,10 @@ not to affect the resulting file."
|
||||||
'nlinum-mode)
|
'nlinum-mode)
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(defun doom/nlinum-toggle ()
|
(defun doom/toggle-line-numbers ()
|
||||||
"Toggle `nlinum-mode'."
|
"Toggle `nlinum-mode'."
|
||||||
(interactive)
|
(interactive)
|
||||||
(nlinum-mode (if (bound-and-true-p nlinum-mode) -1 +1)))
|
(nlinum-mode (if nlinum-mode -1 +1)))
|
||||||
|
|
||||||
;; Optimization: calculate line number column width beforehand
|
;; Optimization: calculate line number column width beforehand
|
||||||
(add-hook! nlinum-mode
|
(add-hook! nlinum-mode
|
||||||
|
@ -288,12 +180,11 @@ not to affect the resulting file."
|
||||||
|
|
||||||
;; Disable nlinum when making frames, otherwise we get linum face error
|
;; Disable nlinum when making frames, otherwise we get linum face error
|
||||||
;; messages that prevent frame creation.
|
;; messages that prevent frame creation.
|
||||||
(defun doom|nlinum-off () (nlinum-mode -1))
|
(add-hook! '(before-make-frame-hook after-make-frame-functions)
|
||||||
(add-hook 'before-make-frame-hook 'doom|nlinum-off)
|
(nlinum-mode -1)))
|
||||||
(add-hook 'after-make-frame-functions 'doom|nlinum-off))
|
|
||||||
|
|
||||||
;; Makes distinguishing stacked delimiters apart much, much easier. Especially
|
;; Helps us distinguish stacked delimiter pairs. Especially in parentheses-drunk
|
||||||
;; in parentheses-drunk languages like Lisp.
|
;; languages like Lisp.
|
||||||
(package! rainbow-delimiters
|
(package! rainbow-delimiters
|
||||||
:commands rainbow-delimiters-mode
|
:commands rainbow-delimiters-mode
|
||||||
:config (setq rainbow-delimiters-max-face-count 3)
|
:config (setq rainbow-delimiters-max-face-count 3)
|
||||||
|
@ -301,18 +192,5 @@ not to affect the resulting file."
|
||||||
(add-hook! (emacs-lisp-mode lisp-mode js-mode css-mode c-mode-common)
|
(add-hook! (emacs-lisp-mode lisp-mode js-mode css-mode c-mode-common)
|
||||||
'rainbow-delimiters-mode))
|
'rainbow-delimiters-mode))
|
||||||
|
|
||||||
;; Give color codes or names a background in that color. Nifty for css. Note
|
|
||||||
;; that hl-line and rainbow-mode don't play nicely together.
|
|
||||||
(package! rainbow-mode
|
|
||||||
:commands rainbow-mode
|
|
||||||
:init (after! hl-line (add-hook 'rainbow-mode-hook 'doom|hl-line-off)))
|
|
||||||
|
|
||||||
;; This makes distractions-free mode possible, but modifying window margins on
|
|
||||||
;; the fly and centering the buffer.
|
|
||||||
(package! visual-fill-column
|
|
||||||
:config
|
|
||||||
(add-hook! visual-fill-column-mode
|
|
||||||
(setq-local split-window-preferred-function 'visual-line-mode-split-window-sensibly)))
|
|
||||||
|
|
||||||
(provide 'core-ui)
|
(provide 'core-ui)
|
||||||
;;; core-ui.el ends here
|
;;; core-ui.el ends here
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue