Reorganize spaceline config
This commit is contained in:
parent
1ac7f5504b
commit
caa1f21901
1 changed files with 104 additions and 99 deletions
203
core/core-ui.el
203
core/core-ui.el
|
@ -258,6 +258,11 @@
|
||||||
:skip-alternate t
|
:skip-alternate t
|
||||||
:tight-right 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
|
(spaceline-define-segment *buffer-modified
|
||||||
(concat
|
(concat
|
||||||
(when buffer-file-name
|
(when buffer-file-name
|
||||||
|
@ -270,12 +275,6 @@
|
||||||
:skip-alternate t
|
:skip-alternate t
|
||||||
:tight t)
|
:tight 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 *buffer-position
|
(spaceline-define-segment *buffer-position
|
||||||
"A more vim-like buffer position."
|
"A more vim-like buffer position."
|
||||||
(let ((start (window-start))
|
(let ((start (window-start))
|
||||||
|
@ -312,69 +311,66 @@
|
||||||
:tight-right t)
|
:tight-right t)
|
||||||
|
|
||||||
(spaceline-define-segment *env-version
|
(spaceline-define-segment *env-version
|
||||||
"A HUD that shows which part of the buffer is currently visible."
|
"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
|
narf--env-version
|
||||||
:when narf--env-version
|
:when narf--env-version
|
||||||
:face other-face
|
:face other-face
|
||||||
:skip-alternate t
|
:skip-alternate t
|
||||||
:tight-right t)
|
:tight-right t)
|
||||||
|
|
||||||
(spaceline-define-segment *hud
|
|
||||||
"A HUD that shows which part of the buffer is currently visible."
|
|
||||||
(powerline-hud highlight-face other-face 1)
|
|
||||||
:face other-face
|
|
||||||
:tight-right t)
|
|
||||||
|
|
||||||
(defface mode-line-count-face nil "")
|
(progn ;; search indicators
|
||||||
(make-variable-buffer-local 'anzu--state)
|
(defface mode-line-count-face nil "")
|
||||||
(spaceline-define-segment *anzu
|
(make-variable-buffer-local 'anzu--state)
|
||||||
"Show the current match number and the total number of matches. Requires
|
(spaceline-define-segment *anzu
|
||||||
|
"Show the current match number and the total number of matches. Requires
|
||||||
anzu to be enabled."
|
anzu to be enabled."
|
||||||
(let ((here anzu--current-position)
|
(let ((here anzu--current-position)
|
||||||
(total anzu--total-matched))
|
(total anzu--total-matched))
|
||||||
(format " %s/%d%s "
|
(format " %s/%d%s "
|
||||||
(anzu--format-here-position here total)
|
(anzu--format-here-position here total)
|
||||||
total (if anzu--overflow-p "+" "")))
|
total (if anzu--overflow-p "+" "")))
|
||||||
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
||||||
:when (and (> anzu--total-matched 0) (evil-ex-hl-active-p 'evil-ex-search))
|
:when (and (> anzu--total-matched 0) (evil-ex-hl-active-p 'evil-ex-search))
|
||||||
:skip-alternate t
|
:skip-alternate t
|
||||||
:tight t)
|
:tight t)
|
||||||
|
|
||||||
;; TODO mode-line-iedit-face default face
|
;; TODO mode-line-iedit-face default face
|
||||||
(spaceline-define-segment *iedit
|
(spaceline-define-segment *iedit
|
||||||
"Show the number of matches and what match you're on (or after). Requires
|
"Show the number of matches and what match you're on (or after). Requires
|
||||||
iedit."
|
iedit."
|
||||||
(let ((this-oc (iedit-find-current-occurrence-overlay))
|
(let ((this-oc (iedit-find-current-occurrence-overlay))
|
||||||
(length (or (ignore-errors (length iedit-occurrences-overlays)) 0)))
|
(length (or (ignore-errors (length iedit-occurrences-overlays)) 0)))
|
||||||
(format "%s/%s"
|
(format "%s/%s"
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(unless this-oc
|
(unless this-oc
|
||||||
(iedit-prev-occurrence)
|
(iedit-prev-occurrence)
|
||||||
(setq this-oc (iedit-find-current-occurrence-overlay)))
|
(setq this-oc (iedit-find-current-occurrence-overlay)))
|
||||||
(if this-oc
|
(if this-oc
|
||||||
;; NOTE: Not terribly reliable
|
;; NOTE: Not terribly reliable
|
||||||
(- length (-elem-index this-oc iedit-occurrences-overlays))
|
(- length (-elem-index this-oc iedit-occurrences-overlays))
|
||||||
"-"))
|
"-"))
|
||||||
length))
|
length))
|
||||||
:when (bound-and-true-p iedit-mode)
|
:when (bound-and-true-p iedit-mode)
|
||||||
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
||||||
:skip-alternate t)
|
:skip-alternate t)
|
||||||
|
|
||||||
(defface mode-line-substitute-face nil "")
|
(defface mode-line-substitute-face nil "")
|
||||||
(spaceline-define-segment *evil-substitute
|
(spaceline-define-segment *evil-substitute
|
||||||
"Show number of :s matches in real time."
|
"Show number of :s matches in real time."
|
||||||
(let ((range (if evil-ex-range
|
(let ((range (if evil-ex-range
|
||||||
(cons (car evil-ex-range) (cadr evil-ex-range))
|
(cons (car evil-ex-range) (cadr evil-ex-range))
|
||||||
(cons (line-beginning-position) (line-end-position))))
|
(cons (line-beginning-position) (line-end-position))))
|
||||||
(pattern (car-safe (evil-delimited-arguments evil-ex-argument 2))))
|
(pattern (car-safe (evil-delimited-arguments evil-ex-argument 2))))
|
||||||
(if pattern
|
(if pattern
|
||||||
(format "%s matches"
|
(format "%s matches"
|
||||||
(count-matches pattern (car range) (cdr range))
|
(count-matches pattern (car range) (cdr range))
|
||||||
evil-ex-argument)
|
evil-ex-argument)
|
||||||
" ... "))
|
" ... "))
|
||||||
:when (and (evil-ex-p) (evil-ex-hl-active-p 'evil-ex-substitute))
|
:when (and (evil-ex-p) (evil-ex-hl-active-p 'evil-ex-substitute))
|
||||||
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
:face (if active 'mode-line-count-face 'mode-line-inactive)
|
||||||
:skip-alternate t)
|
:skip-alternate t))
|
||||||
|
|
||||||
(spaceline-define-segment *macro-recording
|
(spaceline-define-segment *macro-recording
|
||||||
"Show when recording macro"
|
"Show when recording macro"
|
||||||
|
@ -383,6 +379,12 @@ iedit."
|
||||||
:face highlight-face
|
:face highlight-face
|
||||||
:skip-alternate t)
|
: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
|
(spaceline-define-segment *major-mode
|
||||||
(powerline-raw
|
(powerline-raw
|
||||||
(concat
|
(concat
|
||||||
|
@ -395,11 +397,6 @@ iedit."
|
||||||
:tight-right t
|
:tight-right t
|
||||||
:skip-alternate t)
|
:skip-alternate t)
|
||||||
|
|
||||||
(spaceline-define-segment *remote-host
|
|
||||||
"Hostname for remote buffers."
|
|
||||||
(concat "@" (file-remote-p default-directory 'host))
|
|
||||||
:when (file-remote-p default-directory 'host))
|
|
||||||
|
|
||||||
(defun narf--col-at-pos (pos)
|
(defun narf--col-at-pos (pos)
|
||||||
(save-excursion (goto-char pos) (current-column)))
|
(save-excursion (goto-char pos) (current-column)))
|
||||||
(spaceline-define-segment *selection-info
|
(spaceline-define-segment *selection-info
|
||||||
|
@ -426,44 +423,52 @@ Supports both Emacs and Evil cursor conventions."
|
||||||
:face highlight-face
|
:face highlight-face
|
||||||
:skip-alternate t)
|
:skip-alternate t)
|
||||||
|
|
||||||
(defun narf--flycheck-count (state)
|
(progn ;; flycheck
|
||||||
"Return flycheck information for the given error type STATE."
|
(defun narf--flycheck-count (state)
|
||||||
(let* ((counts (flycheck-count-errors flycheck-current-errors))
|
"Return flycheck information for the given error type STATE."
|
||||||
(errorp (flycheck-has-current-errors-p state))
|
(let* ((counts (flycheck-count-errors flycheck-current-errors))
|
||||||
(running (eq 'running flycheck-last-status-change))
|
(errorp (flycheck-has-current-errors-p state))
|
||||||
(err (cdr (assq state counts))))
|
(running (eq 'running flycheck-last-status-change))
|
||||||
(when errorp (if running "?" err))))
|
(err (cdr (assq state counts))))
|
||||||
|
(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-left t))
|
:tight-left t
|
||||||
|
:skip-alternate t))
|
||||||
|
|
||||||
|
(spaceline-define-segment *hud
|
||||||
|
"A HUD that shows which part of the buffer is currently visible."
|
||||||
|
(powerline-hud highlight-face other-face 1)
|
||||||
|
:face other-face
|
||||||
|
:tight-right t))
|
||||||
|
|
||||||
;; Initialize modeline
|
;; Initialize modeline
|
||||||
(spaceline-install
|
(spaceline-install
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue