| Crates.io | dook |
| lib.rs | dook |
| version | 0.3.1 |
| created_at | 2024-07-01 03:32:04.408606+00 |
| updated_at | 2025-06-03 12:21:12.210807+00 |
| description | Look up definitions in your code |
| homepage | https://github.com/pteromys/dook |
| repository | https://github.com/pteromys/dook |
| max_upload_size | |
| id | 1288337 |
| size | 324,500 |
Find code definitions using tree-sitter and ripgrep, and pretty-print them using bat.
Install ripgrep, bat, and uv. Then:
uv tool install dook
(It's also on crates.io if you want to build it yourself. Or if you want to be on the cutting edge you can instead cargo install --git https://github.com/pteromys/dook -F stdin,static_python.)
If you want completion assistance in bash or zsh, install either:
~/.local/share/bash-completion/completions/dook or_dook somewhere on zsh's fpath.pteromys@delia ~/src/dook $ dook into_iter
───────┬────────────────────────────────────────────────────
│ File: ./src/range_union.rs
───────┼────────────────────────────────────────────────────
51 │ impl<'it> IntoIterator for &'it RangeUnion {
... │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ 8< ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
54 │ fn into_iter(self) -> Self::IntoIter {
55 │ self.iter()
56 │ }
───────┴────────────────────────────────────────────────────
Also attempts to find assignments, class definitions, etc—because why should you have to figure out the difference before you search? In old javascript codebases there isn't really a difference anyway!
~/.config/dook/somelanguage.yml, where somelanguage is one of the keys in src/language_aliases.rs. Crib from any of the files in config/. (python.yml is probably a decent example.)test_cases/, named anything you like.dook with this language for a week or two. Every time you edit .yml file, consider adding a corresponding example to the file you created in test_cases/.If you want to roll the dice on submitting a PR (see below), copy your .yml file to config/ and submit a patch adding that and your file from test_cases/. If you're familiar with Rust, add a constant for your language to LanguageName and your list of example search terms to tests/examples.rs. Otherwise I'll add those for you if I ever respond.
Create ~/.config/dook/downloads_policy.txt containing the text yes, ask, or no to control what dook does when it needs to download a language parser from the internet. The default is ask (ask for confirmation every time). If you're paranoid, you might prefer to use ask for a week and then switch to no to get pager integration.
dook creates and uses the following directories for storage:
~/.cache/dook/sources for downloaded parsers~/.cache/tree-sitter for compiled parsers, using tree-sitter-loadergit grep -W 'def your_function_name\(' (or a language-specific analogue) is often good enough in a bunch of languages. And if you pipe it to delta you can get syntax highlighting.cq instead.)git grep -W already gets mostly there so I care less)git grep -W output—which really ought to be an independent utility but would benefit from dook's definitions of what counts as a parentContribute at your own risk! I might ignore your PRs and issues for no good reason, close them without explanation, or rewrite them from scratch and forget to tell you.
By submitting a PR, you agree to license your contributions under the MIT License, credited in the changelog or somewhere reachable from this README.