feat: Bind SPC f r
- Additionally, fixed a bug where consult-recent-file would be called before recentf-mdoe was enabled
This commit is contained in:
@@ -14,24 +14,52 @@
|
|||||||
;; Consult adds various search and navigation tools using Emacs' completing-read
|
;; Consult adds various search and navigation tools using Emacs' completing-read
|
||||||
;; function; i.e., in our case, Vertico.
|
;; function; i.e., in our case, Vertico.
|
||||||
(use-package consult
|
(use-package consult
|
||||||
:defer t)
|
:defer t
|
||||||
|
:config
|
||||||
|
(advice-add #'consult-recent-file
|
||||||
|
:before #'syd-enable-recentf-mode-a))
|
||||||
|
|
||||||
(use-package embark-consult
|
(use-package embark-consult
|
||||||
:after (embark consult))
|
:after (embark consult))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun syd-vertico-embark-preview ()
|
||||||
|
"Previews candidate in vertico buffer, unless it's a consult command"
|
||||||
|
(interactive)
|
||||||
|
(unless (bound-and-true-p consult--preview-function)
|
||||||
|
(if (fboundp 'embark-dwim)
|
||||||
|
(save-selected-window
|
||||||
|
(let (embark-quit-after-action)
|
||||||
|
(embark-dwim)))
|
||||||
|
(user-error "Embark not installed, aborting..."))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun syd-enable-recentf-mode-a ()
|
||||||
|
"Used as :before advice for `consult-recent-file' to ensure recentf mode is
|
||||||
|
enabled."
|
||||||
|
;; REVIEW: Shall we take any extra precautions to only enable `recentf-mode'
|
||||||
|
;; if it was going to be enabled anyway?
|
||||||
|
(recentf-mode 1))
|
||||||
|
|
||||||
;; Vertico is a simple completion engine that replaces Emacs' built-in
|
;; Vertico is a simple completion engine that replaces Emacs' built-in
|
||||||
;; completion engine, achieving Just Works™ compatibility. This is in contrast
|
;; completion engine, achieving Just Works™ compatibility. This is in contrast
|
||||||
;; to e.g. Helm and Ivy, which spawn ecosystems orthogonal to Emacs, and
|
;; to e.g. Helm and Ivy, which spawn ecosystems orthogonal to Emacs, and
|
||||||
;; diametrically-opposed to each other.
|
;; diametrically-opposed to each other.
|
||||||
(use-package vertico
|
(use-package vertico
|
||||||
:hook (on-first-input . vertico-mode)
|
:hook (on-first-input . vertico-mode)
|
||||||
:general (:keymaps 'vertico-map
|
:general
|
||||||
|
(:keymaps 'vertico-map
|
||||||
"DEL" #'vertico-directory-delete-char
|
"DEL" #'vertico-directory-delete-char
|
||||||
"C-SPC" #'+vertico/embark-preview
|
"C-SPC" #'syd-vertico-embark-preview
|
||||||
"C-j" #'vertico-next
|
"C-j" #'vertico-next
|
||||||
"C-k" #'vertico-previous
|
"C-k" #'vertico-previous
|
||||||
"C-M-j" #'vertico-next-group
|
"C-M-j" #'vertico-next-group
|
||||||
"C-M-k" #'vertico-previous-group)
|
"C-M-k" #'vertico-previous-group)
|
||||||
|
(:keymaps 'vertico-map
|
||||||
|
:states 'normal
|
||||||
|
"j" #'vertico-next
|
||||||
|
"k" #'vertico-previous
|
||||||
|
"RET" #'vertico-exit)
|
||||||
:custom ((vertico-resize nil)
|
:custom ((vertico-resize nil)
|
||||||
(vertico-count 17)
|
(vertico-count 17)
|
||||||
(vertico-cycle t))
|
(vertico-cycle t))
|
||||||
@@ -41,7 +69,7 @@
|
|||||||
;; cleans ~/foo/bar/// to /, and ~/foo/bar/~/ to ~/.
|
;; cleans ~/foo/bar/// to /, and ~/foo/bar/~/ to ~/.
|
||||||
(add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy))
|
(add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy))
|
||||||
|
|
||||||
(defun +vertico-orderless-dispatch (pattern _index _total)
|
(defun syd-vertico-orderless-dispatch (pattern _index _total)
|
||||||
"Like `orderless-affix-dispatch', but allows affixes to be escaped.
|
"Like `orderless-affix-dispatch', but allows affixes to be escaped.
|
||||||
|
|
||||||
Shamelessly stolen from Doom. }:3"
|
Shamelessly stolen from Doom. }:3"
|
||||||
@@ -72,7 +100,7 @@ Shamelessly stolen from Doom. }:3"
|
|||||||
'((file
|
'((file
|
||||||
(styles ;basic-remote
|
(styles ;basic-remote
|
||||||
orderless partial-completion))))
|
orderless partial-completion))))
|
||||||
(orderless-style-dispatchers '(+vertico-orderless-dispatch))
|
(orderless-style-dispatchers '(syd-vertico-orderless-dispatch))
|
||||||
;; TODO: See Doom's `+vertico-orderless-dispatch'.
|
;; TODO: See Doom's `+vertico-orderless-dispatch'.
|
||||||
(orderless-affix-dispatch-alist
|
(orderless-affix-dispatch-alist
|
||||||
'((?! . orderless-without-literal)
|
'((?! . orderless-without-literal)
|
||||||
|
|||||||
@@ -147,7 +147,8 @@ all hooks after it are ignored.")
|
|||||||
"P" `("Browse Emacs config" . ,#'syd/find-file-in-emacs-user-directory)
|
"P" `("Browse Emacs config" . ,#'syd/find-file-in-emacs-user-directory)
|
||||||
"u" `("Find file as root" . ,#'syd/find-file-as-root)
|
"u" `("Find file as root" . ,#'syd/find-file-as-root)
|
||||||
"U" `("Open this file as root" . ,#'syd/open-this-file-as-root)
|
"U" `("Open this file as root" . ,#'syd/open-this-file-as-root)
|
||||||
"y" `("Yank buffer path" . ,#'syd/yank-buffer-path))
|
"y" `("Yank buffer path" . ,#'syd/yank-buffer-path)
|
||||||
|
"r" `("Browse recent file" . ,#'consult-recent-file))
|
||||||
|
|
||||||
;; Window
|
;; Window
|
||||||
(require 'syd-window)
|
(require 'syd-window)
|
||||||
|
|||||||
Reference in New Issue
Block a user