Add +ivy/jump-list & bind 'SPC b j' to it
Falls back to evil-show-jumps for non-evil users.
This commit is contained in:
parent
e7f492c400
commit
45a17c86ba
3 changed files with 45 additions and 1 deletions
|
@ -487,3 +487,45 @@ If ALL-FILES-P, search compressed and hidden files as well."
|
||||||
"Execute a compile command from the current project's root."
|
"Execute a compile command from the current project's root."
|
||||||
(interactive)
|
(interactive)
|
||||||
(counsel-compile (projectile-project-root)))
|
(counsel-compile (projectile-project-root)))
|
||||||
|
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +ivy/jump-list ()
|
||||||
|
"Go to an entry in evil's (or better-jumper's) jumplist."
|
||||||
|
(interactive)
|
||||||
|
;; REVIEW Refactor me
|
||||||
|
(let (buffers)
|
||||||
|
(unwind-protect
|
||||||
|
(ivy-read "jumplist: "
|
||||||
|
(nreverse
|
||||||
|
(delete-dups
|
||||||
|
(delq
|
||||||
|
nil
|
||||||
|
(mapcar (lambda (mark)
|
||||||
|
(when mark
|
||||||
|
(cl-destructuring-bind (path pt _id) mark
|
||||||
|
(let ((buf (get-file-buffer path)))
|
||||||
|
(unless buf
|
||||||
|
(push (setq buf (find-file-noselect path t))
|
||||||
|
buffers))
|
||||||
|
(with-current-buffer buf
|
||||||
|
(goto-char pt)
|
||||||
|
(font-lock-fontify-region (line-beginning-position) (line-end-position))
|
||||||
|
(cons (format "%s:%d: %s"
|
||||||
|
(buffer-name)
|
||||||
|
(line-number-at-pos)
|
||||||
|
(string-trim-right (thing-at-point 'line)))
|
||||||
|
(point-marker)))))))
|
||||||
|
(cddr (better-jumper-jump-list-struct-ring
|
||||||
|
(better-jumper-get-jumps (better-jumper--get-current-context))))))))
|
||||||
|
:sort nil
|
||||||
|
:require-match t
|
||||||
|
:action (lambda (cand)
|
||||||
|
(let ((mark (cdr cand)))
|
||||||
|
(delq! (marker-buffer mark) buffers)
|
||||||
|
(mapc #'kill-buffer buffers)
|
||||||
|
(setq buffers nil)
|
||||||
|
(with-current-buffer (switch-to-buffer (marker-buffer mark))
|
||||||
|
(goto-char (marker-position mark)))))
|
||||||
|
:caller '+ivy/jump-list)
|
||||||
|
(mapc #'kill-buffer buffers))))
|
||||||
|
|
|
@ -110,7 +110,8 @@ evil-ex-specific constructs, so we disable it solely in evil-ex."
|
||||||
(define-key! ivy-mode-map
|
(define-key! ivy-mode-map
|
||||||
[remap switch-to-buffer] #'+ivy/switch-buffer
|
[remap switch-to-buffer] #'+ivy/switch-buffer
|
||||||
[remap switch-to-buffer-other-window] #'+ivy/switch-buffer-other-window
|
[remap switch-to-buffer-other-window] #'+ivy/switch-buffer-other-window
|
||||||
[remap persp-switch-to-buffer] #'+ivy/switch-workspace-buffer)
|
[remap persp-switch-to-buffer] #'+ivy/switch-workspace-buffer
|
||||||
|
[remap evil-show-jumps] #'+ivy/jump-list)
|
||||||
|
|
||||||
(define-key ivy-minibuffer-map (kbd "C-c C-e") #'+ivy/woccur)
|
(define-key ivy-minibuffer-map (kbd "C-c C-e") #'+ivy/woccur)
|
||||||
|
|
||||||
|
|
|
@ -598,6 +598,7 @@
|
||||||
:desc "Kill buffer" "d" #'kill-current-buffer
|
:desc "Kill buffer" "d" #'kill-current-buffer
|
||||||
:desc "ibuffer" "i" #'ibuffer
|
:desc "ibuffer" "i" #'ibuffer
|
||||||
:desc "Kill buffer" "k" #'kill-current-buffer
|
:desc "Kill buffer" "k" #'kill-current-buffer
|
||||||
|
:desc "Jumplist" "j" #'evil-show-jumps
|
||||||
:desc "Switch to last buffer" "l" #'evil-switch-to-windows-last-buffer
|
:desc "Switch to last buffer" "l" #'evil-switch-to-windows-last-buffer
|
||||||
:desc "Next buffer" "n" #'next-buffer
|
:desc "Next buffer" "n" #'next-buffer
|
||||||
:desc "New empty buffer" "N" #'evil-buffer-new
|
:desc "New empty buffer" "N" #'evil-buffer-new
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue