feat(emacs): add consult-ripgrep-file
This commit is contained in:
parent
512680499e
commit
86ef74cba8
1 changed files with 28 additions and 3 deletions
|
|
@ -36,13 +36,38 @@
|
||||||
(use-package orderless :straight t
|
(use-package orderless :straight t
|
||||||
:custom
|
:custom
|
||||||
(orderless-matching-styles '(orderless-literal-prefix orderless-literal orderless-regexp)))
|
(orderless-matching-styles '(orderless-literal-prefix orderless-literal orderless-regexp)))
|
||||||
(use-package consult :straight t
|
|
||||||
:bind (("C-c r r" . consult-ripgrep)
|
|
||||||
("C-c r g" . consult-grep)))
|
|
||||||
(use-package yasnippet :straight t
|
(use-package yasnippet :straight t
|
||||||
:hook ((prog-mode . yas-minor-mode)))
|
:hook ((prog-mode . yas-minor-mode)))
|
||||||
(use-package yasnippet-snippets :straight t)
|
(use-package yasnippet-snippets :straight t)
|
||||||
|
|
||||||
|
(use-package consult :straight t
|
||||||
|
:bind (("C-c r r" . consult-ripgrep)
|
||||||
|
("C-c r g" . consult-grep)
|
||||||
|
("C-c r f" . consult-ripgrep-file)))
|
||||||
|
|
||||||
|
(defun consult-ripgrep-file (&optional initial)
|
||||||
|
"Search with `rg' in the current file with INITIAL input."
|
||||||
|
(interactive)
|
||||||
|
(cond
|
||||||
|
((buffer-file-name)
|
||||||
|
(let* ((file (buffer-file-name))
|
||||||
|
(builder (consult--ripgrep-make-builder (list file))))
|
||||||
|
(consult--read
|
||||||
|
(consult--process-collection builder
|
||||||
|
:transform (consult--grep-format builder)
|
||||||
|
:file-handler t)
|
||||||
|
:prompt "Ripgrep (current file): "
|
||||||
|
:lookup #'consult--lookup-member
|
||||||
|
:state (consult--grep-state)
|
||||||
|
:initial initial
|
||||||
|
:add-history (thing-at-point 'symbol)
|
||||||
|
:require-match t
|
||||||
|
:category 'consult-grep
|
||||||
|
:group #'consult--prefix-group
|
||||||
|
:history '(:input consult--grep-history)
|
||||||
|
:sort nil)))
|
||||||
|
(t (user-error "Buffer not visiting a file"))))
|
||||||
|
|
||||||
(provide 'priime-completion)
|
(provide 'priime-completion)
|
||||||
|
|
||||||
;;; priime-completion.el ends here
|
;;; priime-completion.el ends here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue