Like grep, but uses tree-sitter grammars to search in structures instead of strings
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Brian Hicks b20fc8929e pass the language so I can actually query Ruby stuff 15 hours ago
nix update sources 1 week ago
scripts add wrapper scripts to make running exploration commands easier 15 hours ago
src/bin pass the language so I can actually query Ruby stuff 15 hours ago
vendor Merge commit 'cbde19c3d59ddfb7622d252f55306997d250c335' into main 1 week ago
.envrc add wrapper scripts to make running exploration commands easier 15 hours ago
.gitignore cargo init 2 months ago
Cargo.lock update crates 1 week ago
Cargo.toml add real JSON output 2 months ago
README.md add more TODOs 1 week ago
build.rs compile tree-sitter-ruby 1 week ago
default.nix add xcbuild to get around cc errors 2 months ago
shell.nix nixify 2 months ago

README.md

tree-grepper

Works like grep, but uses tree-sitter to search for structure instead of strings.

Installing

This isn't available packaged anywhere. That's fine, use nix:

nix-env -if https://git.bytes.zone/brian/tree-grepper/archive/main.tar.gz

Usage

Use it like grep (or really, more like ack/ag/pt/rg.)

$ tree-grepper '(import_clause (import) (upper_case_qid)@name)'
src/Main.elm:3:1:Browser
src/Main.elm:4:1:Browser.Navigation
src/main.elm:5:1:Css
...

tree-grepper uses Tree-sitter's s-expressions to find matches.

The binary name might change in the future if we find a better/shorter name. Stay tuned.

Some Terrible Benchmarks

On the first possible working version of tree-grepper:

Command Mean Time (Hyperfine)
tree-grepper '(import_clause)@import' 17.2ms
rg -t elm '^import' 10.3ms
grep -rE '^import' 71.0ms

So this is on rg's level of quickness (which makes sense, as this tool uses their tree walking/gitignoring library.) This tool may get slower as we add features, or faster as I learn more about how to write good Rust.

Roadmap

License

TODO