|
15 hours ago | |
---|---|---|
nix | 1 week ago | |
scripts | 15 hours ago | |
src/bin | 15 hours ago | |
vendor | 1 week ago | |
.envrc | 15 hours ago | |
.gitignore | 2 months ago | |
Cargo.lock | 1 week ago | |
Cargo.toml | 2 months ago | |
README.md | 1 week ago | |
build.rs | 1 week ago | |
default.nix | 2 months ago | |
shell.nix | 2 months ago |
Works like grep
, but uses tree-sitter
to search for structure instead of strings.
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
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.
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.
TODO