Remove references to old ivy/helm search commands

And consolidate ex commands into :pg[rep][!] and :pg[rep]d[!].
This commit is contained in:
Henrik Lissner 2019-11-18 15:05:20 -05:00
parent 0be962bb77
commit 263c82def1
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
5 changed files with 50 additions and 162 deletions

View file

@ -72,9 +72,9 @@ Emacs.")
;; Disable commands that won't work, as is, and that Doom already provides a
;; better alternative for.
(put 'projectile-ag 'disabled "Use +{ivy,helm}/project-search or +{ivy,helm}/ag instead")
(put 'projectile-ripgrep 'disabled "Use +{ivy,helm}/project-search or +{ivy,helm}/rg instead")
(put 'projectile-grep 'disabled "Use +{ivy,helm}/project-search or +{ivy,helm}/grep instead")
(put 'projectile-ag 'disabled "Use +{ivy,helm}/project-search instead")
(put 'projectile-ripgrep 'disabled "Use +{ivy,helm}/project-search instead")
(put 'projectile-grep 'disabled "Use +{ivy,helm}/project-search instead")
;; Treat current directory in dired as a "file in a project" and track it
(add-hook 'dired-before-readin-hook #'projectile-track-known-projects-find-file-hook)

View file

@ -1,46 +1,17 @@
;;; completion/helm/autoload/evil.el -*- lexical-binding: t; -*-
;;;###if (featurep! :editor evil)
;;
;; Project searching
;;;###autoload (autoload '+helm:grep "completion/helm/autoload/evil" nil t)
(evil-define-command +helm:grep (all-files-p query)
;;;###autoload (autoload '+helm:project-search "completion/helm/autoload/evil" nil t)
(evil-define-command +helm:project-search (all-files-p query)
"Ex interface for `+helm/grep'"
(interactive "<!><a>")
(+helm/grep all-files-p query))
(+helm/project-search all-files-p query))
;;;###autoload (autoload '+helm:ag "completion/helm/autoload/evil" nil t)
(evil-define-command +helm:ag (all-files-p query)
"Ex interface for `+helm/ag'"
(interactive "<!><a>")
(+helm/ag all-files-p query))
;;;###autoload (autoload '+helm:rg "completion/helm/autoload/evil" nil t)
(evil-define-command +helm:rg (all-files-p query)
"Ex interface for `+helm/rg'"
(interactive "<!><a>")
(+helm/rg all-files-p query))
;;;###autoload (autoload '+helm:grep-from-cwd "completion/helm/autoload/evil" nil t)
(evil-define-command +helm:grep-from-cwd (query &optional recurse-p)
;;;###autoload (autoload '+helm:project-search-from-cwd "completion/helm/autoload/evil" nil t)
(evil-define-command +helm:project-search-from-cwd (query &optional recurse-p)
"Ex interface for `+helm/grep-from-cwd'."
(interactive "<a><!>")
(+helm/grep-from-cwd (not recurse-p) query))
;;;###autoload (autoload '+helm:ag-from-cwd "completion/helm/autoload/evil" nil t)
(evil-define-command +helm:ag-from-cwd (query &optional recurse-p)
"Ex interface for `+helm/ag-from-cwd'."
(interactive "<a><!>")
(+helm/ag-from-cwd (not recurse-p) query))
;;;###autoload (autoload '+helm:rg-from-cwd "completion/helm/autoload/evil" nil t)
(evil-define-command +helm:rg-from-cwd (query &optional recurse-p)
"Ex interface for `+helm/rg-from-cwd'."
(interactive "<a><!>")
(+helm/rg-from-cwd (not recurse-p) query))
(+helm/project-search-from-cwd (not recurse-p) query))
;;;###autoload
(defun +helm--set-prompt-display (pos)

View file

@ -17,7 +17,6 @@
- [[#jump-to-file-project-navigation][Jump-to-file project navigation]]
- [[#project-search--replace][Project search & replace]]
- [[#in-buffer-searching][In-buffer searching]]
- [[#task-lookup][Task lookup]]
- [[#ivy-integration-for-various-completing-commands][Ivy integration for various completing commands]]
- [[#general][General]]
- [[#jump-to-files-buffers-or-projects][Jump to files, buffers or projects)]]
@ -29,8 +28,7 @@
* Description
This module provides Ivy integration for a variety of Emacs commands, as well as
a unified interface for project search and replace, powered by ag, rg,
git-grep & grep (whichever is available).
a unified interface for project search and replace, powered by ripgrep.
#+begin_quote
I prefer ivy over ido for its flexibility. I prefer ivy over helm because it's
@ -41,7 +39,6 @@ lighter, simpler and faster in many cases.
+ =+fuzzy= Enables fuzzy completion for Ivy searches.
+ =+prescient= Enables prescient filtering and sorting for Ivy searches.
+ =+childframe= Causes Ivy to display in a floating child frame, above Emacs.
*This requires GUI Emacs 26.1+*
+ =+icons= Enables file icons for switch-{buffer,project}/find-file counsel
commands.
@ -67,32 +64,24 @@ lighter, simpler and faster in many cases.
command)
* Prerequisites
This module optionally depends on one of:
This module depends on:
+ [[https://github.com/BurntSushi/ripgrep][ripgrep]] (rg)
+ [[https://github.com/ggreer/the_silver_searcher][the_silver_searcher]] (ag)
Ripgrep is recommended, but the order of its results aren't deterministic and it
doesn't support full PCRE (at the time of writing). The_silver_searcher is a
good alternative if either of these bother you.
If none of these are installed, file search commands will use git-grep (falling
back to grep, otherwise).
** Install
*** MacOS
#+BEGIN_SRC sh
brew install ripgrep the_silver_searcher
brew install ripgrep
#+END_SRC
*** Arch Linux
#+BEGIN_SRC sh :dir /sudo::
sudo pacman --needed --noconfirm -S ripgrep the_silver_searcher
sudo pacman --needed --noconfirm -S ripgrep
#+END_SRC
*** openSUSE
#+BEGIN_SRC sh :dir /sudo::
sudo zypper install ripgrep the_silver_searcher
sudo zypper install ripgrep
#+END_SRC
* Features
@ -112,8 +101,7 @@ https://assets.doomemacs.org/completion/ivy/projectile.png
| =SPC f f=, =SPC .= | Jump to file from current directory |
** Project search & replace
This module provides interactive text search and replace using the first search
program available on your system (rg, ag, git-grep or grep).
This module provides interactive text search and replace using ripgrep.
| Keybind | Description |
|-----------+---------------------------------|
@ -124,41 +112,23 @@ program available on your system (rg, ag, git-grep or grep).
https://assets.doomemacs.org/completion/ivy/search.png
The ~+ivy-project-search-engines~ variable is consulted to determine which
underlying program to check for (and in what order). It's default value is ~'(rg
ag pt)~. If none of these are available, it will resort to =git-grep= (falling
back to =grep= after that).
To use a specific program, the following engine-specific commands are available
(but not bound to any key by default) for searching from the project root or the
current directory (recursively), respectively:
+ ~+ivy/ag~ / ~+ivy/ag-from-cwd~
+ ~+ivy/rg~ / ~+ivy/rg-from-cwd~
+ ~+ivy/grep~ / ~+ivy/grep-from-cwd~
The universal argument (=SPC u= for evil users; =C-u= otherwise) changes the
behavior of these commands, instructing the underlying search engine to include
ignored files.
This module also provides Ex Commands for evil users:
| Ex command | Description |
|-----------------------+------------------------------------------------|
| ~:ag[!] [QUERY]~ | Search project w/ ag[fn:1] |
| ~:rg[!] [QUERY]~ | Search project w/ rg[fn:1] |
| ~:grep[!] [QUERY]~ | Search project w/ git-grep/grep[fn:1] |
| ~:agcwd[!] [QUERY]~ | Search this directory w/ the_silver_searcher |
| ~:rgcwd[!] [QUERY]~ | Search this directory w/ ripgrep |
| ~:grepcwd[!] [QUERY]~ | Search this directory w/ git-grep/grep |
| Ex command | Description |
|------------------------+------------------------------------------------------------------|
| ~:pg[rep][!] [QUERY]~ | Search project (if ~!~, include hidden files) |
| ~:pg[rep]d[!] [QUERY]~ | Search from current directory (if ~!~, don't search recursively) |
The optional BANG functions is equivalent to the universal argument for the
previous commands.
-----
While in a search (e.g. invoked from ~+ivy:ag~ or ~:rg~), these extra
keybindings are available to you:
While in a search these extra keybindings are available to you:
| Keybind | Description |
|-----------+-----------------------------------------------|
@ -176,22 +146,14 @@ https://assets.doomemacs.org/completion/ivy/search-replace.png
The =swiper= package provides an interactive buffer search powered by ivy. It
can be invoked with:
+ =SPC s b=
+ =SPC s s=
+ =SPC s S= (uses thing at point as initial input)
+ ~:sw[iper] [QUERY]~
https://assets.doomemacs.org/completion/ivy/swiper.png
A wgrep buffer can be opened from swiper with =C-c C-e=.
** Task lookup
Some projects have TODO's and FIXME's littered across them. The ~+ivy/tasks~
command allows you to search and jump to them. It can be invoked with:
+ =SPC p t= (C-u = restrict search to current file)
+ ~:todo[!]~ (BANG = restrict search to current file)
https://assets.doomemacs.org/completion/ivy/todo.png
** Ivy integration for various completing commands
*** General
| Keybind | Description |
@ -211,14 +173,16 @@ https://assets.doomemacs.org/completion/ivy/todo.png
| =SPC b B=, =SPC <= | Switch to buffer |
*** Search
| Keybind | Description |
|-----------+------------------------------------------|
| =SPC s i= | Search for symbol in current buffer |
| =SPC s I= | Search for symbol in all similar buffers |
| =SPC s b= | Search the current buffer |
| =SPC s p= | Search project |
| =SPC s d= | Search this directory |
| =SPC p t= | List all TODO/FIXMEs in project |
| Keybind | Description |
|-----------+-------------------------------------------|
| =SPC p t= | List all TODO/FIXMEs in project |
| =SPC s b= | Search the current buffer |
| =SPC s d= | Search this directory |
| =SPC s D= | Search another directory |
| =SPC s i= | Search for symbol in current buffer |
| =SPC s p= | Search project |
| =SPC s P= | Search another project |
| =SPC s s= | Search the current buffer (incrementally) |
* Configuration
** TODO Enable fuzzy/non-fuzzy search for specific commands

View file

@ -1,55 +1,14 @@
;; completion/ivy/autoload/evil.el -*- lexical-binding: t; -*-
;;;###if (featurep! :editor evil)
;;;###autoload (autoload '+ivy:swiper "completion/ivy/autoload/evil" nil t)
(evil-define-command +ivy:swiper (&optional search)
"Invoke `swiper' with SEARCH, otherwise with the symbol at point."
(interactive "<a>")
(swiper search))
;;;###autoload (autoload '+ivy:todo "completion/ivy/autoload/evil" nil t)
(evil-define-command +ivy:todo (&optional bang)
"An ex wrapper around `+ivy/tasks'."
(interactive "<!>")
(+ivy/tasks bang))
;;
;; Project searching
;;;###autoload (autoload '+ivy:grep "completion/ivy/autoload/evil" nil t)
(evil-define-command +ivy:grep (all-files-p query)
"Ex interface for `+ivy/grep'"
(interactive "<!><a>")
(+ivy/grep all-files-p query))
;;;###autoload (autoload '+ivy:ag "completion/ivy/autoload/evil" nil t)
(evil-define-command +ivy:ag (all-files-p query)
"Ex interface for `+ivy/ag'"
(interactive "<!><a>")
(+ivy/ag all-files-p query))
;;;###autoload (autoload '+ivy:rg "completion/ivy/autoload/evil" nil t)
(evil-define-command +ivy:rg (all-files-p query)
"Ex interface for `+ivy/rg'"
(interactive "<!><a>")
(+ivy/rg all-files-p query))
;;;###autoload (autoload '+ivy:grep-from-cwd "completion/ivy/autoload/evil" nil t)
(evil-define-command +ivy:grep-from-cwd (query &optional recurse-p)
"Ex interface for `+ivy/grep-from-cwd'."
;;;###autoload (autoload '+ivy:project-search "completion/ivy/autoload/evil" nil t)
(evil-define-command +ivy:project-search (query &optional all-files-p)
"Ex interface for `+ivy/project-search'."
(interactive "<a><!>")
(+ivy/grep-from-cwd (not recurse-p) query))
(+ivy/project-search all-files-p query))
;;;###autoload (autoload '+ivy:ag-from-cwd "completion/ivy/autoload/evil" nil t)
(evil-define-command +ivy:ag-from-cwd (query &optional recurse-p)
"Ex interface for `+ivy/ag-from-cwd'."
;;;###autoload (autoload '+ivy:project-search-from-cwd "completion/ivy/autoload/evil" nil t)
(evil-define-command +ivy:project-search-from-cwd (query &optional recurse-p)
"Ex interface for `+ivy/project-search-from-cwd'."
(interactive "<a><!>")
(+ivy/ag-from-cwd (not recurse-p) query))
;;;###autoload (autoload '+ivy:rg-from-cwd "completion/ivy/autoload/evil" nil t)
(evil-define-command +ivy:rg-from-cwd (query &optional recurse-p)
"Ex interface for `+ivy/rg-from-cwd'."
(interactive "<a><!>")
(+ivy/rg-from-cwd (not recurse-p) query))
(+ivy/project-search-from-cwd (not recurse-p) query))

View file

@ -57,25 +57,19 @@
(evil-ex-define-cmd "cd" #'+evil:cd)
(evil-ex-define-cmd "pwd" #'+evil:pwd)
(evil-define-command +evil:swiper (&optional search)
"Invoke `swiper' with SEARCH, otherwise with the symbol at point."
(interactive "<a>")
(swiper-isearch search))
(evil-ex-define-cmd "sw[iper]" #'+evil:swiper)
(cond ((featurep! :completion ivy)
(evil-ex-define-cmd "ag" #'+ivy:ag)
(evil-ex-define-cmd "agc[wd]" #'+ivy:ag-from-cwd)
(evil-ex-define-cmd "rg" #'+ivy:rg)
(evil-ex-define-cmd "rgc[wd]" #'+ivy:rg-from-cwd)
(evil-ex-define-cmd "grep" #'+ivy:grep)
(evil-ex-define-cmd "grepc[wd]" #'+ivy:grep-from-cwd)
(evil-ex-define-cmd "sw[iper]" #'+ivy:swiper)
(evil-ex-define-cmd "todo" #'+ivy:todo))
(evil-ex-define-cmd "pg[rep]" #'+ivy:project-search)
(evil-ex-define-cmd "pg[grep]d" #'+ivy:project-search-from-cwd))
((featurep! :completion helm)
(evil-ex-define-cmd "ag" #'+helm:ag)
(evil-ex-define-cmd "agc[wd]" #'+helm:ag-from-cwd)
(evil-ex-define-cmd "rg" #'+helm:rg)
(evil-ex-define-cmd "rgc[wd]" #'+helm:rg-from-cwd)
(evil-ex-define-cmd "grep" #'+helm:grep)
(evil-ex-define-cmd "grepc[wd]" #'+helm:grep-from-cwd)
;; (evil-ex-define-cmd "todo" #'+helm:todo) TODO implement `+helm:todo'
))
(evil-ex-define-cmd "pg[rep]" #'+helm:project-search)
(evil-ex-define-cmd "pg[grep]d" #'+helm:project-search-from-cwd)))
;;; Project tools
(evil-ex-define-cmd "compile" #'+evil:compile)