More cleanup
This commit is contained in:
parent
057403cee8
commit
91ebf03a59
2 changed files with 244 additions and 257 deletions
|
@ -8,23 +8,23 @@
|
||||||
flycheck-check-syntax-automatically '(save mode-enabled)
|
flycheck-check-syntax-automatically '(save mode-enabled)
|
||||||
flycheck-disabled-checkers '(emacs-lisp emacs-lisp-checkdoc make))
|
flycheck-disabled-checkers '(emacs-lisp emacs-lisp-checkdoc make))
|
||||||
:config
|
:config
|
||||||
(use-package flycheck-package :config (flycheck-package-setup))
|
(require 'flycheck-package)
|
||||||
|
(flycheck-package-setup)
|
||||||
|
|
||||||
(use-package flycheck-pos-tip
|
(require 'flycheck-pos-tip)
|
||||||
:config
|
(setq flycheck-pos-tip-timeout 10
|
||||||
(setq flycheck-pos-tip-timeout 10
|
flycheck-display-errors-delay 0.5)
|
||||||
flycheck-display-errors-delay 0.5)
|
(flycheck-pos-tip-mode +1)
|
||||||
(flycheck-pos-tip-mode +1))
|
|
||||||
|
|
||||||
(evil-initial-state 'flycheck-error-list-mode 'emacs)
|
(evil-initial-state 'flycheck-error-list-mode 'emacs)
|
||||||
(map! (:map flycheck-error-list-mode-map
|
(map! :map flycheck-error-list-mode-map
|
||||||
:n [escape] 'kill-this-buffer
|
:n [escape] 'kill-this-buffer
|
||||||
:n "q" 'kill-this-buffer
|
:n "q" 'kill-this-buffer
|
||||||
:n "C-n" 'flycheck-error-list-next-error
|
:n "C-n" 'flycheck-error-list-next-error
|
||||||
:n "C-p" 'flycheck-error-list-previous-error
|
:n "C-p" 'flycheck-error-list-previous-error
|
||||||
:n "j" 'flycheck-error-list-next-error
|
:n "j" 'flycheck-error-list-next-error
|
||||||
:n "k" 'flycheck-error-list-previous-error
|
:n "k" 'flycheck-error-list-previous-error
|
||||||
:n "RET" 'flycheck-error-list-goto-error))
|
:n "RET" 'flycheck-error-list-goto-error)
|
||||||
|
|
||||||
;; And on ESC in normal mode.
|
;; And on ESC in normal mode.
|
||||||
(advice-add 'evil-force-normal-state :after 'narf*flycheck-buffer)
|
(advice-add 'evil-force-normal-state :after 'narf*flycheck-buffer)
|
||||||
|
|
473
core/core-ui.el
473
core/core-ui.el
|
@ -1,23 +1,20 @@
|
||||||
;;; core-ui.el --- interface settings
|
;;; core-ui.el --- interface settings
|
||||||
|
|
||||||
(setq-default
|
(setq-default
|
||||||
blink-matching-paren nil
|
blink-matching-paren nil ; don't blink matching delimiters--too distracting
|
||||||
show-paren-delay 0.075
|
show-paren-delay 0.075
|
||||||
|
|
||||||
;; Multiple cursors across buffers cause a strange redraw delay for
|
;;cursor-in-non-selected-windows nil ; no cursors except in active buffer
|
||||||
;; some things, like auto-complete or evil-mode's cursor color
|
|
||||||
;; switching.
|
|
||||||
cursor-in-non-selected-windows t
|
|
||||||
highlight-nonselected-windows nil
|
highlight-nonselected-windows nil
|
||||||
hl-line-sticky-flag nil ; only highlight in one window
|
hl-line-sticky-flag nil ; only highlight in one window
|
||||||
|
|
||||||
uniquify-buffer-name-style nil ; my mode-line does this for me
|
uniquify-buffer-name-style nil ; my mode-line does this for me
|
||||||
visible-bell nil ; silence of the bells
|
visible-bell nil ; silence of the bells
|
||||||
use-dialog-box nil ; always avoid GUI
|
use-dialog-box nil ; always avoid GUI
|
||||||
redisplay-dont-pause t
|
redisplay-dont-pause t ; don't pause display on input
|
||||||
indicate-buffer-boundaries t
|
indicate-buffer-boundaries t ; show indicators where buffer starts/ends
|
||||||
indicate-empty-lines t
|
indicate-empty-lines t ; show indicators on empty lines
|
||||||
fringes-outside-margins t
|
fringes-outside-margins t ; switches order of fringe and margin
|
||||||
idle-update-delay 2 ; update a little less often
|
idle-update-delay 2 ; update a little less often
|
||||||
split-width-threshold nil ; favor horizontal splits
|
split-width-threshold nil ; favor horizontal splits
|
||||||
show-help-function nil ; hide :help-echo text
|
show-help-function nil ; hide :help-echo text
|
||||||
|
@ -36,29 +33,30 @@
|
||||||
(blink-cursor-mode 1) ; blink cursor
|
(blink-cursor-mode 1) ; blink cursor
|
||||||
(tooltip-mode -1) ; show tooltips in echo area
|
(tooltip-mode -1) ; show tooltips in echo area
|
||||||
|
|
||||||
;; Set up minibuffer and fringe
|
;; set up minibuffer and fringe
|
||||||
(defface narf-minibuffer-active '((t (:inherit mode-line)))
|
|
||||||
"Face for active minibuffer")
|
|
||||||
|
|
||||||
(if (not window-system)
|
(if (not window-system)
|
||||||
(menu-bar-mode -1)
|
(menu-bar-mode -1)
|
||||||
(scroll-bar-mode -1) ; no scrollbar
|
(scroll-bar-mode -1) ; no scrollbar
|
||||||
(tool-bar-mode -1) ; no toolbar
|
(tool-bar-mode -1) ; no toolbar
|
||||||
|
|
||||||
;; Set fonts
|
;; full filename in frame title
|
||||||
|
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
|
||||||
|
|
||||||
|
;; set fonts
|
||||||
(narf/load-font narf-default-font)
|
(narf/load-font narf-default-font)
|
||||||
(set-face-attribute 'default t :font narf-default-font)
|
(set-face-attribute 'default t :font narf-default-font)
|
||||||
|
|
||||||
;; Setup fringe
|
;; standardize fringe width
|
||||||
(fringe-mode narf-fringe-size)
|
(fringe-mode narf-fringe-size)
|
||||||
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
|
|
||||||
|
|
||||||
;; Tilde empty-line indicator
|
;; Show tilde in margin on empty lines
|
||||||
(define-fringe-bitmap 'tilde [64 168 16] nil nil 'center)
|
(define-fringe-bitmap 'tilde [64 168 16] nil nil 'center)
|
||||||
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
|
(setcdr (assq 'empty-line fringe-indicator-alist) 'tilde)
|
||||||
(set-fringe-bitmap-face 'tilde 'font-lock-comment-face)
|
(set-fringe-bitmap-face 'tilde 'font-lock-comment-face)
|
||||||
|
|
||||||
;; Brighter minibuffer when active
|
;; Brighter minibuffer when active
|
||||||
|
(defface narf-minibuffer-active '((t (:inherit mode-line)))
|
||||||
|
"Face for active minibuffer")
|
||||||
(defun narf|minibuffer-setup ()
|
(defun narf|minibuffer-setup ()
|
||||||
(set-window-fringes (selected-window) 0 0 nil)
|
(set-window-fringes (selected-window) 0 0 nil)
|
||||||
(make-local-variable 'face-remapping-alist)
|
(make-local-variable 'face-remapping-alist)
|
||||||
|
@ -66,7 +64,7 @@
|
||||||
(add-hook! minibuffer-setup 'narf|minibuffer-setup)
|
(add-hook! minibuffer-setup 'narf|minibuffer-setup)
|
||||||
(add-hook! 'after-init-hook (set-window-fringes (minibuffer-window) 0 0 nil)))
|
(add-hook! 'after-init-hook (set-window-fringes (minibuffer-window) 0 0 nil)))
|
||||||
|
|
||||||
;; Fix display of certain unicode characters
|
;; Try to display unicode characters without upsetting line-hieght (as much as possible)
|
||||||
(mapc (lambda (set)
|
(mapc (lambda (set)
|
||||||
(let ((font (car set))
|
(let ((font (car set))
|
||||||
(chars (cadr set))
|
(chars (cadr set))
|
||||||
|
@ -79,17 +77,17 @@
|
||||||
?➊ ?➋ ?➌ ?➍ ?➎ ?❻ ?➐ ?➑ ?➒ ?➓))
|
?➊ ?➋ ?➌ ?➍ ?➎ ?❻ ?➐ ?➑ ?➒ ?➓))
|
||||||
;; File attachment symbols (for org-mode)
|
;; File attachment symbols (for org-mode)
|
||||||
("FontAwesome" (? ? ? ? ? ? ? ? ?) 13)
|
("FontAwesome" (? ? ? ? ? ? ? ? ?) 13)
|
||||||
;; Math symbols
|
;; Certain math symbols
|
||||||
("Hack" (?× ?∙ ?÷ ?⌉ ?⌈ ?⌊ ?⌋
|
("Hack" (?× ?∙ ?÷ ?⌉ ?⌈ ?⌊ ?⌋
|
||||||
?∩ ?∪ ?⊆ ?⊂ ?⊄ ?⊇ ?⊃ ?⊅
|
?∩ ?∪ ?⊆ ?⊂ ?⊄ ?⊇ ?⊃ ?⊅
|
||||||
?⇒ ?⇐ ?⇔ ?↔ ?→ ?≡ ?∴ ?∵ ?⊕ ?∀ ?∃ ?∄ ?∈ ?∉
|
?⇒ ?⇐ ?⇔ ?↔ ?→ ?≡ ?∴ ?∵ ?⊕ ?∀ ?∃ ?∄ ?∈ ?∉
|
||||||
?∨ ?∧ ?¬))))
|
?∨ ?∧ ?¬))))
|
||||||
|
|
||||||
;; on by default in Emacs 25
|
;; on by default in Emacs 25; I prefer to enable on a mode-by-mode basis, so disable it
|
||||||
(when (and (featurep 'eldoc) (>= emacs-major-version 25))
|
(when (and (featurep 'eldoc) (>= emacs-major-version 25))
|
||||||
(global-eldoc-mode -1))
|
(global-eldoc-mode -1))
|
||||||
|
|
||||||
;; Highlight line
|
;; line highlighting
|
||||||
(add-hook! (prog-mode markdown-mode) 'hl-line-mode)
|
(add-hook! (prog-mode markdown-mode) 'hl-line-mode)
|
||||||
|
|
||||||
;; Disable line highlight in visual mode
|
;; Disable line highlight in visual mode
|
||||||
|
@ -213,243 +211,232 @@
|
||||||
:config
|
:config
|
||||||
(setq-default
|
(setq-default
|
||||||
powerline-default-separator nil
|
powerline-default-separator nil
|
||||||
powerline-height 19
|
powerline-height 18
|
||||||
spaceline-highlight-face-func 'spaceline-highlight-face-evil-state)
|
spaceline-highlight-face-func 'spaceline-highlight-face-evil-state)
|
||||||
|
|
||||||
(defface mode-line-is-modified nil "Face for mode-line modified symbol")
|
(defface mode-line-is-modified nil "Face for mode-line modified symbol")
|
||||||
(defface mode-line-buffer-file nil "Face for mode-line buffer file path")
|
(defface mode-line-buffer-file nil "Face for mode-line buffer file path")
|
||||||
|
|
||||||
(progn ;; Custom modeline segments
|
;; Custom modeline segments
|
||||||
(spaceline-define-segment *buffer-path
|
(spaceline-define-segment *buffer-path
|
||||||
(if buffer-file-name
|
(if buffer-file-name
|
||||||
(let* ((project-path (let (projectile-require-project-root) (projectile-project-root)))
|
(let* ((project-path (let (projectile-require-project-root) (projectile-project-root)))
|
||||||
(buffer-path (f-relative buffer-file-name project-path))
|
(buffer-path (f-relative buffer-file-name project-path))
|
||||||
(max-length (truncate (/ (window-width) 1.75)))
|
(max-length (truncate (/ (window-width) 1.75)))
|
||||||
(path-len (length buffer-path)))
|
(path-len (length buffer-path)))
|
||||||
(concat (file-name-nondirectory (directory-file-name project-path))
|
(concat (file-name-nondirectory (directory-file-name project-path))
|
||||||
"/"
|
"/"
|
||||||
(if (> path-len max-length)
|
(if (> path-len max-length)
|
||||||
(concat "…" (replace-regexp-in-string
|
(concat "…" (replace-regexp-in-string
|
||||||
"^.*?/" "/"
|
"^.*?/" "/"
|
||||||
(substring buffer-path (- path-len max-length) path-len)))
|
(substring buffer-path (- path-len max-length) path-len)))
|
||||||
buffer-path)))
|
buffer-path)))
|
||||||
"%b")
|
"%b")
|
||||||
:face (if active 'mode-line-buffer-file 'mode-line-inactive)
|
:face (if active 'mode-line-buffer-file 'mode-line-inactive)
|
||||||
:skip-alternate t
|
:skip-alternate t
|
||||||
:tight-right t)
|
:tight-right t)
|
||||||
|
|
||||||
(spaceline-define-segment *remote-host
|
(spaceline-define-segment *remote-host
|
||||||
"Hostname for remote buffers."
|
"Hostname for remote buffers."
|
||||||
(concat "@" (file-remote-p default-directory 'host))
|
(concat "@" (file-remote-p default-directory 'host))
|
||||||
:when (file-remote-p default-directory 'host))
|
:when (file-remote-p default-directory 'host))
|
||||||
|
|
||||||
(spaceline-define-segment *buffer-modified
|
(spaceline-define-segment *buffer-modified
|
||||||
(concat
|
(concat
|
||||||
(when buffer-file-name
|
(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 buffer-file-name
|
|
||||||
(pcase (vc-state (buffer-file-name))
|
|
||||||
(`up-to-date "")
|
|
||||||
(`edited "*")
|
|
||||||
(`added "+")
|
|
||||||
(`unregistered "?")
|
|
||||||
(`removed "-")
|
|
||||||
(`needs-merge "%")
|
|
||||||
(`needs-update "^")
|
|
||||||
(`ignored "#")
|
|
||||||
(_ "_")))))
|
|
||||||
: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).
|
|
||||||
See `define-env-command!' to define one for a mode."
|
|
||||||
narf--env-version
|
|
||||||
:when narf--env-version
|
|
||||||
:face other-face
|
|
||||||
:skip-alternate t
|
|
||||||
:tight-right t)
|
|
||||||
|
|
||||||
|
|
||||||
(progn ;; 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."
|
|
||||||
(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
|
(concat
|
||||||
(and (featurep 'face-remap) (/= text-scale-mode-amount 0) (format "(%+d) " text-scale-mode-amount))
|
(when (buffer-modified-p) "[+]")
|
||||||
(if (stringp mode-name) mode-name (car mode-name))
|
(unless (file-exists-p buffer-file-name) "[!]")))
|
||||||
(if (stringp mode-line-process) mode-line-process)))
|
(if buffer-read-only "[RO]"))
|
||||||
:tight-right t)
|
:face mode-line-is-modified
|
||||||
|
:when (not (string-prefix-p "*" (buffer-name)))
|
||||||
|
:skip-alternate t
|
||||||
|
:tight t)
|
||||||
|
|
||||||
(spaceline-define-segment *buffer-size
|
(spaceline-define-segment *buffer-position
|
||||||
(powerline-buffer-size)
|
"A more vim-like buffer position."
|
||||||
:tight-right t
|
(let ((start (window-start))
|
||||||
:skip-alternate t)
|
(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)
|
||||||
|
|
||||||
(defun narf--col-at-pos (pos)
|
(spaceline-define-segment *vc
|
||||||
(save-excursion (goto-char pos) (current-column)))
|
"Version control info"
|
||||||
(spaceline-define-segment *selection-info
|
(powerline-raw
|
||||||
"Information about the size of the current selection, when applicable.
|
(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).
|
||||||
|
See `define-env-command!' to define one for a mode."
|
||||||
|
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."
|
||||||
|
(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.
|
||||||
Supports both Emacs and Evil cursor conventions."
|
Supports both Emacs and Evil cursor conventions."
|
||||||
(let ((reg-beg (region-beginning))
|
(let ((reg-beg (region-beginning))
|
||||||
(reg-end (region-end)))
|
(reg-end (region-end)))
|
||||||
(let* ((lines (count-lines reg-beg (min (1+ reg-end) (point-max))))
|
(let* ((lines (count-lines reg-beg (min (1+ reg-end) (point-max))))
|
||||||
(chars (- (1+ reg-end) reg-beg))
|
(chars (- (1+ reg-end) reg-beg))
|
||||||
(cols (1+ (abs (- (narf--col-at-pos reg-end)
|
(cols (1+ (abs (- (narf--col-at-pos reg-end)
|
||||||
(narf--col-at-pos reg-beg)))))
|
(narf--col-at-pos reg-beg)))))
|
||||||
(evil (eq 'visual evil-state))
|
(evil (eq 'visual evil-state))
|
||||||
(rect (or (bound-and-true-p rectangle-mark-mode)
|
(rect (or (bound-and-true-p rectangle-mark-mode)
|
||||||
(and evil (eq 'block evil-visual-selection))))
|
(and evil (eq 'block evil-visual-selection))))
|
||||||
(multi-line (or (> lines 1) (eq 'line evil-visual-selection))))
|
(multi-line (or (> lines 1) (eq 'line evil-visual-selection))))
|
||||||
(cond
|
(cond
|
||||||
(rect (format "%dx%dB" lines (if evil cols (1- cols))))
|
(rect (format "%dx%dB" lines (if evil cols (1- cols))))
|
||||||
(multi-line
|
(multi-line
|
||||||
(if (and (eq evil-state 'visual) (eq evil-this-type 'line))
|
(if (and (eq evil-state 'visual) (eq evil-this-type 'line))
|
||||||
(format "%dL" lines)
|
(format "%dL" lines)
|
||||||
(format "%dC %dL" chars lines)))
|
(format "%dC %dL" chars lines)))
|
||||||
(t (format "%dC" (if evil chars (1- chars)))))))
|
(t (format "%dC" (if evil chars (1- chars)))))))
|
||||||
:when (eq 'visual evil-state)
|
:when (eq 'visual evil-state)
|
||||||
:face highlight-face
|
:face highlight-face
|
||||||
:skip-alternate t)
|
:skip-alternate t)
|
||||||
|
|
||||||
(progn ;; flycheck
|
;; flycheck
|
||||||
(defun narf--flycheck-count (state)
|
(defun narf--flycheck-count (state)
|
||||||
"Return flycheck information for the given error type STATE."
|
"Return flycheck information for the given error type STATE."
|
||||||
(let* ((counts (flycheck-count-errors flycheck-current-errors))
|
(let* ((counts (flycheck-count-errors flycheck-current-errors))
|
||||||
(errorp (flycheck-has-current-errors-p state))
|
(errorp (flycheck-has-current-errors-p state))
|
||||||
(running (eq 'running flycheck-last-status-change))
|
(running (eq 'running flycheck-last-status-change))
|
||||||
(err (cdr (assq state counts))))
|
(err (cdr (assq state counts))))
|
||||||
(when errorp (if running "?" err))))
|
(when errorp (if running "?" err))))
|
||||||
|
|
||||||
(defface spaceline-flycheck-error
|
(defface spaceline-flycheck-error
|
||||||
'((t (:foreground "#FC5C94" :distant-foreground "#A20C41")))
|
'((t (:foreground "#FC5C94" :distant-foreground "#A20C41")))
|
||||||
"Face for flycheck error feedback in the modeline.")
|
"Face for flycheck error feedback in the modeline.")
|
||||||
(defface spaceline-flycheck-warning
|
(defface spaceline-flycheck-warning
|
||||||
'((t (:foreground "#F3EA98" :distant-foreground "#968B26")))
|
'((t (:foreground "#F3EA98" :distant-foreground "#968B26")))
|
||||||
"Face for flycheck warning feedback in the modeline.")
|
"Face for flycheck warning feedback in the modeline.")
|
||||||
(defface spaceline-flycheck-info
|
(defface spaceline-flycheck-info
|
||||||
'((t (:foreground "#8DE6F7" :distant-foreground "#21889B")))
|
'((t (:foreground "#8DE6F7" :distant-foreground "#21889B")))
|
||||||
"Face for flycheck info feedback in the modeline.")
|
"Face for flycheck info feedback in the modeline.")
|
||||||
|
|
||||||
(defvar narf--flycheck-err-cache nil "")
|
(defvar narf--flycheck-err-cache nil "")
|
||||||
(defvar narf--flycheck-cache nil "")
|
(defvar narf--flycheck-cache nil "")
|
||||||
(spaceline-define-segment *flycheck
|
(spaceline-define-segment *flycheck
|
||||||
"Persistent and cached flycheck indicators in the mode-line."
|
"Persistent and cached flycheck indicators in the mode-line."
|
||||||
(or (and (or (eq narf--flycheck-err-cache narf--flycheck-cache)
|
(or (and (or (eq narf--flycheck-err-cache narf--flycheck-cache)
|
||||||
(memq flycheck-last-status-change '(running not-checked)))
|
(memq flycheck-last-status-change '(running not-checked)))
|
||||||
narf--flycheck-cache)
|
narf--flycheck-cache)
|
||||||
(and (setq narf--flycheck-err-cache flycheck-current-errors)
|
(and (setq narf--flycheck-err-cache flycheck-current-errors)
|
||||||
(setq narf--flycheck-cache
|
(setq narf--flycheck-cache
|
||||||
(let ((fe (narf--flycheck-count 'error))
|
(let ((fe (narf--flycheck-count 'error))
|
||||||
(fw (narf--flycheck-count 'warning))
|
(fw (narf--flycheck-count 'warning))
|
||||||
(fi (narf--flycheck-count 'info)))
|
(fi (narf--flycheck-count 'info)))
|
||||||
(concat
|
(concat
|
||||||
(when fe (powerline-raw (format " ⚠%s " fe) 'spaceline-flycheck-error))
|
(when fe (powerline-raw (format " ⚠%s " fe) 'spaceline-flycheck-error))
|
||||||
(when fw (powerline-raw (format " ⚠%s " fw) 'spaceline-flycheck-warning))
|
(when fw (powerline-raw (format " ⚠%s " fw) 'spaceline-flycheck-warning))
|
||||||
(when fi (powerline-raw (format " ⚠%s " fi) 'spaceline-flycheck-info)))))))
|
(when fi (powerline-raw (format " ⚠%s " fi) 'spaceline-flycheck-info)))))))
|
||||||
:when (and (bound-and-true-p flycheck-mode)
|
:when (and (bound-and-true-p flycheck-mode)
|
||||||
(or flycheck-current-errors
|
(or flycheck-current-errors
|
||||||
(eq 'running flycheck-last-status-change)))
|
(eq 'running flycheck-last-status-change)))
|
||||||
:tight t
|
:tight t
|
||||||
:skip-alternate t))
|
:skip-alternate t)
|
||||||
|
|
||||||
(spaceline-define-segment *hud
|
(spaceline-define-segment *hud
|
||||||
"A HUD that shows which part of the buffer is currently visible."
|
"A HUD that shows which part of the buffer is currently visible."
|
||||||
(powerline-hud (if active 'spaceline-highlight-face 'region) line-face 1)
|
(powerline-hud (if active 'spaceline-highlight-face 'region) line-face 1)
|
||||||
:tight-right t))
|
:tight-right t)
|
||||||
|
|
||||||
;; Initialize modeline
|
;; Initialize modeline
|
||||||
(spaceline-install
|
(spaceline-install
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue