ahs: move b, f and / key bindings to helm and ivy
Correctly augment the docstring based on the presence of b,f and / bindings using dynamic hint. b,f and / are not available if none of helm or ivy layers are used.
This commit is contained in:
parent
2a07a7fd76
commit
f5799ab1ec
|
@ -10,7 +10,9 @@
|
||||||
;;; License: GPLv3
|
;;; License: GPLv3
|
||||||
|
|
||||||
(setq helm-packages
|
(setq helm-packages
|
||||||
'(ace-jump-helm-line
|
'(
|
||||||
|
ace-jump-helm-line
|
||||||
|
auto-highlight-symbol
|
||||||
bookmark
|
bookmark
|
||||||
helm
|
helm
|
||||||
helm-ag
|
helm-ag
|
||||||
|
@ -21,7 +23,8 @@
|
||||||
helm-projectile
|
helm-projectile
|
||||||
helm-swoop
|
helm-swoop
|
||||||
helm-themes
|
helm-themes
|
||||||
(helm-spacemacs-help :location local)))
|
(helm-spacemacs-help :location local)
|
||||||
|
))
|
||||||
|
|
||||||
;; Initialization of packages
|
;; Initialization of packages
|
||||||
|
|
||||||
|
@ -32,6 +35,18 @@
|
||||||
(with-eval-after-load 'helm
|
(with-eval-after-load 'helm
|
||||||
(define-key helm-map (kbd "C-q") 'ace-jump-helm-line))))
|
(define-key helm-map (kbd "C-q") 'ace-jump-helm-line))))
|
||||||
|
|
||||||
|
(defun helm/pre-init-auto-highlight-symbol ()
|
||||||
|
(spacemacs|use-package-add-hook auto-highlight-symbol
|
||||||
|
:post-init
|
||||||
|
;; add some functions to ahs transient states
|
||||||
|
(setq spacemacs--symbol-highlight-transient-state-doc
|
||||||
|
(concat spacemacs--symbol-highlight-transient-state-doc
|
||||||
|
" [_b_] search buffers [_/_] search proj [_f_] search files")
|
||||||
|
spacemacs-symbol-highlight-transient-state-add-bindings
|
||||||
|
'(("/" spacemacs/helm-project-smart-do-search-region-or-symbol :exit t)
|
||||||
|
("b" spacemacs/helm-buffers-smart-do-search-region-or-symbol :exit t)
|
||||||
|
("f" spacemacs/helm-files-smart-do-search-region-or-symbol :exit t)))))
|
||||||
|
|
||||||
(defun helm/post-init-bookmark ()
|
(defun helm/post-init-bookmark ()
|
||||||
(spacemacs/set-leader-keys "fb" 'helm-filtered-bookmarks))
|
(spacemacs/set-leader-keys "fb" 'helm-filtered-bookmarks))
|
||||||
|
|
||||||
|
|
|
@ -246,28 +246,6 @@ To prevent this error we just wrap `describe-mode' to defeat the
|
||||||
(swiper--cleanup)
|
(swiper--cleanup)
|
||||||
(swiper--add-overlays (ivy--regex ivy-text)))))))
|
(swiper--add-overlays (ivy--regex ivy-text)))))))
|
||||||
|
|
||||||
|
|
||||||
;; Evil
|
|
||||||
|
|
||||||
(defun spacemacs/ivy-evil-registers ()
|
|
||||||
"Show evil registers"
|
|
||||||
(interactive)
|
|
||||||
(let ((ivy-height 24))
|
|
||||||
(ivy-read "Evil Registers:"
|
|
||||||
(cl-loop for (key . val) in (evil-register-list)
|
|
||||||
collect (eval `(format "%s : %s" (propertize ,(char-to-string key) 'face 'font-lock-builtin-face)
|
|
||||||
,(or (and val
|
|
||||||
(stringp val)
|
|
||||||
(replace-regexp-in-string "\n" "^J" val))
|
|
||||||
""))))
|
|
||||||
:action #'spacemacs/ivy-insert-evil-register)))
|
|
||||||
|
|
||||||
(defun spacemacs/ivy-insert-evil-register (candidate)
|
|
||||||
(insert (replace-regexp-in-string "\\^J" "\n"
|
|
||||||
(substring-no-properties candidate 4))))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;; Ivy
|
;; Ivy
|
||||||
|
|
||||||
(defun spacemacs//ivy-command-not-implemented-yet (key)
|
(defun spacemacs//ivy-command-not-implemented-yet (key)
|
||||||
|
@ -289,7 +267,24 @@ To prevent this error we just wrap `describe-mode' to defeat the
|
||||||
(require (car repl))
|
(require (car repl))
|
||||||
(call-interactively (cdr repl))))))
|
(call-interactively (cdr repl))))))
|
||||||
|
|
||||||
|
;; Evil
|
||||||
|
|
||||||
|
(defun spacemacs/ivy-evil-registers ()
|
||||||
|
"Show evil registers"
|
||||||
|
(interactive)
|
||||||
|
(let ((ivy-height 24))
|
||||||
|
(ivy-read "Evil Registers:"
|
||||||
|
(cl-loop for (key . val) in (evil-register-list)
|
||||||
|
collect (eval `(format "%s : %s" (propertize ,(char-to-string key) 'face 'font-lock-builtin-face)
|
||||||
|
,(or (and val
|
||||||
|
(stringp val)
|
||||||
|
(replace-regexp-in-string "\n" "^J" val))
|
||||||
|
""))))
|
||||||
|
:action #'spacemacs/ivy-insert-evil-register)))
|
||||||
|
|
||||||
|
(defun spacemacs/ivy-insert-evil-register (candidate)
|
||||||
|
(insert (replace-regexp-in-string "\\^J" "\n"
|
||||||
|
(substring-no-properties candidate 4))))
|
||||||
|
|
||||||
;; Layouts
|
;; Layouts
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
;;; License: GPLv3
|
;;; License: GPLv3
|
||||||
|
|
||||||
(setq ivy-packages
|
(setq ivy-packages
|
||||||
'(auto-highlight-symbol
|
'(
|
||||||
|
auto-highlight-symbol
|
||||||
counsel
|
counsel
|
||||||
(counsel-projectile :toggle (configuration-layer/package-usedp 'projectile))
|
(counsel-projectile :toggle (configuration-layer/package-usedp 'projectile))
|
||||||
evil
|
evil
|
||||||
|
@ -23,15 +24,20 @@
|
||||||
projectile
|
projectile
|
||||||
smex
|
smex
|
||||||
swiper
|
swiper
|
||||||
wgrep))
|
wgrep
|
||||||
|
))
|
||||||
|
|
||||||
(defun ivy/post-init-auto-highlight-symbol ()
|
(defun ivy/pre-init-auto-highlight-symbol ()
|
||||||
(setq spacemacs-symbol-highlight-transient-state-remove-bindings
|
(spacemacs|use-package-add-hook auto-highlight-symbol
|
||||||
'("/" "b" "f"))
|
:post-init
|
||||||
(setq spacemacs-symbol-highlight-transient-state-add-bindings
|
;; add some functions to ahs transient states
|
||||||
'(("/" spacemacs/search-project-auto-region-or-symbol :exit t)
|
(setq spacemacs--symbol-highlight-transient-state-doc
|
||||||
("b" spacemacs/swiper-all-region-or-symbol :exit t)
|
(concat spacemacs--symbol-highlight-transient-state-doc
|
||||||
("f" spacemacs/search-auto-region-or-symbol :exit t))))
|
" [_b_] search buffers [_/_] search proj [_f_] search files")
|
||||||
|
spacemacs-symbol-highlight-transient-state-add-bindings
|
||||||
|
'(("/" spacemacs/search-project-auto-region-or-symbol :exit t)
|
||||||
|
("b" spacemacs/swiper-all-region-or-symbol :exit t)
|
||||||
|
("f" spacemacs/search-auto-region-or-symbol :exit t)))))
|
||||||
|
|
||||||
(defun ivy/init-counsel ()
|
(defun ivy/init-counsel ()
|
||||||
(use-package counsel
|
(use-package counsel
|
||||||
|
|
|
@ -45,7 +45,11 @@
|
||||||
;; current symbol can always be highlighted with `SPC s h'
|
;; current symbol can always be highlighted with `SPC s h'
|
||||||
ahs-idle-timer 0
|
ahs-idle-timer 0
|
||||||
ahs-idle-interval 0.25
|
ahs-idle-interval 0.25
|
||||||
ahs-inhibit-face-list nil)
|
ahs-inhibit-face-list nil
|
||||||
|
spacemacs--symbol-highlight-transient-state-doc
|
||||||
|
"
|
||||||
|
%s [_n_] next [_N_/_p_] previous [_r_] change range [_R_] reset [_e_] iedit
|
||||||
|
%s [_d_/_D_] next/previous definition")
|
||||||
|
|
||||||
;; since we are creating our own maps,
|
;; since we are creating our own maps,
|
||||||
;; prevent the default keymap from getting created
|
;; prevent the default keymap from getting created
|
||||||
|
@ -243,12 +247,16 @@
|
||||||
(iedit-restrict-region (ahs-current-plugin-prop 'start)
|
(iedit-restrict-region (ahs-current-plugin-prop 'start)
|
||||||
(ahs-current-plugin-prop 'end)))
|
(ahs-current-plugin-prop 'end)))
|
||||||
(t (ahs-edit-mode t))))
|
(t (ahs-edit-mode t))))
|
||||||
|
;; transient state
|
||||||
|
(defun spacemacs//symbol-highlight-ts-doc ()
|
||||||
|
(spacemacs//transient-state-make-doc
|
||||||
|
'symbol-highlight
|
||||||
|
(format spacemacs--symbol-highlight-transient-state-doc
|
||||||
|
(symbol-highlight-doc)
|
||||||
|
(make-string (length (symbol-highlight-doc)) 32))))
|
||||||
(spacemacs|define-transient-state symbol-highlight
|
(spacemacs|define-transient-state symbol-highlight
|
||||||
:title "Symbol Highlight Transient State"
|
:title "Symbol Highlight Transient State"
|
||||||
:doc "
|
:dynamic-hint (spacemacs//symbol-highlight-ts-doc)
|
||||||
%s(symbol-highlight-doc) [_n_/_N_/_p_] next/prev/prev [_R_] restart [_e_] iedit [_b_] search buffers
|
|
||||||
%s(make-string (length (symbol-highlight-doc)) 32) [_d_/_D_]^^ next/prev def'n [_r_] change range [_/_] search proj [_f_] search files"
|
|
||||||
:before-exit (spacemacs//ahs-ms-on-exit)
|
:before-exit (spacemacs//ahs-ms-on-exit)
|
||||||
:bindings
|
:bindings
|
||||||
("d" ahs-forward-definition)
|
("d" ahs-forward-definition)
|
||||||
|
@ -259,9 +267,6 @@
|
||||||
("p" spacemacs/quick-ahs-backward)
|
("p" spacemacs/quick-ahs-backward)
|
||||||
("R" ahs-back-to-start)
|
("R" ahs-back-to-start)
|
||||||
("r" ahs-change-range)
|
("r" ahs-change-range)
|
||||||
("/" spacemacs/helm-project-smart-do-search-region-or-symbol :exit t)
|
|
||||||
("b" spacemacs/helm-buffers-smart-do-search-region-or-symbol :exit t)
|
|
||||||
("f" spacemacs/helm-files-smart-do-search-region-or-symbol :exit t)
|
|
||||||
("q" nil :exit t)))))
|
("q" nil :exit t)))))
|
||||||
|
|
||||||
(defun spacemacs-editing-visual/init-column-enforce-mode ()
|
(defun spacemacs-editing-visual/init-column-enforce-mode ()
|
||||||
|
|
Loading…
Reference in a new issue