diff options
author | David Morgan <djm_uk@protonmail.com> | 2021-09-01 10:28:23 +0100 |
---|---|---|
committer | David Morgan <djm_uk@protonmail.com> | 2021-09-01 10:28:23 +0100 |
commit | 85ed757c6240ccf4dc47eee1b705c995982b3f5c (patch) | |
tree | ee581df1aeaee08c799ea0908ffd3f7b9b1a6466 /.emacs.d | |
parent | 1bfdf5225f5f945dae7a469e65be686a8dad9e44 (diff) | |
download | dotfiles-85ed757c6240ccf4dc47eee1b705c995982b3f5c.tar.gz |
Add consult-fd and fix binding
Diffstat (limited to '.emacs.d')
-rw-r--r-- | .emacs.d/lisp/init-minibuffer.el | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el index 3bdfc11..f31ed3d 100644 --- a/.emacs.d/lisp/init-minibuffer.el +++ b/.emacs.d/lisp/init-minibuffer.el @@ -189,15 +189,39 @@ (defun consult-line-symbol-at-point () (interactive) (consult-line (thing-at-point 'symbol))) + (defvar consult--fd-command nil) + (defun consult--fd-builder (input) + (unless consult--fd-command + (setq consult--fd-command + (if (eq 0 (call-process-shell-command "fdfind")) + "fdfind" + "fd"))) + (pcase-let* ((`(,arg . ,opts) (consult--command-split input)) + (`(,re . ,hl) (funcall consult--regexp-compiler + arg 'extended))) + (when re + (list :command (append + (list consult--fd-command + "--color=never" "--full-path" + (consult--join-regexps re 'extended)) + opts) + :highlight hl)))) + + (defun consult-fd (&optional dir initial) + (interactive "P") + (let* ((prompt-dir (consult--directory-prompt "Fd" dir)) + (default-directory (cdr prompt-dir))) + (find-file (consult--find (car prompt-dir) #'consult--fd-builder initial)))) ;; Add these here, as we have two bindings for search map (M-s and C-c s) - (define-key search-map "f" 'consult-find) - (define-key search-map "F" 'consult-locate) + (define-key search-map "f" 'consult-fd) + (define-key search-map "F" 'consult-find) + (define-key search-map (kbd "M-f") 'consult-locate) (define-key search-map "g" 'consult-grep) (define-key search-map "G" 'consult-git-grep) (define-key search-map "r" 'consult-ripgrep) (define-key search-map "R" 'consult-ripgrep-auto-preview) - (define-key search-map "M-r" 'consult-ripgrep-unrestricted) + (define-key search-map (kbd "M-r") 'consult-ripgrep-unrestricted) (define-key search-map "*" 'consult-ripgrep-symbol-at-point) (define-key search-map "z" 'consult-z-ripgrep) (define-key search-map "l" 'consult-line) |