doomemacs/core/core-ui.el

472 lines
18 KiB
EmacsLisp
Raw Normal View History

2015-06-06 18:40:33 +08:00
;;; core-ui.el --- interface settings
2015-06-15 15:05:52 +08:00
2015-06-05 06:23:21 +08:00
(setq-default
2016-03-30 11:48:06 +08:00
blink-matching-paren nil ; don't blink matching delimiters--too distracting
2015-11-10 04:52:42 +08:00
show-paren-delay 0.075
2015-10-26 13:29:38 +08:00
2016-03-30 11:48:06 +08:00
;;cursor-in-non-selected-windows nil ; no cursors except in active buffer
2015-12-09 15:03:13 +08:00
highlight-nonselected-windows nil
2016-03-04 04:04:14 +08:00
hl-line-sticky-flag nil ; only highlight in one window
uniquify-buffer-name-style nil ; my mode-line does this for me
2015-12-09 15:03:13 +08:00
visible-bell nil ; silence of the bells
use-dialog-box nil ; always avoid GUI
2016-03-30 11:48:06 +08:00
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
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
split-width-threshold nil ; favor horizontal splits
2015-12-12 16:29:58 +08:00
show-help-function nil ; hide :help-echo text
2016-03-04 04:04:14 +08:00
;; Disable bidirectional text support for slight performance bonus
2016-02-11 15:08:32 +08:00
bidi-display-reordering 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
2015-12-09 15:03:13 +08:00
resize-mini-windows 'grow-only
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
max-mini-window-height 0.3
2016-03-04 04:04:14 +08:00
;; Remove arrow on the right fringe when wrapped
2015-12-09 15:03:13 +08:00
fringe-indicator-alist (delq (assoc 'continuation fringe-indicator-alist)
fringe-indicator-alist))
2016-04-06 11:58:32 +08: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-04 04:04:14 +08:00
(blink-cursor-mode 1) ; blink cursor
(tooltip-mode -1) ; show tooltips in echo area
2016-03-30 11:48:06 +08:00
;; set up minibuffer and fringe
2016-03-04 04:04:14 +08:00
(if (not window-system)
(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")))
;; set fonts
2016-03-04 04:04:14 +08:00
(narf/load-font narf-default-font)
(set-face-attribute 'default t :font narf-default-font)
2016-03-30 11:48:06 +08:00
;; standardize fringe width
2016-03-04 04:04:14 +08:00
(fringe-mode narf-fringe-size)
2016-03-10 10:40:18 +08:00
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)
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
(set-fringe-bitmap-face 'tilde 'font-lock-comment-face)
;; Brighter minibuffer when active
2016-03-30 11:48:06 +08:00
(defface narf-minibuffer-active '((t (:inherit mode-line)))
"Face for active minibuffer")
2016-03-04 04:04:14 +08: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-10 10:40:18 +08:00
(add-hook! minibuffer-setup 'narf|minibuffer-setup)
(add-hook! 'after-init-hook (set-window-fringes (minibuffer-window) 0 0 nil)))
2015-11-14 15:35:15 +08:00
2016-03-30 11:48:06 +08:00
;; Try to display unicode characters without upsetting line-hieght (as much as possible)
2016-03-04 04:04:14 +08:00
(mapc (lambda (set)
2016-03-06 13:44:22 +08:00
(let ((font (car set))
(chars (cadr set))
2016-03-04 04:04:14 +08: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 13:44:22 +08:00
'(("DejaVu Sans" (?☑ ?☐ ?⚠ ?★ ?♭ ?♯
2016-03-04 04:04:14 +08:00
?➊ ?➋ ?➌ ?➍ ?➎ ?❻ ?➐ ?➑ ?➒ ?➓))
;; File attachment symbols (for org-mode)
("FontAwesome" (? ? ? ? ? ? ? ? ?) 13)
2016-03-30 11:48:06 +08:00
;; Certain math symbols
2016-03-04 04:04:14 +08:00
("Hack" (?× ?∙ ?⌉ ?⌈ ?⌊ ?⌋
?∩ ? ?⊆ ?⊂ ?⊄ ?⊇ ?⊃ ?⊅
?⇒ ?⇐ ?⇔ ?↔ ?→ ?≡ ?∴ ?∵ ?⊕ ?∀ ?∃ ?∄ ?∈ ?∉
? ?∧ ))))
2016-03-30 11:48:06 +08:00
;; on by default in Emacs 25; I prefer to enable on a mode-by-mode basis, so disable it
2016-01-31 10:16:10 +08:00
(when (and (featurep 'eldoc) (>= emacs-major-version 25))
(global-eldoc-mode -1))
2015-11-11 07:01:57 +08:00
2016-03-30 11:48:06 +08:00
;; line highlighting
2016-02-26 13:08:41 +08:00
(add-hook! (prog-mode markdown-mode) 'hl-line-mode)
2015-11-11 07:01:57 +08:00
;; Disable line highlight in visual mode
(defvar narf--hl-line-mode nil)
(make-variable-buffer-local 'narf--hl-line-mode)
2015-12-09 15:03:13 +08: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-11 07:01:57 +08:00
(add-hook! hl-line-mode (if hl-line-mode (setq narf--hl-line-mode t)))
2016-04-06 11:58:32 +08: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-11 07:01:57 +08:00
2016-03-04 04:04:14 +08:00
;; Hide modeline in help windows
2016-03-05 11:39:48 +08:00
(defun narf|hide-mode-line ()
2016-03-07 14:15:42 +08:00
(setq mode-line-format nil))
2016-04-06 11:58:32 +08:00
(add-hook 'help-mode-hook 'narf|hide-mode-line)
2016-03-04 04:04:14 +08:00
;; Highlight TODO/FIXME/NOTE tags
2016-03-06 13:44:22 +08: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-08 09:16:31 +08:00
(add-hook! (prog-mode emacs-lisp-mode)
2015-11-19 04:22:00 +08: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-05 06:23:21 +08:00
2016-03-04 04:04:14 +08:00
;; Fade out when unfocused
2015-11-19 04:22:00 +08:00
(add-hook! focus-in (set-frame-parameter nil 'alpha 100))
2016-04-01 01:18:08 +08:00
(add-hook! focus-out (set-frame-parameter nil 'alpha 85))
2015-11-11 07:02:09 +08:00
2016-03-04 04:04:14 +08:00
;;
;; Plugins
;;
(use-package visual-fill-column :defer t)
(use-package rainbow-delimiters
:commands rainbow-delimiters-mode
2016-03-06 13:44:22 +08:00
:init
2016-03-29 13:08:50 +08:00
(add-hook! (emacs-lisp-mode lisp-mode js2-mode scss-mode c-mode-common)
2016-03-06 13:44:22 +08:00
'rainbow-delimiters-mode)
:config
(setq rainbow-delimiters-max-face-count 4))
2015-11-10 04:52:42 +08:00
(use-package rainbow-mode :defer t
2015-11-19 04:22:00 +08:00
:init
2016-04-06 11:58:32 +08:00
;; hl-line-mode and rainbow-mode don't play well together
2015-11-19 04:22:00 +08:00
(add-hook! rainbow-mode
(when narf--hl-line-mode
(hl-line-mode (if rainbow-mode -1 1)))))
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
2016-03-23 23:51:29 +08:00
(defface linum-highlight-face '((t (:inherit linum))) "Face for line highlights")
2015-06-06 18:40:33 +08:00
(defvar narf--hl-nlinum-overlay nil)
2015-11-10 04:52:42 +08:00
(defvar narf--hl-nlinum-line nil)
2016-03-30 01:40:12 +08:00
(defvar nlinum-format "%4d ")
2015-11-19 18:50:04 +08:00
(setq linum-format "%3d ")
2015-11-10 04:52:42 +08:00
:init
2015-10-03 16:56:33 +08:00
(defun narf|nlinum-enable ()
(nlinum-mode +1)
2015-11-14 15:35:15 +08:00
(add-hook 'post-command-hook 'narf|nlinum-hl-line t))
2015-10-21 17:16:32 +08:00
2015-11-11 07:01:57 +08:00
(add-hook!
2015-12-11 05:15:09 +08:00
(markdown-mode prog-mode scss-mode web-mode conf-mode)
2015-11-11 07:01:57 +08:00
'narf|nlinum-enable)
2015-10-03 16:56:33 +08:00
:config
2015-06-06 18:40:33 +08:00
(defun narf|nlinum-unhl-line ()
2015-11-14 15:35:15 +08:00
"Unhighlight line number"
2015-06-06 18:40:33 +08:00
(when narf--hl-nlinum-overlay
2015-12-09 14:59:50 +08:00
(let* ((disp (get-text-property
0 'display (overlay-get narf--hl-nlinum-overlay 'before-string)))
2015-06-06 18:40:33 +08:00
(str (nth 1 disp)))
(put-text-property 0 (length str) 'face 'linum str)
(setq narf--hl-nlinum-overlay nil
2015-12-09 14:59:50 +08:00
narf--hl-nlinum-line nil)
disp)))
2015-06-06 18:40:33 +08:00
(defun narf|nlinum-hl-line (&optional line)
2015-11-14 15:35:15 +08:00
"Highlight line number"
(let ((line-no (or line (string-to-number (format-mode-line "%l")))))
2015-06-06 18:40:33 +08:00
(when (and nlinum-mode (not (eq line-no narf--hl-nlinum-line)))
2015-12-09 14:59:50 +08:00
(let* ((pbol (if line
(save-excursion (goto-char (point-min))
(forward-line line-no)
(line-beginning-position))
2015-11-14 15:35:15 +08:00
(line-beginning-position)))
2015-06-06 18:40:33 +08:00
(peol (1+ pbol)))
;; Handle EOF case
2015-10-28 15:31:51 +08:00
(let ((max (point-max)))
(when (>= peol max)
(setq peol max)))
2015-06-06 18:40:33 +08:00
(jit-lock-fontify-now pbol peol)
2015-12-09 14:59:50 +08:00
(let ((ov (-first (lambda (item) (overlay-get item 'nlinum)) (overlays-in pbol peol))))
2015-06-06 18:40:33 +08:00
(when ov
(narf|nlinum-unhl-line)
2015-11-10 04:52:42 +08:00
(let ((str (nth 1 (get-text-property 0 'display (overlay-get ov 'before-string)))))
2015-06-06 18:40:33 +08: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 15:05:52 +08:00
(add-hook! nlinum-mode
2015-10-26 13:29:38 +08:00
(setq nlinum--width
2015-12-09 14:59:50 +08:00
(length (save-excursion (goto-char (point-max))
(format-mode-line "%l"))))))
2015-10-26 13:29:38 +08:00
2015-06-06 18:40:33 +08:00
2015-09-28 11:36:09 +08:00
;; Mode-line ;;;;;;;;;;;;;;;;;;;;;;;;;;;
2015-06-06 18:40:33 +08:00
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
(use-package spaceline
2015-11-07 13:20:04 +08: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-10-01 01:47:57 +08:00
:config
2015-09-29 03:55:25 +08:00
(setq-default
powerline-default-separator nil
2016-03-30 11:48:06 +08:00
powerline-height 18
2015-11-19 18:52:22 +08:00
spaceline-highlight-face-func 'spaceline-highlight-face-evil-state)
2015-09-29 03:55:25 +08:00
(defface mode-line-is-modified nil "Face for mode-line modified symbol")
2015-10-13 12:46:17 +08:00
(defface mode-line-buffer-file nil "Face for mode-line buffer file path")
2015-10-01 01:47:57 +08:00
2016-03-30 11:48:06 +08: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))
(max-length (truncate (/ (window-width) 1.75)))
(path-len (length buffer-path)))
(concat (file-name-nondirectory (directory-file-name project-path))
"/"
(if (> path-len max-length)
(concat "" (replace-regexp-in-string
"^.*?/" "/"
(substring buffer-path (- path-len max-length) path-len)))
buffer-path)))
"%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 14:25:14 +08:00
See `define-env-command!' to define one for a mode."
2016-03-30 11:48:06 +08: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
anzu to be enabled."
2016-03-30 11:48:06 +08: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)
(spaceline-define-segment *buffer-size
(powerline-buffer-size)
:tight-right t
:skip-alternate 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.
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
Supports both Emacs and Evil cursor conventions."
2016-03-30 11:48:06 +08: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-10-01 01:47:57 +08:00
;; Initialize modeline
2015-09-29 03:55:25 +08:00
(spaceline-install
;; Left side
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
'(*macro-recording
2016-02-26 22:43:03 +08:00
((*anzu *iedit *evil-substitute *flycheck)
:fallback *buffer-size)
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
(*buffer-path *remote-host)
*buffer-modified
*vc
)
2015-09-29 03:55:25 +08:00
;; Right side
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
'(*selection-info
*buffer-encoding-abbrev
*major-mode
*env-version
2015-09-29 03:55:25 +08:00
(global :when active)
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
("%l/%c" *buffer-position)
*hud
)))
2015-06-05 06:23:21 +08:00
(provide 'core-ui)
;;; core-ui.el ends here