Overhaul mode-line; at occurrence count for ex-substitute & iedit
This commit is contained in:
parent
84fbf01811
commit
e67af73113
1 changed files with 68 additions and 29 deletions
|
@ -234,7 +234,7 @@
|
||||||
:config
|
:config
|
||||||
(setq-default
|
(setq-default
|
||||||
powerline-default-separator nil
|
powerline-default-separator nil
|
||||||
powerline-height 18)
|
powerline-height 19)
|
||||||
|
|
||||||
(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")
|
||||||
|
@ -255,7 +255,8 @@
|
||||||
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)
|
||||||
:tight t)
|
:skip-alternate t
|
||||||
|
:tight-right t)
|
||||||
|
|
||||||
(spaceline-define-segment narf-buffer-modified
|
(spaceline-define-segment narf-buffer-modified
|
||||||
(concat
|
(concat
|
||||||
|
@ -272,7 +273,8 @@
|
||||||
(spaceline-define-segment narf-buffer-encoding-abbrev
|
(spaceline-define-segment narf-buffer-encoding-abbrev
|
||||||
"The line ending convention used in the buffer."
|
"The line ending convention used in the buffer."
|
||||||
(symbol-name buffer-file-coding-system)
|
(symbol-name buffer-file-coding-system)
|
||||||
:when (not (string-match-p "\\(utf-8\\|undecided\\)" (symbol-name buffer-file-coding-system))))
|
:when (not (string-match-p "\\(utf-8\\|undecided\\)"
|
||||||
|
(symbol-name buffer-file-coding-system))))
|
||||||
|
|
||||||
(spaceline-define-segment narf-buffer-position
|
(spaceline-define-segment narf-buffer-position
|
||||||
"A more vim-like buffer position."
|
"A more vim-like buffer position."
|
||||||
|
@ -286,18 +288,18 @@
|
||||||
(cond ((eq start 1) ":Top")
|
(cond ((eq start 1) ":Top")
|
||||||
((>= perc 100) ":Bot")
|
((>= perc 100) ":Bot")
|
||||||
(t (format ":%d%%%%" perc))))))
|
(t (format ":%d%%%%" perc))))))
|
||||||
:tight-right t)
|
:tight t)
|
||||||
|
|
||||||
(spaceline-define-segment narf-vc
|
(spaceline-define-segment narf-vc
|
||||||
"Version control info"
|
"Version control info"
|
||||||
(let ((vc (vc-working-revision buffer-file-name)))
|
(concat (downcase vc-mode)
|
||||||
(when vc
|
(case (vc-state buffer-file-name)
|
||||||
(format "%s%s" vc (case (vc-state buffer-file-name)
|
('edited "+")
|
||||||
('edited "+")
|
('conflict "!!!")
|
||||||
('conflict "!!!")
|
(t "")))
|
||||||
(t "")))))
|
:when (and active vc-mode)
|
||||||
:face other-face
|
:face other-face
|
||||||
:when (and active vc-mode))
|
:tight t)
|
||||||
|
|
||||||
(spaceline-define-segment narf-env-version
|
(spaceline-define-segment narf-env-version
|
||||||
"A HUD that shows which part of the buffer is currently visible."
|
"A HUD that shows which part of the buffer is currently visible."
|
||||||
|
@ -308,42 +310,79 @@
|
||||||
|
|
||||||
(spaceline-define-segment narf-hud
|
(spaceline-define-segment narf-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 highlight-face default-face 1)
|
(powerline-hud highlight-face other-face 1)
|
||||||
|
:face other-face
|
||||||
:tight-right t)
|
:tight-right t)
|
||||||
|
|
||||||
(spaceline-define-segment narf-anzu
|
(spaceline-define-segment narf-anzu
|
||||||
"Show the current match number and the total number of matches. Requires anzu
|
"Show the current match number and the total number of matches. Requires
|
||||||
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))
|
||||||
(when anzu--state
|
(when anzu--state
|
||||||
(concat
|
(propertize
|
||||||
(propertize
|
(cl-case anzu--state
|
||||||
(cl-case anzu--state
|
(search (format " %s/%d%s "
|
||||||
(search (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 "+" "")))
|
(replace-query (format " %d replace " total))
|
||||||
(replace-query (format " %d replace " total))
|
(replace (format " %d/%d " here total)))
|
||||||
(replace (format " %d/%d " here total)))
|
'face highlight-face)))
|
||||||
'face highlight-face)
|
|
||||||
" ")))
|
|
||||||
:when (and active (bound-and-true-p anzu--state))
|
:when (and active (bound-and-true-p anzu--state))
|
||||||
|
:skip-alternate t
|
||||||
:tight t)
|
:tight t)
|
||||||
|
|
||||||
|
;; TODO mode-line-iedit-face default face
|
||||||
|
(defface mode-line-iedit-face nil "")
|
||||||
|
(spaceline-define-segment narf-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)))
|
||||||
|
(if (zerop (iedit-occurrence-string-length))
|
||||||
|
"..."
|
||||||
|
(format "%s/%s"
|
||||||
|
(save-excursion
|
||||||
|
(unless this-oc
|
||||||
|
(iedit-prev-occurrence)
|
||||||
|
(setq this-oc (iedit-find-current-occurrence-overlay)))
|
||||||
|
(if this-oc
|
||||||
|
(- length (-elem-index this-oc iedit-occurrences-overlays))
|
||||||
|
"-"))
|
||||||
|
(int-to-string length))))
|
||||||
|
:face (if active 'mode-line-iedit-face 'mode-line-inactive)
|
||||||
|
:skip-alternate t
|
||||||
|
:when (and (featurep 'iedit) (> (length iedit-occurrences-overlays) 0)))
|
||||||
|
|
||||||
|
;; TODO mode-line-substitute-face default face
|
||||||
|
(defface mode-line-substitute-face nil "")
|
||||||
|
;; TODO This is very hackish; refactor?
|
||||||
|
(spaceline-define-segment narf-evil-substitute
|
||||||
|
"Show number of :s matches in real time."
|
||||||
|
(let ((highlights (cdar evil-ex-active-highlights-alist)))
|
||||||
|
(format "%s" (length (elt highlights (1- (length highlights))))))
|
||||||
|
:face (if active 'mode-line-substitute-face 'mode-line-inactive)
|
||||||
|
:skip-alternate t
|
||||||
|
:when (and (evil-ex-p) (string-equal evil-ex-cmd "s")))
|
||||||
|
|
||||||
|
(spaceline-define-segment narf-major-mode
|
||||||
|
(concat "[" mode-name "]")
|
||||||
|
:skip-alternate t)
|
||||||
|
|
||||||
;; Initialize modeline
|
;; Initialize modeline
|
||||||
(spaceline-install
|
(spaceline-install
|
||||||
;; Left side
|
;; Left side
|
||||||
'(narf-anzu
|
'(narf-anzu narf-iedit narf-evil-substitute
|
||||||
(narf-buffer-path remote-host)
|
(narf-buffer-path remote-host)
|
||||||
narf-buffer-modified
|
narf-buffer-modified
|
||||||
narf-vc
|
narf-vc
|
||||||
((flycheck-error flycheck-warning flycheck-info) :when active))
|
((flycheck-error flycheck-warning flycheck-info) :when active))
|
||||||
;; Right side
|
;; Right side
|
||||||
'((selection-info :face highlight-face)
|
'((selection-info :face highlight-face :skip-alternate t)
|
||||||
narf-env-version
|
narf-env-version
|
||||||
narf-buffer-encoding-abbrev
|
narf-buffer-encoding-
|
||||||
((major-mode :tight-right t)
|
(narf-major-mode
|
||||||
(minor-modes :tight t :separator "")
|
(minor-modes :separator " " :tight t)
|
||||||
process :when active)
|
process :when active)
|
||||||
(global :when active)
|
(global :when active)
|
||||||
("%l·%c" narf-buffer-position)
|
("%l·%c" narf-buffer-position)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue