Expand description
Tree-sitter parsing and chunk extraction for semtree.
Turns source files into structured Chunks -
functions, methods, structs, classes - aligned to real syntax boundaries
instead of arbitrary line windows. Supports Rust, Python, JavaScript,
TypeScript, TSX, Go, Java, C, C++, C#, Ruby, PHP, Kotlin, Scala, Swift,
OCaml, Solidity, Lua, Zig and Emacs Lisp; non-code text falls back to
fixed-size windows.
Each language is a tree-sitter query in src/lang/queries/; adding one is a
grammar dependency plus a .scm file, no per-language Rust.
use semtree_parse::extract_file;
let chunks = extract_file(std::path::Path::new("src/lib.rs"))?;
for c in &chunks {
println!("{:?} {:?}", c.kind, c.name);
}Structs§
Enums§
Functions§
- chunk_
text - Split plain text into overlapping chunks of ~
chunk_lineslines. - extract_
file - Extract chunks from any supported file - code or plain text.
- is_
text_ file - File types we handle as plain text (no AST)
- parse_
and_ extract - parse_
and_ extract_ file