completion/helm: replace helm-ag with helm-rg
This commit is contained in:
parent
e3f8674297
commit
6facc534ce
3 changed files with 22 additions and 50 deletions
|
@ -51,46 +51,18 @@ workspace."
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
(unless (executable-find "rg")
|
(unless (executable-find "rg")
|
||||||
(user-error "Couldn't find ripgrep in your PATH"))
|
(user-error "Couldn't find ripgrep in your PATH"))
|
||||||
(require 'helm-ag)
|
(require 'helm-rg)
|
||||||
(helm-ag--init-state)
|
(let ((helm-rg-default-directory (or in (doom-project-root) default-directory))
|
||||||
(let* ((project-root (or (doom-project-root) default-directory))
|
(helm-rg-default-extra-args
|
||||||
(directory (or in project-root))
|
(delq nil (list (when all-files "-z -uu")
|
||||||
(default-directory directory)
|
(unless recursive "--maxdepth 1")))))
|
||||||
(helm-ag--default-directory directory)
|
(helm-rg (or query
|
||||||
(helm-ag--default-target (list directory))
|
(when (use-region-p)
|
||||||
(query (or query
|
(let ((beg (or (bound-and-true-p evil-visual-beginning) (region-beginning)))
|
||||||
(when (use-region-p)
|
(end (or (bound-and-true-p evil-visual-end) (region-end))))
|
||||||
(let ((beg (or (bound-and-true-p evil-visual-beginning) (region-beginning)))
|
(when (> (abs (- end beg)) 1)
|
||||||
(end (or (bound-and-true-p evil-visual-end) (region-end))))
|
(buffer-substring-no-properties beg end))))
|
||||||
(when (> (abs (- end beg)) 1)
|
""))))
|
||||||
(rxt-quote-pcre (buffer-substring-no-properties beg end)))))
|
|
||||||
""))
|
|
||||||
(prompt (format "[rg %s] "
|
|
||||||
(cond ((file-equal-p directory project-root)
|
|
||||||
(projectile-project-name))
|
|
||||||
((file-equal-p directory default-directory)
|
|
||||||
"./")
|
|
||||||
((file-relative-name directory project-root)))))
|
|
||||||
(command
|
|
||||||
(list "rg --no-heading --line-number --color never"
|
|
||||||
"-S"
|
|
||||||
(when all-files "-z -uu")
|
|
||||||
(unless recursive "--maxdepth 1")))
|
|
||||||
(helm-ag-base-command (string-join (delq nil command) " ")))
|
|
||||||
;; TODO Define our own sources instead
|
|
||||||
(helm-attrset 'name (format "[rg %s] Searching %s"
|
|
||||||
(string-join (delq nil (cdr command)) " ")
|
|
||||||
(abbreviate-file-name directory))
|
|
||||||
helm-source-do-ag)
|
|
||||||
(helm-attrset '+helm-command command helm-source-do-ag)
|
|
||||||
(cl-letf (((symbol-function 'helm-do-ag--helm)
|
|
||||||
(lambda () (helm :sources '(helm-source-do-ag)
|
|
||||||
:prompt prompt
|
|
||||||
:buffer "*helm-rg*"
|
|
||||||
:keymap helm-do-ag-map
|
|
||||||
:input query
|
|
||||||
:history 'helm-ag--helm-history))))
|
|
||||||
(helm-do-ag directory))))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +helm/project-search (&optional arg initial-query directory)
|
(defun +helm/project-search (&optional arg initial-query directory)
|
||||||
|
|
|
@ -77,7 +77,6 @@ be negative.")
|
||||||
|
|
||||||
(let ((fuzzy (featurep! +fuzzy)))
|
(let ((fuzzy (featurep! +fuzzy)))
|
||||||
(setq helm-M-x-fuzzy-match fuzzy
|
(setq helm-M-x-fuzzy-match fuzzy
|
||||||
helm-ag-fuzzy-match fuzzy
|
|
||||||
helm-apropos-fuzzy-match fuzzy
|
helm-apropos-fuzzy-match fuzzy
|
||||||
helm-apropos-fuzzy-match fuzzy
|
helm-apropos-fuzzy-match fuzzy
|
||||||
helm-bookmark-show-location fuzzy
|
helm-bookmark-show-location fuzzy
|
||||||
|
@ -125,14 +124,15 @@ be negative.")
|
||||||
:config (helm-flx-mode +1))
|
:config (helm-flx-mode +1))
|
||||||
|
|
||||||
|
|
||||||
(after! helm-ag
|
(after! helm-rg
|
||||||
(map! :map helm-ag-edit-map :n "RET" #'compile-goto-error)
|
(set-popup-rule! "^helm-rg-" :ttl nil :select t :size 0.45)
|
||||||
(define-key helm-ag-edit-map [remap quit-window] #'helm-ag--edit-abort)
|
(map! :map helm-rg-map
|
||||||
(set-popup-rule! "^\\*helm-ag-edit" :size 0.35 :ttl 0 :quit nil)
|
"C-c C-e" #'helm-rg--bounce)
|
||||||
;; Recenter after jumping to match
|
(map! :map helm-rg--bounce-mode-map
|
||||||
(advice-add #'helm-ag--find-file-action :after-while #'doom-recenter-a)
|
"q" #'kill-current-buffer
|
||||||
;; And record position before jumping
|
"C-c C-c" (λ! (helm-rg--bounce-dump) (kill-current-buffer))
|
||||||
(advice-add #'helm-ag--find-file-action :around #'doom-set-jump-maybe-a))
|
"C-x C-c" #'helm-rg--bounce-dump-current-file
|
||||||
|
"C-c C-k" #'kill-current-buffer))
|
||||||
|
|
||||||
|
|
||||||
;;;###package helm-bookmark
|
;;;###package helm-bookmark
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
;;; completion/helm/packages.el
|
;;; completion/helm/packages.el
|
||||||
|
|
||||||
(package! helm)
|
(package! helm)
|
||||||
(package! helm-ag)
|
(package! helm-rg)
|
||||||
(package! helm-c-yasnippet)
|
(package! helm-c-yasnippet)
|
||||||
(package! helm-company)
|
(package! helm-company)
|
||||||
(package! helm-describe-modes :recipe (:host github :repo "emacs-helm/helm-describe-modes"))
|
(package! helm-describe-modes :recipe (:host github :repo "emacs-helm/helm-describe-modes"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue