Expand description
Quick search for symbol definitions in various programming languages
Currently this supports Rust, JS (or TypeScript), and PHP.
This can be used like “Go to definition” in an IDE, except that instead of using a language server, it just searches for the definition using text parsing. This is less accurate but often faster in projects with lots of files or where a language server won’t work or hasn’t yet started.
grepdef since 3.0 is written in Rust and is designed to be extremely fast.
This can also be used as a library crate for other Rust programs.
§Example
The syntax of the CLI is similar to that of grep
or ripgrep
: first put the symbol you want
to search for (eg: a function name, class name, etc.) and then list the file(s) or directories
over which you want to search.
$ grepdef parseQuery ./src
./src/queries.js:function parseQuery {
Just like grep
, you can add the -n
option to include line numbers.
$ grepdef -n parseQuery ./src
./src/queries.js:17:function parseQuery {
The search will be faster if you specify what type of file you are searching for using the
--type
option.
$ grepdef --type js -n parseQuery ./src
./src/queries.js:17:function parseQuery {
To use the crate from other Rust code, use Searcher.
use grepdef::{Args, Searcher};
for result in Searcher::new(Args::from_query("parseQuery")).unwrap().search().unwrap() {
println!("{}", result.to_grep());
}
Structs§
- Args
- The command-line arguments to be used by Searcher
- Search
Result - A result from calling Searcher::search or Searcher::search_and_format
- Searcher
- A struct that can perform a search
Enums§
- Color
Option - The supported arguments to the color option
- File
Type - The supported file types to search
- Search
Event Type - The type of a search event
- Search
Method - (Advanced) The type of underlying search algorithm to use
- Search
Result Format - The output format of SearchResult