fix(vertico): add +ivy/jump-list analogue
Fix 'SPC s j' for consult users.
This commit is contained in:
parent
33b646826b
commit
9d7338d4b8
2 changed files with 42 additions and 0 deletions
|
@ -177,3 +177,44 @@ If INITIAL is non-nil, use as initial input."
|
|||
:add-history (thing-at-point 'filename)
|
||||
:category '+vertico
|
||||
:history '(:input +vertico/find-file-in--history)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +vertico/jump-list (jump)
|
||||
"Go to an entry in evil's (or better-jumper's) jumplist."
|
||||
(interactive
|
||||
(let (buffers)
|
||||
(unwind-protect
|
||||
(list
|
||||
(consult--read
|
||||
;; REVIEW Refactor me
|
||||
(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 (or (thing-at-point 'line) "")))
|
||||
(point-marker)))))))
|
||||
(cddr (better-jumper-jump-list-struct-ring
|
||||
(better-jumper-get-jumps (better-jumper--get-current-context))))))))
|
||||
:prompt "jumplist: "
|
||||
:sort nil
|
||||
:require-match t
|
||||
:category 'jump-list))
|
||||
(mapc #'kill-buffer buffers))))
|
||||
(let ((mark (cdr jump)))
|
||||
(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)))))
|
||||
|
|
|
@ -67,6 +67,7 @@ overrides `completion-styles' during company completion sessions.")
|
|||
[remap apropos] #'consult-apropos
|
||||
[remap bookmark-jump] #'consult-bookmark
|
||||
[remap evil-show-marks] #'consult-mark
|
||||
[remap evil-show-jumps] #'+vertico/jump-list
|
||||
[remap goto-line] #'consult-goto-line
|
||||
[remap imenu] #'consult-imenu
|
||||
[remap locate] #'consult-locate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue