fix(selectrum): Tear +selectrum-file-search down to consult-ripgrep
This commit is contained in:
parent
74b100cd54
commit
4fb1b7ed23
1 changed files with 2 additions and 30 deletions
|
@ -11,6 +11,7 @@ one face."
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(cl-defun +selectrum-file-search (&key query in all-files (recursive t) prompt args)
|
(cl-defun +selectrum-file-search (&key query in all-files (recursive t) prompt args)
|
||||||
"Conduct a file search using ripgrep.
|
"Conduct a file search using ripgrep.
|
||||||
|
|
||||||
:query STRING
|
:query STRING
|
||||||
Determines the initial input to search for.
|
Determines the initial input to search for.
|
||||||
:in PATH
|
:in PATH
|
||||||
|
@ -22,36 +23,7 @@ one face."
|
||||||
(user-error "Couldn't find ripgrep in your PATH"))
|
(user-error "Couldn't find ripgrep in your PATH"))
|
||||||
(require 'consult)
|
(require 'consult)
|
||||||
(setq deactivate-mark t)
|
(setq deactivate-mark t)
|
||||||
(let* ((this-command 'consult--grep)
|
(consult-ripgrep))
|
||||||
(project-root (or (doom-project-root) default-directory))
|
|
||||||
(directory (or in project-root))
|
|
||||||
(prompt (or prompt
|
|
||||||
(format "rg [%s]: "
|
|
||||||
(cond ((equal directory default-directory)
|
|
||||||
"./")
|
|
||||||
((equal directory project-root)
|
|
||||||
(projectile-project-name))
|
|
||||||
((file-relative-name directory project-root))))))
|
|
||||||
(query (or query
|
|
||||||
(when (doom-region-active-p)
|
|
||||||
(replace-regexp-in-string
|
|
||||||
"[! |]" (lambda (substr)
|
|
||||||
(cond ((and (string= substr " ")
|
|
||||||
(not (featurep! +fuzzy)))
|
|
||||||
" ")
|
|
||||||
((string= substr "|")
|
|
||||||
"\\\\\\\\|")
|
|
||||||
((concat "\\\\" substr))))
|
|
||||||
(rxt-quote-pcre (doom-thing-at-point-or-region))))))
|
|
||||||
(ripgrep-command (format "rg %s . -e"
|
|
||||||
(string-trim
|
|
||||||
(concat (if all-files "-uu")
|
|
||||||
(unless recursive "--maxdepth 1")
|
|
||||||
"--null --line-buffered --color=always --max-columns=500 --no-heading --line-number"
|
|
||||||
" --hidden -g!.git "
|
|
||||||
(mapconcat #'shell-quote-argument args " ")))
|
|
||||||
args)))
|
|
||||||
(consult--grep prompt ripgrep-command directory query)))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +selectrum/project-search (&optional arg initial-query directory)
|
(defun +selectrum/project-search (&optional arg initial-query directory)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue