Skip to content

Commit

Permalink
counsel&ivy setup
Browse files Browse the repository at this point in the history
Chen Bin committed Jan 3, 2025

Verified

This commit was signed with the committer’s verified signature.
bep Bjørn Erik Pedersen
1 parent c576a7e commit 0b22464
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lisp/init-evil.el
Original file line number Diff line number Diff line change
@@ -766,7 +766,8 @@ If N > 0 and in js, only occurrences in current N lines are renamed."
"9" 'winum-select-window-9
"xm" 'counsel-M-x
"xx" 'er/expand-region
"xf" 'find-file
;; `counsel-find-file' has more actions (press "M-o" to trigger more actions)
"xf" (if (functionp 'counsel-find-file) 'counsel-find-file 'find-file)
"x/" 'find-file-other-window
"xb" 'ivy-switch-buffer-by-pinyin
"xh" 'mark-whole-buffer
13 changes: 4 additions & 9 deletions lisp/init-ivy.el
Original file line number Diff line number Diff line change
@@ -37,14 +37,11 @@
;; @see https://oremacs.com/2015/07/23/ivy-multiaction/
;; press "M-o" to choose ivy action
(ivy-set-actions
'counsel-find-file
'find-file
'(("j" find-file-other-frame "other frame")
("b" counsel-find-file-cd-bookmark-action "cd bookmark")
("x" counsel-find-file-extern "open externally")
("d" delete-file "delete")
("r" counsel-find-file-as-root "open as root"))))

;; (setq ivy-use-virtual-buffers t) ; not good experience
(global-set-key (kbd "C-x b") 'ivy-switch-buffer)

(define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
@@ -192,11 +189,6 @@ If N is 2, list files in my recent 20 commits."
:keymap ivy-switch-buffer-map
:caller 'ivy-switch-buffer)))

(with-eval-after-load 'ivy
;; work around ivy issue.
;; @see https://github.com/abo-abo/swiper/issues/828
(setq ivy-display-style 'fancy))

;; {{ swiper&ivy-mode
(global-set-key (kbd "C-s") 'counsel-grep-or-swiper)
;; }}
@@ -246,6 +238,9 @@ If N is 2, list files in my recent 20 commits."
(my-counsel-imenu))))

(with-eval-after-load 'ivy
;; Add recent files and bookmarks to the `ivy-switch-buffer'
(setq ivy-use-virtual-buffers t)

;; better performance on everything (especially windows), ivy-0.10.0 required
;; when `ivy-dynamic-exhibit-delay-ms' is a non-zero value
;; Setting it to a bigger value in ALL OSs is also more green energy btw.

0 comments on commit 0b22464

Please sign in to comment.