2016-05-07 21:57:43 -04:00
|
|
|
|
;;; core-ui.el --- interface & mode-line config
|
2015-06-15 09:05:52 +02:00
|
|
|
|
|
2016-05-24 22:15:44 -04:00
|
|
|
|
(defconst doom-fringe-size '3 "Default fringe width")
|
2016-05-23 17:13:59 -04:00
|
|
|
|
|
2016-05-20 09:23:46 -04:00
|
|
|
|
;; y/n instead of yes/no
|
|
|
|
|
(fset 'yes-or-no-p 'y-or-n-p)
|
|
|
|
|
|
2015-06-04 18:23:21 -04:00
|
|
|
|
(setq-default
|
2016-05-23 17:13:59 -04:00
|
|
|
|
indicate-buffer-boundaries nil ; don't show where buffer starts/ends
|
2016-05-24 22:15:44 -04:00
|
|
|
|
indicate-empty-lines nil ; don't show empty lines
|
2016-05-23 17:13:59 -04:00
|
|
|
|
fringes-outside-margins t ; switches order of fringe and margin
|
2016-05-07 21:57:43 -04:00
|
|
|
|
;; Keep cursors and highlights in current window only
|
|
|
|
|
cursor-in-non-selected-windows nil
|
2016-04-08 16:15:37 -04:00
|
|
|
|
highlight-nonselected-windows nil
|
2016-05-23 17:13:59 -04: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-08 16:15:37 -04:00
|
|
|
|
|
2016-05-23 17:13:59 -04:00
|
|
|
|
blink-matching-paren nil ; don't blink--too distracting
|
|
|
|
|
show-paren-delay 0.075
|
|
|
|
|
uniquify-buffer-name-style nil
|
2016-04-08 16:15:37 -04:00
|
|
|
|
visible-bell nil
|
|
|
|
|
visible-cursor nil
|
|
|
|
|
x-stretch-cursor t
|
2016-05-12 03:06:39 -04:00
|
|
|
|
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 02:00:19 -04:00
|
|
|
|
jit-lock-defer-time nil
|
2016-04-08 16:15:37 -04:00
|
|
|
|
jit-lock-stealth-nice 0.1
|
|
|
|
|
jit-lock-stealth-time 0.2
|
|
|
|
|
jit-lock-stealth-verbose nil
|
2015-12-11 16:51:04 -05:00
|
|
|
|
;; Minibuffer resizing
|
2016-05-01 01:05:25 -04:00
|
|
|
|
resize-mini-windows 'grow-only
|
|
|
|
|
max-mini-window-height 0.3
|
2016-05-23 17:13:59 -04:00
|
|
|
|
;; Ask for confirmation on exit only if there are real buffers left
|
|
|
|
|
confirm-kill-emacs
|
|
|
|
|
(lambda (_) (if window-system (if (doom/get-real-buffers) (y-or-n-p "› Quit?") t) t)))
|
2015-11-30 16:51:13 -05:00
|
|
|
|
|
2016-05-23 17:13:59 -04:00
|
|
|
|
;; Initialize UI
|
2016-05-20 22:37:30 -04:00
|
|
|
|
(load-theme doom-current-theme t)
|
2016-05-20 09:23:46 -04:00
|
|
|
|
(tooltip-mode -1) ; show tooltips in echo area
|
2016-05-23 20:56:19 -04:00
|
|
|
|
(if (not (display-graphic-p))
|
2016-03-03 15:04:14 -05:00
|
|
|
|
(menu-bar-mode -1)
|
2016-03-26 01:19:31 -04:00
|
|
|
|
(scroll-bar-mode -1) ; no scrollbar
|
|
|
|
|
(tool-bar-mode -1) ; no toolbar
|
2016-03-29 23:48:06 -04:00
|
|
|
|
;; full filename in frame title
|
|
|
|
|
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
|
|
|
|
|
;; set fonts
|
2016-05-20 22:37:30 -04:00
|
|
|
|
(set-frame-font doom-default-font t)
|
|
|
|
|
(set-face-attribute 'default t :font doom-current-font)
|
2016-05-21 00:13:50 -04:00
|
|
|
|
;; standardize fringe width
|
2016-05-24 22:15:44 -04:00
|
|
|
|
(fringe-mode doom-fringe-size)
|
2016-05-21 00:13:50 -04:00
|
|
|
|
(push `(left-fringe . ,doom-fringe-size) default-frame-alist)
|
|
|
|
|
(push `(right-fringe . ,doom-fringe-size) default-frame-alist)
|
|
|
|
|
;; Default frame size on startup
|
|
|
|
|
(push '(width . 120) default-frame-alist)
|
|
|
|
|
(push '(height . 32) default-frame-alist)
|
2016-05-20 17:19:59 -04:00
|
|
|
|
;; no fringe in the minibuffer
|
2016-05-23 17:13:59 -04:00
|
|
|
|
(add-hook! (emacs-startup minibuffer-setup)
|
|
|
|
|
(set-window-fringes (minibuffer-window) 0 0 nil))
|
2016-03-29 23:48:06 -04:00
|
|
|
|
;; Show tilde in margin on empty lines
|
2016-03-03 15:04:14 -05:00
|
|
|
|
(define-fringe-bitmap 'tilde [64 168 16] nil nil 'center)
|
2016-05-20 17:19:59 -04:00
|
|
|
|
(set-fringe-bitmap-face 'tilde 'fringe)
|
2016-05-23 20:56:19 -04:00
|
|
|
|
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
|
|
|
|
|
;; Fix certain unicode characters without upsetting line-height
|
|
|
|
|
(doom-fix-unicode "DejaVu Sans" '(?⚠ ?★ ?λ ?➊ ?➋ ?➌ ?➍ ?➎ ?❻ ?➐ ?➑ ?➒ ?➓)))
|
2015-11-14 02:35:15 -05:00
|
|
|
|
|
2016-05-23 20:56:19 -04:00
|
|
|
|
;; Hide mode-line in help/compile window
|
|
|
|
|
(add-hook 'help-mode-hook 'doom|hide-mode-line)
|
|
|
|
|
(add-hook 'compilation-mode-hook 'doom|hide-mode-line)
|
2016-03-03 15:04:14 -05:00
|
|
|
|
|
2016-05-23 17:13:59 -04:00
|
|
|
|
;; On by default in Emacs 25. I'll enable it manually, so disable it globally
|
2016-04-23 22:08:46 -04:00
|
|
|
|
(when (and (> emacs-major-version 24) (featurep 'eldoc))
|
2016-01-30 21:16:10 -05:00
|
|
|
|
(global-eldoc-mode -1))
|
2015-11-10 18:01:57 -05:00
|
|
|
|
|
2016-05-26 05:23:25 -04:00
|
|
|
|
(use-package eldoc-eval
|
|
|
|
|
:config
|
|
|
|
|
(setq eldoc-in-minibuffer-show-fn 'doom/eldoc-show-in-mode-line)
|
|
|
|
|
(eldoc-in-minibuffer-mode +1))
|
|
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
|
;; Highlight TODO/FIXME/NOTE tags
|
2016-05-16 00:41:25 -04:00
|
|
|
|
(add-hook! (prog-mode emacs-lisp-mode css-mode)
|
2016-04-26 02:00:19 -04:00
|
|
|
|
(font-lock-add-keywords
|
2016-05-23 17:14:37 -04:00
|
|
|
|
nil '(("\\<\\(TODO\\(?:(.*)\\)?:?\\)\\>" 1 'warning prepend)
|
|
|
|
|
("\\<\\(FIXME\\(?:(.*)\\)?:?\\)\\>" 1 'error prepend)
|
|
|
|
|
("\\<\\(NOTE\\(?:(.*)\\)?:?\\)\\>" 1 'success prepend))))
|
2015-06-04 18:23:21 -04:00
|
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
;; Plugins
|
|
|
|
|
;;
|
|
|
|
|
|
2016-05-01 01:05:25 -04:00
|
|
|
|
(use-package hl-line
|
2016-05-23 17:13:59 -04:00
|
|
|
|
:init (add-hook! (prog-mode markdown-mode) 'hl-line-mode)
|
2016-05-01 01:05:25 -04:00
|
|
|
|
:config
|
2016-05-20 22:37:30 -04:00
|
|
|
|
(defvar-local doom--hl-line-mode nil)
|
2016-05-07 21:57:43 -04:00
|
|
|
|
(setq hl-line-sticky-flag nil
|
|
|
|
|
global-hl-line-sticky-flag nil)
|
2016-05-01 01:05:25 -04:00
|
|
|
|
|
2016-05-20 22:37:30 -04: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 01:05:25 -04:00
|
|
|
|
;; Disable line highlight in visual mode
|
2016-05-20 22:37:30 -04: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 01:05:25 -04:00
|
|
|
|
|
2016-04-26 02:00:19 -04:00
|
|
|
|
(use-package visual-fill-column :defer t
|
|
|
|
|
:config
|
|
|
|
|
(setq-default visual-fill-column-center-text nil
|
|
|
|
|
visual-fill-column-width fill-column))
|
2015-11-30 16:51:13 -05:00
|
|
|
|
|
2016-04-12 02:59:36 -04:00
|
|
|
|
(use-package highlight-indentation
|
2016-05-12 22:11:43 -04:00
|
|
|
|
:commands (highlight-indentation-mode
|
|
|
|
|
highlight-indentation-current-column-mode)
|
2016-04-12 02:59:36 -04:00
|
|
|
|
:init
|
2016-04-23 22:08:46 -04:00
|
|
|
|
(add-hook! (nxml-mode yaml-mode json-mode scss-mode
|
2016-04-12 02:59:36 -04:00
|
|
|
|
c-mode-common ruby-mode python-mode lua-mode)
|
|
|
|
|
'highlight-indentation-mode)
|
2016-04-23 22:08:46 -04:00
|
|
|
|
(after! editorconfig
|
2016-05-12 22:11:43 -04:00
|
|
|
|
(advice-add 'highlight-indentation-guess-offset
|
2016-05-20 22:37:30 -04:00
|
|
|
|
:override 'doom*hl-indent-guess-offset))
|
2016-04-12 02:59:36 -04: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-20 22:37:30 -04:00
|
|
|
|
(doom/add-whitespace)
|
|
|
|
|
(add-hook 'after-save-hook 'doom/add-whitespace nil t)
|
2016-04-16 21:40:52 -04:00
|
|
|
|
(add-hook 'before-save-hook 'delete-trailing-whitespace nil t))
|
2016-05-20 22:37:30 -04:00
|
|
|
|
(remove-hook 'after-save-hook 'doom/add-whitespace t)
|
2016-04-16 21:40:52 -04:00
|
|
|
|
(remove-hook 'before-save-hook 'delete-trailing-whitespace t))))
|
2016-04-12 02:59:36 -04:00
|
|
|
|
|
2016-04-16 00:44:18 -04:00
|
|
|
|
(use-package highlight-numbers :commands (highlight-numbers-mode))
|
|
|
|
|
|
2015-10-15 14:01:53 -04:00
|
|
|
|
(use-package rainbow-delimiters
|
|
|
|
|
:commands rainbow-delimiters-mode
|
2016-05-23 17:13:59 -04:00
|
|
|
|
:config (setq rainbow-delimiters-max-face-count 3)
|
2016-03-06 00:44:22 -05:00
|
|
|
|
:init
|
2016-05-23 17:13:59 -04:00
|
|
|
|
(add-hook! (emacs-lisp-mode lisp-mode js-mode css-mode c-mode-common)
|
|
|
|
|
'rainbow-delimiters-mode))
|
2015-10-15 14:01:53 -04:00
|
|
|
|
|
2016-05-23 17:13:59 -04:00
|
|
|
|
;; NOTE hl-line-mode and rainbow-mode don't play well together
|
2016-04-12 02:56:30 -04:00
|
|
|
|
(use-package rainbow-mode
|
|
|
|
|
:commands (rainbow-mode)
|
2016-05-23 17:13:59 -04:00
|
|
|
|
:init (add-hook 'rainbow-mode-hook 'doom|hl-line-off))
|
2015-10-15 14:01:53 -04:00
|
|
|
|
|
2015-10-26 01:29:38 -04:00
|
|
|
|
(use-package nlinum
|
2015-10-28 03:31:51 -04:00
|
|
|
|
:commands nlinum-mode
|
2015-06-06 06:40:33 -04:00
|
|
|
|
:preface
|
2016-05-12 22:11:43 -04:00
|
|
|
|
(setq linum-format "%3d ")
|
2016-05-20 17:20:44 -04:00
|
|
|
|
(defvar nlinum-format "%4d ")
|
2016-05-20 22:37:30 -04:00
|
|
|
|
(defvar doom--hl-nlinum-overlay nil)
|
|
|
|
|
(defvar doom--hl-nlinum-line nil)
|
2015-11-09 15:52:42 -05:00
|
|
|
|
:init
|
2015-11-10 18:01:57 -05:00
|
|
|
|
(add-hook!
|
2015-12-10 16:15:09 -05:00
|
|
|
|
(markdown-mode prog-mode scss-mode web-mode conf-mode)
|
2016-04-30 23:13:39 -04:00
|
|
|
|
'nlinum-mode)
|
|
|
|
|
(add-hook! 'nlinum-mode-hook
|
2016-05-20 22:37:30 -04:00
|
|
|
|
(add-hook 'post-command-hook 'doom|nlinum-hl-line nil t))
|
2015-10-03 04:56:33 -04:00
|
|
|
|
:config
|
2016-05-24 22:50:39 -04:00
|
|
|
|
;; Calculate line number column width
|
2015-06-15 09:05:52 +02:00
|
|
|
|
(add-hook! nlinum-mode
|
2016-05-23 17:13:59 -04:00
|
|
|
|
(setq nlinum--width (length (save-excursion (goto-char (point-max))
|
2016-05-24 22:50:39 -04:00
|
|
|
|
(format-mode-line "%l")))))
|
|
|
|
|
;; 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 01:29:38 -04:00
|
|
|
|
|
2015-06-06 06:40:33 -04:00
|
|
|
|
|
2016-04-26 02:03:42 -04:00
|
|
|
|
;;
|
|
|
|
|
;; Mode-line
|
|
|
|
|
;;
|
2015-06-06 06:40:33 -04:00
|
|
|
|
|
2015-12-11 16:51:04 -05:00
|
|
|
|
(use-package spaceline
|
2015-11-07 00:20:04 -05:00
|
|
|
|
:init
|
2016-05-20 22:37:30 -04:00
|
|
|
|
(defvar-local doom--env-version nil)
|
|
|
|
|
(defvar-local doom--env-command nil)
|
2016-05-20 16:44:57 -04:00
|
|
|
|
(defvar powerline-height 26)
|
2016-05-07 21:57:43 -04:00
|
|
|
|
(defvar powerline-default-separator nil)
|
2015-09-28 15:55:25 -04:00
|
|
|
|
|
2016-04-26 02:03:42 -04:00
|
|
|
|
:config
|
2015-10-01 03:40:09 -04:00
|
|
|
|
(defface mode-line-is-modified nil "Face for mode-line modified symbol")
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(defface mode-line-buffer-file nil "Face for mode-line buffer file name")
|
|
|
|
|
(defface mode-line-buffer-path nil "Face for mode-line buffer file path")
|
2015-09-30 13:47:57 -04:00
|
|
|
|
|
2016-03-29 23:48:06 -04:00
|
|
|
|
;; Custom modeline segments
|
|
|
|
|
(spaceline-define-segment *buffer-path
|
2016-05-12 22:11:43 -04:00
|
|
|
|
(concat
|
|
|
|
|
(when buffer-file-name
|
|
|
|
|
(powerline-raw
|
|
|
|
|
(f-dirname
|
2016-05-20 22:37:30 -04:00
|
|
|
|
(let ((buffer-path (f-relative buffer-file-name (doom/project-root)))
|
2016-05-12 22:11:43 -04:00
|
|
|
|
(max-length (truncate (/ (window-body-width) 1.75))))
|
|
|
|
|
(concat (projectile-project-name) "/"
|
|
|
|
|
(if (> (length buffer-path) max-length)
|
|
|
|
|
(let ((path (reverse (split-string buffer-path "/" t)))
|
|
|
|
|
(output ""))
|
|
|
|
|
(when (and path (equal "" (car path)))
|
|
|
|
|
(setq path (cdr path)))
|
|
|
|
|
(while (and path (<= (length output) (- max-length 4)))
|
|
|
|
|
(setq output (concat (car path) "/" output))
|
|
|
|
|
(setq path (cdr path)))
|
|
|
|
|
(when path
|
|
|
|
|
(setq output (concat "../" output)))
|
|
|
|
|
(when (string-suffix-p "/" output)
|
|
|
|
|
(setq output (substring output 0 -1)))
|
|
|
|
|
output)
|
|
|
|
|
buffer-path))))
|
|
|
|
|
(if active 'mode-line-buffer-path)))
|
2016-05-20 16:44:57 -04:00
|
|
|
|
(powerline-raw "%b" (if active 'mode-line-buffer-file))
|
|
|
|
|
(when buffer-file-name
|
|
|
|
|
(powerline-raw
|
|
|
|
|
(concat (when buffer-file-name
|
|
|
|
|
(concat
|
2016-05-23 17:13:59 -04:00
|
|
|
|
(if (buffer-modified-p) " ✱")
|
2016-05-20 16:44:57 -04:00
|
|
|
|
(if (not (file-exists-p buffer-file-name)) "[!]")))
|
|
|
|
|
(if buffer-read-only "[RO]"))
|
|
|
|
|
'mode-line-is-modified)))
|
|
|
|
|
:tight-right t
|
|
|
|
|
:skip-alternate t)
|
2016-03-29 23:48:06 -04:00
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *buffer-position
|
|
|
|
|
"A more vim-like buffer position."
|
2016-05-20 16:44:57 -04:00
|
|
|
|
(concat "(%l,%c) "
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(let ((start (window-start))
|
|
|
|
|
(end (window-end))
|
|
|
|
|
(pend (point-max)))
|
|
|
|
|
(if (and (eq start 1)
|
|
|
|
|
(eq end pend))
|
|
|
|
|
":All"
|
|
|
|
|
(let ((perc (/ end 0.01 pend)))
|
|
|
|
|
(cond ((= start 1) ":Top")
|
|
|
|
|
((>= perc 100) ":Bot")
|
2016-05-20 16:44:57 -04:00
|
|
|
|
(t (format ":%d%%%%" perc))))))
|
|
|
|
|
" "))
|
2016-03-29 23:48:06 -04:00
|
|
|
|
|
2016-05-25 00:11:39 -04:00
|
|
|
|
(defface mode-line-vcs-info nil '((t (:inherit warning))))
|
|
|
|
|
(defface mode-line-vcs-warning nil '((t (:inherit warning))))
|
2016-03-29 23:48:06 -04:00
|
|
|
|
(spaceline-define-segment *vc
|
|
|
|
|
"Version control info"
|
2016-05-20 16:44:57 -04:00
|
|
|
|
(when vc-mode
|
2016-05-25 00:11:39 -04:00
|
|
|
|
(propertize
|
|
|
|
|
(concat "⎇ " (substring vc-mode (+ 2 (length (symbol-name (vc-backend buffer-file-name))))))
|
|
|
|
|
'face (when active
|
|
|
|
|
(let ((state (vc-state buffer-file-name)))
|
|
|
|
|
(cond ((memq state '(edited added))
|
|
|
|
|
'mode-line-vcs-info)
|
|
|
|
|
((memq state '(removed needs-merge needs-update conflict removed unregistered))
|
|
|
|
|
'mode-line-vcs-warning)))))))
|
2016-03-29 23:48:06 -04:00
|
|
|
|
|
|
|
|
|
;; search indicators
|
|
|
|
|
(defface mode-line-count-face nil "")
|
|
|
|
|
(make-variable-buffer-local 'anzu--state)
|
|
|
|
|
(spaceline-define-segment *anzu
|
|
|
|
|
"Show the current match number and the total number of matches. Requires
|
2015-11-14 02:37:10 -05:00
|
|
|
|
anzu to be enabled."
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(when (evil-ex-hl-active-p 'evil-ex-search)
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(powerline-raw
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(let ((here anzu--current-position)
|
|
|
|
|
(total anzu--total-matched))
|
|
|
|
|
(format " %s/%d%s "
|
|
|
|
|
here total
|
|
|
|
|
(if anzu--overflow-p "+" "")))
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(if active 'mode-line-count-face 'mode-line-inactive)))
|
2016-03-29 23:48:06 -04:00
|
|
|
|
:tight t)
|
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *iedit
|
2016-05-20 16:44:57 -04:00
|
|
|
|
"Show the number of iedit regions matches + what match you're on."
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(when (bound-and-true-p iedit-mode)
|
|
|
|
|
(propertize
|
|
|
|
|
(let ((this-oc (iedit-find-current-occurrence-overlay))
|
2016-05-12 22:11:43 -04:00
|
|
|
|
(length (or (ignore-errors (length iedit-occurrences-overlays)) 0)))
|
|
|
|
|
(format
|
|
|
|
|
" %s/%s "
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unless this-oc
|
|
|
|
|
(iedit-prev-occurrence)
|
|
|
|
|
(setq this-oc (iedit-find-current-occurrence-overlay)))
|
|
|
|
|
(if this-oc
|
|
|
|
|
;; NOTE: Not terribly reliable
|
|
|
|
|
(- length (-elem-index this-oc iedit-occurrences-overlays))
|
|
|
|
|
"-"))
|
|
|
|
|
length))
|
2016-05-10 23:03:41 -04:00
|
|
|
|
'face (if active 'mode-line-count-face 'mode-line-inactive)))
|
|
|
|
|
:tight t)
|
2016-03-29 23:48:06 -04:00
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *evil-substitute
|
|
|
|
|
"Show number of :s matches in real time."
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(when (and (evil-ex-p) (evil-ex-hl-active-p 'evil-ex-substitute))
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(powerline-raw
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(let ((range (if evil-ex-range
|
|
|
|
|
(cons (car evil-ex-range) (cadr evil-ex-range))
|
|
|
|
|
(cons (line-beginning-position) (line-end-position))))
|
|
|
|
|
(pattern (car-safe (evil-delimited-arguments evil-ex-argument 2))))
|
|
|
|
|
(if pattern
|
|
|
|
|
(format " %s matches "
|
|
|
|
|
(count-matches pattern (car range) (cdr range))
|
|
|
|
|
evil-ex-argument)
|
|
|
|
|
" ... "))
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(if active 'mode-line-count-face 'mode-line-inactive)))
|
2016-05-10 23:03:41 -04:00
|
|
|
|
:tight t)
|
2016-03-29 23:48:06 -04:00
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *macro-recording
|
2016-05-20 16:44:57 -04:00
|
|
|
|
"Show when recording macro."
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(when (and active defining-kbd-macro)
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(powerline-raw
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(format " %s ▶ " (char-to-string evil-this-macro))
|
2016-05-11 23:13:07 -04:00
|
|
|
|
highlight-face))
|
2016-05-01 01:05:25 -04:00
|
|
|
|
:tight t)
|
2016-03-29 23:48:06 -04:00
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *buffer-encoding-abbrev
|
|
|
|
|
"The line ending convention used in the buffer."
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(unless (string-match-p "\\(utf-8\\|undecided\\)"
|
|
|
|
|
(symbol-name buffer-file-coding-system))
|
|
|
|
|
(format "%s" buffer-file-coding-system)))
|
2016-03-29 23:48:06 -04:00
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *major-mode
|
2016-05-07 21:57:43 -04:00
|
|
|
|
"The major mode, including process, environment and text-scale info."
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(concat (format "%s" mode-name)
|
|
|
|
|
(if (stringp mode-line-process) mode-line-process)
|
2016-05-20 22:37:30 -04:00
|
|
|
|
(if doom--env-version (concat " " doom--env-version))
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(and (featurep 'face-remap)
|
|
|
|
|
(/= text-scale-mode-amount 0)
|
2016-05-20 16:44:57 -04:00
|
|
|
|
(format " (%+d)" text-scale-mode-amount))))
|
2016-03-29 23:48:06 -04:00
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *selection-info
|
2016-05-07 21:57:43 -04:00
|
|
|
|
"Information about the current selection."
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(when (and active (evil-visual-state-p))
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(powerline-raw
|
|
|
|
|
(let ((reg-beg (region-beginning))
|
|
|
|
|
(reg-end (region-end))
|
|
|
|
|
(evil (eq 'visual evil-state)))
|
|
|
|
|
(let ((lines (count-lines reg-beg (min (1+ reg-end) (point-max))))
|
|
|
|
|
(chars (- (1+ reg-end) reg-beg))
|
|
|
|
|
(cols (1+ (abs (- (evil-column reg-end)
|
|
|
|
|
(evil-column reg-beg))))))
|
|
|
|
|
(cond
|
|
|
|
|
;; rectangle selection
|
|
|
|
|
((or (bound-and-true-p rectangle-mark-mode)
|
|
|
|
|
(and evil (eq 'block evil-visual-selection)))
|
2016-05-20 16:44:57 -04:00
|
|
|
|
(format " %dx%dB " lines (if evil cols (1- cols))))
|
2016-05-11 23:13:07 -04:00
|
|
|
|
;; line selection
|
|
|
|
|
((or (> lines 1) (eq 'line evil-visual-selection))
|
|
|
|
|
(if (and (eq evil-state 'visual) (eq evil-this-type 'line))
|
2016-05-23 17:14:37 -04:00
|
|
|
|
(format " %dL " lines)
|
2016-05-20 16:44:57 -04:00
|
|
|
|
(format " %dC %dL " chars lines)))
|
|
|
|
|
(t (format " %dC " (if evil chars (1- chars)))))))
|
|
|
|
|
highlight-face))
|
|
|
|
|
:tight t)
|
2016-03-29 23:48:06 -04:00
|
|
|
|
|
|
|
|
|
;; flycheck
|
2016-05-23 17:14:37 -04:00
|
|
|
|
(defface doom-flycheck-error '((t (:inherit error)))
|
2016-03-29 23:48:06 -04:00
|
|
|
|
"Face for flycheck error feedback in the modeline.")
|
2016-05-23 17:14:37 -04:00
|
|
|
|
(defface doom-flycheck-warning '((t (:inherit warning)))
|
2016-03-29 23:48:06 -04:00
|
|
|
|
"Face for flycheck warning feedback in the modeline.")
|
|
|
|
|
|
2016-05-20 22:37:30 -04:00
|
|
|
|
(defvar-local doom--flycheck-err-cache nil "")
|
|
|
|
|
(defvar-local doom--flycheck-cache nil "")
|
2016-03-29 23:48:06 -04:00
|
|
|
|
(spaceline-define-segment *flycheck
|
|
|
|
|
"Persistent and cached flycheck indicators in the mode-line."
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(when (and (bound-and-true-p flycheck-mode)
|
2016-03-29 23:48:06 -04:00
|
|
|
|
(or flycheck-current-errors
|
|
|
|
|
(eq 'running flycheck-last-status-change)))
|
2016-05-20 22:37:30 -04:00
|
|
|
|
(or (and (or (eq doom--flycheck-err-cache doom--flycheck-cache)
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(memq flycheck-last-status-change '(running not-checked)))
|
2016-05-20 22:37:30 -04:00
|
|
|
|
doom--flycheck-cache)
|
|
|
|
|
(and (setq doom--flycheck-err-cache flycheck-current-errors)
|
|
|
|
|
(setq doom--flycheck-cache
|
|
|
|
|
(let ((fe (doom/-flycheck-count 'error))
|
|
|
|
|
(fw (doom/-flycheck-count 'warning)))
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(concat
|
2016-05-12 22:11:43 -04:00
|
|
|
|
(if fe (propertize (format " ⚠%s " fe)
|
|
|
|
|
'face (if active
|
2016-05-23 17:14:37 -04:00
|
|
|
|
'doom-flycheck-error
|
2016-05-12 22:11:43 -04:00
|
|
|
|
'mode-line)))
|
|
|
|
|
(if fw (propertize (format " ⚠%s " fw)
|
|
|
|
|
'face (if active
|
2016-05-23 17:14:37 -04:00
|
|
|
|
'doom-flycheck-warning
|
2016-05-12 22:11:43 -04:00
|
|
|
|
'mode-line)))))))))
|
2016-05-01 01:07:45 -04:00
|
|
|
|
:tight t)
|
2016-03-29 23:48:06 -04:00
|
|
|
|
|
2016-05-01 01:07:45 -04:00
|
|
|
|
(spaceline-define-segment *pad
|
2016-05-07 21:57:43 -04:00
|
|
|
|
"Padding, to ensure the mode-line is `powerline-height' pixels tall"
|
2016-05-20 16:44:57 -04:00
|
|
|
|
(pl/percent-xpm powerline-height 100 0 100 0 3 (if active "#00B3EF") nil)
|
2016-05-10 23:03:41 -04:00
|
|
|
|
:tight t)
|
2015-11-14 02:37:10 -05:00
|
|
|
|
|
2016-05-10 23:03:41 -04:00
|
|
|
|
(spaceline-compile
|
2016-05-11 05:36:49 -04:00
|
|
|
|
'main
|
2016-05-20 16:44:57 -04:00
|
|
|
|
'(*pad
|
|
|
|
|
((*macro-recording *anzu *iedit *evil-substitute *flycheck *selection-info)
|
2016-05-10 23:03:41 -04:00
|
|
|
|
:skip-alternate t
|
|
|
|
|
:tight t)
|
2016-05-20 16:44:57 -04:00
|
|
|
|
*buffer-path)
|
|
|
|
|
'(*vc
|
2016-05-10 23:03:41 -04:00
|
|
|
|
*major-mode
|
|
|
|
|
*env-version
|
|
|
|
|
*buffer-encoding-abbrev
|
|
|
|
|
(global :when active)
|
2016-05-20 16:44:57 -04:00
|
|
|
|
*buffer-position))
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
(spaceline-define-segment *default-dir
|
|
|
|
|
"Shows default-directory"
|
|
|
|
|
(concat "[" (abbreviate-file-name default-directory) "]")
|
|
|
|
|
:face other-face)
|
|
|
|
|
|
|
|
|
|
(spaceline-compile
|
|
|
|
|
'scratch
|
|
|
|
|
'(*pad
|
|
|
|
|
((*macro-recording *anzu *iedit *evil-substitute *flycheck *selection-info)
|
|
|
|
|
:skip-alternate t
|
|
|
|
|
:tight t)
|
|
|
|
|
*buffer-path
|
|
|
|
|
*default-dir)
|
|
|
|
|
'(*major-mode
|
|
|
|
|
*env-version
|
|
|
|
|
*buffer-encoding-abbrev
|
|
|
|
|
(global :when active)
|
|
|
|
|
*buffer-position))
|
2016-04-12 15:57:20 -04:00
|
|
|
|
|
2016-05-26 05:23:25 -04:00
|
|
|
|
;;
|
|
|
|
|
(spaceline-define-segment *eldoc
|
|
|
|
|
(and (bound-and-true-p str) str)
|
|
|
|
|
:tight t
|
|
|
|
|
:face 'mode-line)
|
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *eldoc-pad
|
|
|
|
|
"Padding, to ensure the mode-line is `powerline-height' pixels tall"
|
|
|
|
|
(pl/percent-xpm powerline-height 100 0 100 0 3 "#B3EF00" nil)
|
|
|
|
|
:tight t
|
|
|
|
|
:face 'mode-line)
|
|
|
|
|
|
|
|
|
|
(spaceline-compile
|
|
|
|
|
'eldoc '(*eldoc-pad *eldoc) '())
|
|
|
|
|
|
2015-09-30 13:47:57 -04:00
|
|
|
|
;; Initialize modeline
|
2016-05-11 23:13:07 -04:00
|
|
|
|
(setq-default mode-line-format '("%e" (:eval (spaceline-ml-main)))))
|
2015-06-04 18:23:21 -04:00
|
|
|
|
|
|
|
|
|
(provide 'core-ui)
|
|
|
|
|
;;; core-ui.el ends here
|