2015-06-06 06:40:33 -04:00
|
|
|
|
;;; core-ui.el --- interface settings
|
2015-06-15 09:05:52 +02:00
|
|
|
|
|
2015-06-04 18:23:21 -04:00
|
|
|
|
(setq-default
|
2016-03-29 23:48:06 -04:00
|
|
|
|
blink-matching-paren nil ; don't blink matching delimiters--too distracting
|
2015-11-09 15:52:42 -05:00
|
|
|
|
show-paren-delay 0.075
|
2015-10-26 01:29:38 -04:00
|
|
|
|
|
2016-03-29 23:48:06 -04:00
|
|
|
|
;;cursor-in-non-selected-windows nil ; no cursors except in active buffer
|
2016-04-08 16:15:37 -04:00
|
|
|
|
highlight-nonselected-windows nil
|
|
|
|
|
hl-line-sticky-flag nil ; only highlight in one window
|
|
|
|
|
|
|
|
|
|
uniquify-buffer-name-style nil ; my mode-line does this for me
|
|
|
|
|
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
|
|
|
|
|
indicate-buffer-boundaries t ; show indicators where buffer starts/ends
|
|
|
|
|
indicate-empty-lines t ; show indicators on empty lines
|
|
|
|
|
fringes-outside-margins t ; switches order of fringe and margin
|
|
|
|
|
split-width-threshold nil ; favor horizontal splits
|
|
|
|
|
show-help-function nil ; hide :help-echo text
|
|
|
|
|
|
|
|
|
|
jit-lock-defer-time 0.04
|
|
|
|
|
jit-lock-stealth-nice 0.1
|
|
|
|
|
jit-lock-stealth-time 0.2
|
|
|
|
|
jit-lock-stealth-verbose nil
|
2015-11-30 16:51:13 -05:00
|
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
|
;; Disable bidirectional text support for slight performance bonus
|
2016-02-11 02:08:32 -05:00
|
|
|
|
bidi-display-reordering nil
|
|
|
|
|
|
2015-12-11 16:51:04 -05:00
|
|
|
|
;; Minibuffer resizing
|
2015-12-09 02:03:13 -05:00
|
|
|
|
resize-mini-windows 'grow-only
|
2015-12-11 16:51:04 -05:00
|
|
|
|
max-mini-window-height 0.3
|
2015-11-30 16:51:13 -05:00
|
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
|
;; Remove arrow on the right fringe when wrapped
|
2015-12-09 02:03:13 -05:00
|
|
|
|
fringe-indicator-alist (delq (assoc 'continuation fringe-indicator-alist)
|
|
|
|
|
fringe-indicator-alist))
|
2015-10-15 14:01:53 -04:00
|
|
|
|
|
2016-04-05 23:58:32 -04:00
|
|
|
|
(fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no
|
|
|
|
|
|
|
|
|
|
;; Ask for confirmation on exit only if there are real buffers left
|
|
|
|
|
(when window-system
|
|
|
|
|
(setq confirm-kill-emacs
|
|
|
|
|
(lambda (_)
|
|
|
|
|
(if (narf/get-real-buffers)
|
|
|
|
|
(y-or-n-p ">> Gee, I dunno Brain... Are you sure?")
|
|
|
|
|
t))))
|
|
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
|
(blink-cursor-mode 1) ; blink cursor
|
|
|
|
|
(tooltip-mode -1) ; show tooltips in echo area
|
2015-11-30 16:51:13 -05:00
|
|
|
|
|
2016-03-29 23:48:06 -04:00
|
|
|
|
;; set up minibuffer and fringe
|
2016-03-03 15:04:14 -05:00
|
|
|
|
(if (not window-system)
|
|
|
|
|
(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-03-03 15:04:14 -05:00
|
|
|
|
(narf/load-font narf-default-font)
|
|
|
|
|
(set-face-attribute 'default t :font narf-default-font)
|
|
|
|
|
|
2016-03-29 23:48:06 -04:00
|
|
|
|
;; standardize fringe width
|
2016-03-03 15:04:14 -05:00
|
|
|
|
(fringe-mode narf-fringe-size)
|
2016-03-09 21:40:18 -05:00
|
|
|
|
|
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)
|
|
|
|
|
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
|
|
|
|
|
(set-fringe-bitmap-face 'tilde 'font-lock-comment-face)
|
|
|
|
|
|
|
|
|
|
;; Brighter minibuffer when active
|
2016-03-29 23:48:06 -04:00
|
|
|
|
(defface narf-minibuffer-active '((t (:inherit mode-line)))
|
|
|
|
|
"Face for active minibuffer")
|
2016-03-03 15:04:14 -05:00
|
|
|
|
(defun narf|minibuffer-setup ()
|
|
|
|
|
(set-window-fringes (selected-window) 0 0 nil)
|
|
|
|
|
(make-local-variable 'face-remapping-alist)
|
|
|
|
|
(add-to-list 'face-remapping-alist '(default narf-minibuffer-active)))
|
2016-03-09 21:40:18 -05:00
|
|
|
|
(add-hook! minibuffer-setup 'narf|minibuffer-setup)
|
|
|
|
|
(add-hook! 'after-init-hook (set-window-fringes (minibuffer-window) 0 0 nil)))
|
2015-11-14 02:35:15 -05:00
|
|
|
|
|
2016-03-29 23:48:06 -04:00
|
|
|
|
;; Try to display unicode characters without upsetting line-hieght (as much as possible)
|
2016-03-03 15:04:14 -05:00
|
|
|
|
(mapc (lambda (set)
|
2016-03-06 00:44:22 -05:00
|
|
|
|
(let ((font (car set))
|
|
|
|
|
(chars (cadr set))
|
2016-03-03 15:04:14 -05:00
|
|
|
|
(size (caddr set)))
|
|
|
|
|
(mapc (lambda (x) (set-fontset-font
|
|
|
|
|
"fontset-default" `(,x . ,x)
|
|
|
|
|
(font-spec :name font :size size) nil 'prepend))
|
|
|
|
|
chars)))
|
2016-03-06 00:44:22 -05:00
|
|
|
|
'(("DejaVu Sans" (?☑ ?☐ ?⚠ ?★ ?λ ?♭ ?♯
|
2016-03-03 15:04:14 -05:00
|
|
|
|
?➊ ?➋ ?➌ ?➍ ?➎ ?❻ ?➐ ?➑ ?➒ ?➓))
|
|
|
|
|
;; File attachment symbols (for org-mode)
|
|
|
|
|
("FontAwesome" (? ? ? ? ? ? ? ? ?) 13)
|
2016-03-29 23:48:06 -04:00
|
|
|
|
;; Certain math symbols
|
2016-03-03 15:04:14 -05:00
|
|
|
|
("Hack" (?× ?∙ ?÷ ?⌉ ?⌈ ?⌊ ?⌋
|
|
|
|
|
?∩ ?∪ ?⊆ ?⊂ ?⊄ ?⊇ ?⊃ ?⊅
|
|
|
|
|
?⇒ ?⇐ ?⇔ ?↔ ?→ ?≡ ?∴ ?∵ ?⊕ ?∀ ?∃ ?∄ ?∈ ?∉
|
|
|
|
|
?∨ ?∧ ?¬))))
|
|
|
|
|
|
2016-03-29 23:48:06 -04:00
|
|
|
|
;; on by default in Emacs 25; I prefer to enable on a mode-by-mode basis, so disable it
|
2016-01-30 21:16:10 -05:00
|
|
|
|
(when (and (featurep 'eldoc) (>= emacs-major-version 25))
|
|
|
|
|
(global-eldoc-mode -1))
|
2015-11-10 18:01:57 -05:00
|
|
|
|
|
2016-03-29 23:48:06 -04:00
|
|
|
|
;; line highlighting
|
2016-02-26 00:08:41 -05:00
|
|
|
|
(add-hook! (prog-mode markdown-mode) 'hl-line-mode)
|
2015-11-10 18:01:57 -05:00
|
|
|
|
|
|
|
|
|
;; Disable line highlight in visual mode
|
|
|
|
|
(defvar narf--hl-line-mode nil)
|
|
|
|
|
(make-variable-buffer-local 'narf--hl-line-mode)
|
|
|
|
|
|
2015-12-09 02:03:13 -05:00
|
|
|
|
(defun narf|hl-line-on () (if narf--hl-line-mode (hl-line-mode +1)))
|
|
|
|
|
(defun narf|hl-line-off () (if narf--hl-line-mode (hl-line-mode -1)))
|
2015-11-10 18:01:57 -05:00
|
|
|
|
|
|
|
|
|
(add-hook! hl-line-mode (if hl-line-mode (setq narf--hl-line-mode t)))
|
2016-04-05 23:58:32 -04:00
|
|
|
|
(add-hook 'evil-visual-state-entry-hook 'narf|hl-line-off)
|
|
|
|
|
(add-hook 'evil-visual-state-exit-hook 'narf|hl-line-on)
|
2015-11-10 18:01:57 -05:00
|
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
|
;; Hide modeline in help windows
|
2016-03-04 22:39:48 -05:00
|
|
|
|
(defun narf|hide-mode-line ()
|
2016-03-07 01:15:42 -05:00
|
|
|
|
(setq mode-line-format nil))
|
2016-04-05 23:58:32 -04:00
|
|
|
|
(add-hook 'help-mode-hook 'narf|hide-mode-line)
|
2015-10-15 14:01:53 -04:00
|
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
|
;; Highlight TODO/FIXME/NOTE tags
|
2016-03-06 00:44:22 -05:00
|
|
|
|
(defface narf-todo-face '((t (:inherit font-lock-warning-face)))
|
|
|
|
|
"Face for TODOs")
|
|
|
|
|
(defface narf-fixme-face '((t (:inherit font-lock-warning-face)))
|
|
|
|
|
"Face for FIXMEs")
|
|
|
|
|
(defface narf-note-face '((t (:inherit font-lock-warning-face)))
|
|
|
|
|
"Face for NOTEs")
|
2015-11-07 20:16:31 -05:00
|
|
|
|
(add-hook! (prog-mode emacs-lisp-mode)
|
2015-11-18 15:22:00 -05:00
|
|
|
|
(font-lock-add-keywords nil '(("\\<\\(TODO\\((.+)\\)?:?\\)" 1 'narf-todo-face prepend)
|
|
|
|
|
("\\<\\(FIXME\\((.+)\\)?:?\\)" 1 'narf-fixme-face prepend)
|
|
|
|
|
("\\<\\(NOTE\\((.+)\\)?:?\\)" 1 'narf-note-face prepend))))
|
2015-06-04 18:23:21 -04:00
|
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
|
;; Fade out when unfocused
|
2015-11-18 15:22:00 -05:00
|
|
|
|
(add-hook! focus-in (set-frame-parameter nil 'alpha 100))
|
2016-03-31 13:18:08 -04:00
|
|
|
|
(add-hook! focus-out (set-frame-parameter nil 'alpha 85))
|
2015-11-10 18:02:09 -05:00
|
|
|
|
|
2016-03-03 15:04:14 -05:00
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
;; Plugins
|
|
|
|
|
;;
|
|
|
|
|
|
2015-11-30 16:51:13 -05:00
|
|
|
|
(use-package visual-fill-column :defer t)
|
|
|
|
|
|
2016-04-12 02:59:36 -04:00
|
|
|
|
(use-package highlight-indentation
|
|
|
|
|
:commands (highlight-indentation-mode highlight-indentation-current-column-mode)
|
|
|
|
|
:init
|
|
|
|
|
(add-hook! (web-mode nxml-mode yaml-mode json-mode scss-mode
|
|
|
|
|
c-mode-common ruby-mode python-mode lua-mode)
|
|
|
|
|
'highlight-indentation-mode)
|
|
|
|
|
|
|
|
|
|
:config
|
|
|
|
|
;; 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
|
|
|
|
|
(narf/add-whitespace)
|
|
|
|
|
(add-hook 'after-save-hook 'narf/add-whitespace nil t))
|
|
|
|
|
(remove-hook 'after-save-hook 'narf/add-whitespace t)))
|
|
|
|
|
(add-hook 'before-save-hook 'delete-trailing-whitespace))
|
|
|
|
|
|
2016-04-14 12:54:25 -04:00
|
|
|
|
(use-package imenu-list
|
|
|
|
|
:commands (imenu-list-minor-mode)
|
|
|
|
|
:config
|
|
|
|
|
(setq imenu-list-mode-line-format nil
|
|
|
|
|
imenu-list-position 'right
|
|
|
|
|
imenu-list-size 35)
|
|
|
|
|
|
|
|
|
|
(map! :map imenu-list-major-mode-map
|
|
|
|
|
:n [escape] 'narf/imenu-list-quit
|
|
|
|
|
:n "RET" 'imenu-list-goto-entry
|
|
|
|
|
:n "SPC" 'imenu-list-display-entry
|
|
|
|
|
:n [tab] 'hs-toggle-hiding))
|
|
|
|
|
|
2015-10-15 14:01:53 -04:00
|
|
|
|
(use-package rainbow-delimiters
|
|
|
|
|
:commands rainbow-delimiters-mode
|
2016-03-06 00:44:22 -05:00
|
|
|
|
:init
|
2016-03-29 01:08:50 -04:00
|
|
|
|
(add-hook! (emacs-lisp-mode lisp-mode js2-mode scss-mode c-mode-common)
|
2016-03-06 00:44:22 -05:00
|
|
|
|
'rainbow-delimiters-mode)
|
|
|
|
|
:config
|
|
|
|
|
(setq rainbow-delimiters-max-face-count 4))
|
2015-10-15 14:01:53 -04:00
|
|
|
|
|
2016-04-12 02:56:30 -04:00
|
|
|
|
(use-package rainbow-mode
|
|
|
|
|
:commands (rainbow-mode)
|
2015-11-18 15:22:00 -05:00
|
|
|
|
:init
|
2016-04-05 23:58:32 -04:00
|
|
|
|
;; hl-line-mode and rainbow-mode don't play well together
|
2015-11-18 15:22:00 -05:00
|
|
|
|
(add-hook! rainbow-mode
|
|
|
|
|
(when narf--hl-line-mode
|
|
|
|
|
(hl-line-mode (if rainbow-mode -1 1)))))
|
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-03-23 11:51:29 -04:00
|
|
|
|
(defface linum-highlight-face '((t (:inherit linum))) "Face for line highlights")
|
2015-06-06 06:40:33 -04:00
|
|
|
|
(defvar narf--hl-nlinum-overlay nil)
|
2015-11-09 15:52:42 -05:00
|
|
|
|
(defvar narf--hl-nlinum-line nil)
|
2016-03-29 13:40:12 -04:00
|
|
|
|
(defvar nlinum-format "%4d ")
|
2015-11-19 05:50:04 -05:00
|
|
|
|
(setq linum-format "%3d ")
|
2015-11-09 15:52:42 -05:00
|
|
|
|
:init
|
2015-10-03 04:56:33 -04:00
|
|
|
|
(defun narf|nlinum-enable ()
|
|
|
|
|
(nlinum-mode +1)
|
2015-11-14 02:35:15 -05:00
|
|
|
|
(add-hook 'post-command-hook 'narf|nlinum-hl-line t))
|
2015-10-21 05:16:32 -04:00
|
|
|
|
|
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)
|
2015-11-10 18:01:57 -05:00
|
|
|
|
'narf|nlinum-enable)
|
2015-10-03 04:56:33 -04:00
|
|
|
|
:config
|
2015-06-06 06:40:33 -04:00
|
|
|
|
(defun narf|nlinum-unhl-line ()
|
2015-11-14 02:35:15 -05:00
|
|
|
|
"Unhighlight line number"
|
2015-06-06 06:40:33 -04:00
|
|
|
|
(when narf--hl-nlinum-overlay
|
2015-12-09 01:59:50 -05:00
|
|
|
|
(let* ((disp (get-text-property
|
|
|
|
|
0 'display (overlay-get narf--hl-nlinum-overlay 'before-string)))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
(str (nth 1 disp)))
|
|
|
|
|
(put-text-property 0 (length str) 'face 'linum str)
|
|
|
|
|
(setq narf--hl-nlinum-overlay nil
|
2015-12-09 01:59:50 -05:00
|
|
|
|
narf--hl-nlinum-line nil)
|
|
|
|
|
disp)))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
|
|
|
|
|
(defun narf|nlinum-hl-line (&optional line)
|
2015-11-14 02:35:15 -05:00
|
|
|
|
"Highlight line number"
|
|
|
|
|
(let ((line-no (or line (string-to-number (format-mode-line "%l")))))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
(when (and nlinum-mode (not (eq line-no narf--hl-nlinum-line)))
|
2015-12-09 01:59:50 -05:00
|
|
|
|
(let* ((pbol (if line
|
|
|
|
|
(save-excursion (goto-char (point-min))
|
|
|
|
|
(forward-line line-no)
|
|
|
|
|
(line-beginning-position))
|
2015-11-14 02:35:15 -05:00
|
|
|
|
(line-beginning-position)))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
(peol (1+ pbol)))
|
|
|
|
|
;; Handle EOF case
|
2015-10-28 03:31:51 -04:00
|
|
|
|
(let ((max (point-max)))
|
|
|
|
|
(when (>= peol max)
|
|
|
|
|
(setq peol max)))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
(jit-lock-fontify-now pbol peol)
|
2015-12-09 01:59:50 -05:00
|
|
|
|
(let ((ov (-first (lambda (item) (overlay-get item 'nlinum)) (overlays-in pbol peol))))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
(when ov
|
|
|
|
|
(narf|nlinum-unhl-line)
|
2015-11-09 15:52:42 -05:00
|
|
|
|
(let ((str (nth 1 (get-text-property 0 'display (overlay-get ov 'before-string)))))
|
2015-06-06 06:40:33 -04:00
|
|
|
|
(put-text-property 0 (length str) 'face 'linum-highlight-face str)
|
|
|
|
|
(setq narf--hl-nlinum-overlay ov
|
|
|
|
|
narf--hl-nlinum-line line-no))))))))
|
|
|
|
|
|
2015-06-15 09:05:52 +02:00
|
|
|
|
(add-hook! nlinum-mode
|
2015-10-26 01:29:38 -04:00
|
|
|
|
(setq nlinum--width
|
2015-12-09 01:59:50 -05:00
|
|
|
|
(length (save-excursion (goto-char (point-max))
|
|
|
|
|
(format-mode-line "%l"))))))
|
2015-10-26 01:29:38 -04:00
|
|
|
|
|
2015-06-06 06:40:33 -04:00
|
|
|
|
|
2015-09-27 23:36:09 -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
|
|
|
|
|
(defvar narf--env-version nil)
|
|
|
|
|
(defvar narf--env-command nil)
|
|
|
|
|
(make-variable-buffer-local 'narf--env-version)
|
|
|
|
|
(make-variable-buffer-local 'narf--env-command)
|
2015-09-30 13:47:57 -04:00
|
|
|
|
:config
|
2015-09-28 15:55:25 -04:00
|
|
|
|
(setq-default
|
2015-10-15 14:01:53 -04:00
|
|
|
|
powerline-default-separator nil
|
2016-04-10 18:51:07 -04:00
|
|
|
|
powerline-height 20
|
2015-11-19 05:52:22 -05:00
|
|
|
|
spaceline-highlight-face-func 'spaceline-highlight-face-evil-state)
|
2015-09-28 15:55:25 -04:00
|
|
|
|
|
2015-10-01 03:40:09 -04:00
|
|
|
|
(defface mode-line-is-modified nil "Face for mode-line modified symbol")
|
2015-10-13 00:46:17 -04:00
|
|
|
|
(defface mode-line-buffer-file 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
|
|
|
|
|
(if buffer-file-name
|
|
|
|
|
(let* ((project-path (let (projectile-require-project-root) (projectile-project-root)))
|
|
|
|
|
(buffer-path (f-relative buffer-file-name project-path))
|
2016-04-12 15:57:20 -04:00
|
|
|
|
(max-length (truncate (/ (window-width) 2)))
|
2016-03-29 23:48:06 -04:00
|
|
|
|
(path-len (length buffer-path)))
|
2016-04-12 15:57:20 -04:00
|
|
|
|
(if (> path-len max-length)
|
|
|
|
|
(f-filename buffer-path)
|
|
|
|
|
(concat (f-filename project-path) "/" buffer-path)))
|
2016-03-29 23:48:06 -04:00
|
|
|
|
"%b")
|
|
|
|
|
:face (if active 'mode-line-buffer-file 'mode-line-inactive)
|
|
|
|
|
:skip-alternate t
|
|
|
|
|
:tight-right t)
|
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *remote-host
|
|
|
|
|
"Hostname for remote buffers."
|
|
|
|
|
(concat "@" (file-remote-p default-directory 'host))
|
|
|
|
|
:when (file-remote-p default-directory 'host))
|
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *buffer-modified
|
|
|
|
|
(concat
|
|
|
|
|
(when buffer-file-name
|
|
|
|
|
(concat
|
|
|
|
|
(when (buffer-modified-p) "[+]")
|
|
|
|
|
(unless (file-exists-p buffer-file-name) "[!]")))
|
|
|
|
|
(if buffer-read-only "[RO]"))
|
|
|
|
|
:face mode-line-is-modified
|
|
|
|
|
:when (not (string-prefix-p "*" (buffer-name)))
|
|
|
|
|
:skip-alternate t
|
|
|
|
|
:tight t)
|
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *buffer-position
|
|
|
|
|
"A more vim-like buffer position."
|
|
|
|
|
(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 ((eq start 1) ":Top")
|
|
|
|
|
((>= perc 100) ":Bot")
|
|
|
|
|
(t (format ":%d%%%%" perc))))))
|
|
|
|
|
:tight t)
|
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *vc
|
|
|
|
|
"Version control info"
|
|
|
|
|
(powerline-raw
|
|
|
|
|
(concat (replace-regexp-in-string
|
|
|
|
|
(format "^ %s" (vc-backend buffer-file-name))
|
|
|
|
|
"" vc-mode)))
|
|
|
|
|
:when (and active vc-mode)
|
|
|
|
|
:face other-face
|
|
|
|
|
:tight-right t)
|
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *env-version
|
|
|
|
|
"Shows the environment version of a mode (e.g. pyenv for python or rbenv for ruby).
|
2015-12-12 01:25:14 -05:00
|
|
|
|
See `define-env-command!' to define one for a mode."
|
2016-03-29 23:48:06 -04:00
|
|
|
|
narf--env-version
|
|
|
|
|
:when narf--env-version
|
|
|
|
|
:face other-face
|
|
|
|
|
:skip-alternate t
|
|
|
|
|
:tight-right t)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; 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-03-29 23:48:06 -04:00
|
|
|
|
(let ((here anzu--current-position)
|
|
|
|
|
(total anzu--total-matched))
|
|
|
|
|
(format " %s/%d%s "
|
|
|
|
|
(anzu--format-here-position here total)
|
|
|
|
|
total (if anzu--overflow-p "+" "")))
|
|
|
|
|
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
|
|
|
|
:when (and (> anzu--total-matched 0) (evil-ex-hl-active-p 'evil-ex-search))
|
|
|
|
|
:skip-alternate t
|
|
|
|
|
:tight t)
|
|
|
|
|
|
|
|
|
|
;; TODO mode-line-iedit-face default face
|
|
|
|
|
(spaceline-define-segment *iedit
|
|
|
|
|
"Show the number of matches and what match you're on (or after). Requires iedit."
|
|
|
|
|
(let ((this-oc (iedit-find-current-occurrence-overlay))
|
|
|
|
|
(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))
|
|
|
|
|
:when (bound-and-true-p iedit-mode)
|
|
|
|
|
:tight t
|
|
|
|
|
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
|
|
|
|
:skip-alternate t)
|
|
|
|
|
|
|
|
|
|
(defface mode-line-substitute-face nil "")
|
|
|
|
|
(spaceline-define-segment *evil-substitute
|
|
|
|
|
"Show number of :s matches in real time."
|
|
|
|
|
(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)
|
|
|
|
|
" ... "))
|
|
|
|
|
:when (and (evil-ex-p) (evil-ex-hl-active-p 'evil-ex-substitute))
|
|
|
|
|
:tight t
|
|
|
|
|
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
|
|
|
|
:skip-alternate t)
|
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *macro-recording
|
|
|
|
|
"Show when recording macro"
|
|
|
|
|
(format "%s ▶" (char-to-string evil-this-macro))
|
|
|
|
|
:when (and active defining-kbd-macro)
|
|
|
|
|
:face highlight-face
|
|
|
|
|
:skip-alternate t)
|
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *buffer-encoding-abbrev
|
|
|
|
|
"The line ending convention used in the buffer."
|
|
|
|
|
(symbol-name buffer-file-coding-system)
|
|
|
|
|
:when (not (string-match-p "\\(utf-8\\|undecided\\)"
|
|
|
|
|
(symbol-name buffer-file-coding-system))))
|
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *major-mode
|
|
|
|
|
(powerline-raw
|
|
|
|
|
(concat
|
|
|
|
|
(and (featurep 'face-remap) (/= text-scale-mode-amount 0) (format "(%+d) " text-scale-mode-amount))
|
|
|
|
|
(if (stringp mode-name) mode-name (car mode-name))
|
|
|
|
|
(if (stringp mode-line-process) mode-line-process)))
|
|
|
|
|
:tight-right t)
|
|
|
|
|
|
|
|
|
|
(defun narf--col-at-pos (pos)
|
|
|
|
|
(save-excursion (goto-char pos) (current-column)))
|
|
|
|
|
(spaceline-define-segment *selection-info
|
|
|
|
|
"Information about the size of the current selection, when applicable.
|
2015-12-11 16:51:04 -05:00
|
|
|
|
Supports both Emacs and Evil cursor conventions."
|
2016-03-29 23:48:06 -04:00
|
|
|
|
(let ((reg-beg (region-beginning))
|
|
|
|
|
(reg-end (region-end)))
|
|
|
|
|
(let* ((lines (count-lines reg-beg (min (1+ reg-end) (point-max))))
|
|
|
|
|
(chars (- (1+ reg-end) reg-beg))
|
|
|
|
|
(cols (1+ (abs (- (narf--col-at-pos reg-end)
|
|
|
|
|
(narf--col-at-pos reg-beg)))))
|
|
|
|
|
(evil (eq 'visual evil-state))
|
|
|
|
|
(rect (or (bound-and-true-p rectangle-mark-mode)
|
|
|
|
|
(and evil (eq 'block evil-visual-selection))))
|
|
|
|
|
(multi-line (or (> lines 1) (eq 'line evil-visual-selection))))
|
|
|
|
|
(cond
|
|
|
|
|
(rect (format "%dx%dB" lines (if evil cols (1- cols))))
|
|
|
|
|
(multi-line
|
|
|
|
|
(if (and (eq evil-state 'visual) (eq evil-this-type 'line))
|
|
|
|
|
(format "%dL" lines)
|
|
|
|
|
(format "%dC %dL" chars lines)))
|
|
|
|
|
(t (format "%dC" (if evil chars (1- chars)))))))
|
|
|
|
|
:when (eq 'visual evil-state)
|
|
|
|
|
:face highlight-face
|
|
|
|
|
:skip-alternate t)
|
|
|
|
|
|
|
|
|
|
;; flycheck
|
|
|
|
|
(defun narf--flycheck-count (state)
|
|
|
|
|
"Return flycheck information for the given error type STATE."
|
|
|
|
|
(let* ((counts (flycheck-count-errors flycheck-current-errors))
|
|
|
|
|
(errorp (flycheck-has-current-errors-p state))
|
|
|
|
|
(running (eq 'running flycheck-last-status-change))
|
|
|
|
|
(err (cdr (assq state counts))))
|
|
|
|
|
(when errorp (if running "?" err))))
|
|
|
|
|
|
|
|
|
|
(defface spaceline-flycheck-error
|
|
|
|
|
'((t (:foreground "#FC5C94" :distant-foreground "#A20C41")))
|
|
|
|
|
"Face for flycheck error feedback in the modeline.")
|
|
|
|
|
(defface spaceline-flycheck-warning
|
|
|
|
|
'((t (:foreground "#F3EA98" :distant-foreground "#968B26")))
|
|
|
|
|
"Face for flycheck warning feedback in the modeline.")
|
|
|
|
|
(defface spaceline-flycheck-info
|
|
|
|
|
'((t (:foreground "#8DE6F7" :distant-foreground "#21889B")))
|
|
|
|
|
"Face for flycheck info feedback in the modeline.")
|
|
|
|
|
|
|
|
|
|
(defvar narf--flycheck-err-cache nil "")
|
|
|
|
|
(defvar narf--flycheck-cache nil "")
|
|
|
|
|
(spaceline-define-segment *flycheck
|
|
|
|
|
"Persistent and cached flycheck indicators in the mode-line."
|
|
|
|
|
(or (and (or (eq narf--flycheck-err-cache narf--flycheck-cache)
|
|
|
|
|
(memq flycheck-last-status-change '(running not-checked)))
|
|
|
|
|
narf--flycheck-cache)
|
|
|
|
|
(and (setq narf--flycheck-err-cache flycheck-current-errors)
|
|
|
|
|
(setq narf--flycheck-cache
|
|
|
|
|
(let ((fe (narf--flycheck-count 'error))
|
|
|
|
|
(fw (narf--flycheck-count 'warning))
|
|
|
|
|
(fi (narf--flycheck-count 'info)))
|
|
|
|
|
(concat
|
|
|
|
|
(when fe (powerline-raw (format " ⚠%s " fe) 'spaceline-flycheck-error))
|
|
|
|
|
(when fw (powerline-raw (format " ⚠%s " fw) 'spaceline-flycheck-warning))
|
|
|
|
|
(when fi (powerline-raw (format " ⚠%s " fi) 'spaceline-flycheck-info)))))))
|
|
|
|
|
:when (and (bound-and-true-p flycheck-mode)
|
|
|
|
|
(or flycheck-current-errors
|
|
|
|
|
(eq 'running flycheck-last-status-change)))
|
|
|
|
|
:tight t
|
|
|
|
|
:skip-alternate t)
|
|
|
|
|
|
|
|
|
|
(spaceline-define-segment *hud
|
|
|
|
|
"A HUD that shows which part of the buffer is currently visible."
|
|
|
|
|
(powerline-hud (if active 'spaceline-highlight-face 'region) line-face 1)
|
|
|
|
|
:tight-right t)
|
2015-11-14 02:37:10 -05:00
|
|
|
|
|
2016-04-12 15:57:20 -04:00
|
|
|
|
(defun narf-spaceline-init ()
|
|
|
|
|
(spaceline-install
|
|
|
|
|
;; Left side
|
|
|
|
|
'(*macro-recording
|
|
|
|
|
(*anzu *iedit *evil-substitute *flycheck)
|
|
|
|
|
(*buffer-path *remote-host)
|
|
|
|
|
*buffer-modified
|
|
|
|
|
*vc
|
|
|
|
|
)
|
|
|
|
|
;; Right side
|
|
|
|
|
'(*selection-info
|
|
|
|
|
*buffer-encoding-abbrev
|
|
|
|
|
*major-mode
|
|
|
|
|
*env-version
|
|
|
|
|
(global :when active)
|
|
|
|
|
("%l/%c" *buffer-position)
|
|
|
|
|
*hud
|
|
|
|
|
)))
|
|
|
|
|
|
2015-09-30 13:47:57 -04:00
|
|
|
|
;; Initialize modeline
|
2016-04-12 15:57:20 -04:00
|
|
|
|
(narf-spaceline-init))
|
2015-06-04 18:23:21 -04:00
|
|
|
|
|
|
|
|
|
(provide 'core-ui)
|
|
|
|
|
;;; core-ui.el ends here
|