Add symbol-overlay package to spacemacs/navigation layer

Defines a transient state for symbol-overlay, and bind it to ~SPC s o~ and ~SPC s O~.

Updates:

* update due to the signature change of `symbol-overlay-get-list`.
* align the docstring using `^^` and add `quit` button.
This commit is contained in:
康小广 2018-11-29 06:29:47 -05:00 committed by duianto
parent 3d11456f51
commit 2e6817ef34
3 changed files with 99 additions and 0 deletions

View file

@ -589,6 +589,8 @@ Other:
- =help-fns+=
- =font-lock+=
- Remove package =adaptive-wrap=
- Added =symbol-overlay= to the =spacemacs-navigation= layer
(thanks to kenkangxgwe)
- Key bindings:
- New evil text objects =«=, =「=, == and =“=.
- Improved buffer transient state with extra bindings and new commands:
@ -746,6 +748,27 @@ Other:
(thanks to Rich Alesi)
- Improved =which-key= replacement regular expressions (thanks to duianto)
- Added ~SPC o~ which-key prefix name: =user bindings= (thanks to duianto)
- Added =symbol-overlay= key bindings (thanks to kenkangxgwe):
- ~SPC s o~ calls =spacemacs/symbol-overlay=
- ~SPC s O~ calls =symbol-overlay-remove-all=
- New symbol overlay transient state, ~SPC s o~ on a symbol:
- ~b~ calls =symbol-overlay-switch-backward=
- ~c~ calls =symbol-overlay-save-symbol=
- ~d~ calls =symbol-overlay-jump-to-definition=
- ~e~ calls =symbol-overlay-echo-mark=
- ~f~ calls =symbol-overlay-switch-forward=
- ~n~ calls =symbol-overlay-jump-next=
- ~N~ calls =symbol-overlay-jump-prev=
- ~o~ calls =symbol-overlay-put=
- ~O~ calls =symbol-overlay-remove-all=
- ~p~ calls =symbol-overlay-jump-prev=
- ~r~ calls =symbol-overlay-query-replace=
- ~R~ calls =symbol-overlay-rename=
- ~s~ calls =symbol-overlay-isearch-literally=
- ~t~ calls =symbol-overlay-toggle-in-scope=
- ~z~ calls =recenter-top-bottom=
- ~q~ exits the transient state
(thanks to kenkangxgwe)
- Improvements:
- Rewrote window layout functions for ~SPC w 1~, ~SPC w 2~, ~SPC w 3~, and
~SPC w 4~ (thanks to Codruț Constantin Gușoi):

View file

@ -197,6 +197,39 @@ If the universal prefix argument is used then kill also the window."
(format spacemacs--symbol-highlight-transient-state-doc
(spacemacs//symbol-highlight-doc))))
;; symbol overlay
(defun spacemacs/symbol-overlay ()
"Start symbol-overlay-transient-state."
(interactive)
(symbol-overlay-put)
(spacemacs/symbol-overlay-transient-state/body))
(defun spacemacs//symbol-overlay-doc ()
(let* ((symbol-at-point (symbol-overlay-get-symbol))
(keyword (symbol-overlay-assoc symbol-at-point))
(symbol (car keyword))
(before (symbol-overlay-get-list -1 symbol))
(after (symbol-overlay-get-list 1 symbol))
(count (length before))
(scope (format "%s"
(if (cadr keyword)
"Scope"
"Buffer")))
(color (cddr keyword))
(x/y (format "[%s/%s]" (+ count 1) (+ count (length after)))))
(concat
(propertize (format " %s " scope) 'face color))
(propertize (format " %s " x/y) 'face
`(:foreground "#ffffff" :background "#000000"))))
(defun spacemacs//symbol-overlay-ts-doc ()
(spacemacs//transient-state-make-doc
'symbol-overlay
(format spacemacs--symbol-overlay-transient-state-doc
(spacemacs//symbol-overlay-doc))))
;; golden ratio

View file

@ -23,6 +23,7 @@
paradox
restart-emacs
(smooth-scrolling :location built-in)
symbol-overlay
winum))
(defun spacemacs-navigation/init-ace-link ()
@ -370,6 +371,48 @@
:documentation "Smooth scrolling."
:evil-leader "tv"))
(defun spacemacs-navigation/init-symbol-overlay ()
(use-package symbol-overlay
:init
(progn
(setq spacemacs--symbol-overlay-transient-state-doc "
%s
[_n_] next [_N_/_p_] prev [_d_] def [_f_/_b_] switch [_t_] scope
[_e_] echo [_o_]^^ unoverlay [_O_] unoverlay all [_c_]^^ copy [_z_] center
[_s_] search [_r_]^^ replace [_R_] rename ^^^^ [_q_] quit")
;; since we are creating our own maps,
;; prevent the default keymap from getting created
(setq symbol-overlay-map (make-sparse-keymap)))
:config
(progn
(spacemacs/set-leader-keys
"so" 'spacemacs/symbol-overlay
"sO" 'symbol-overlay-remove-all)
;; transient state
(spacemacs|define-transient-state symbol-overlay
:title "Symbol Overlay Transient State"
:hint-is-doc t
:dynamic-hint (spacemacs//symbol-overlay-ts-doc)
:bindings
("b" symbol-overlay-switch-backward)
("c" symbol-overlay-save-symbol)
("d" symbol-overlay-jump-to-definition)
("e" symbol-overlay-echo-mark)
("f" symbol-overlay-switch-forward)
("n" symbol-overlay-jump-next)
("N" symbol-overlay-jump-prev)
("o" symbol-overlay-put)
("O" symbol-overlay-remove-all)
("p" symbol-overlay-jump-prev)
("r" symbol-overlay-query-replace)
("R" symbol-overlay-rename)
("s" symbol-overlay-isearch-literally)
("t" symbol-overlay-toggle-in-scope)
("z" recenter-top-bottom)
("q" nil :exit t)))))
(defun spacemacs-navigation/init-winum ()
(use-package winum
:config