Skip to main content

Crate tree_sitter_language_pack

Crate tree_sitter_language_pack 

Source
Expand description

§tree-sitter-language-pack

Pre-compiled tree-sitter grammars for 305 programming languages with a unified API for parsing, analysis, and intelligent code chunking.

§Quick Start

use tree_sitter_language_pack::{ProcessConfig, available_languages, has_language, process};

// Check available languages
let langs = available_languages();
assert!(has_language("python"));

// Process source code
let config = ProcessConfig::new("python").all();
let result = process("def hello(): pass", &config).unwrap();
println!("Language: {}", result.language);
println!("Functions: {}", result.structure.len());

§Parser API

use tree_sitter_language_pack::get_parser;

let mut parser = get_parser("python")?;
let tree = parser.parse("def foo(): pass").expect("parse failed");
assert_eq!(tree.root_node().kind(), "module");

§Modules

  • registry - Thread-safe language registry for parser lookup
  • [intel] - Source code intelligence extraction (structure, imports, exports, etc.)
  • [parse] - Low-level tree-sitter parsing utilities
  • [text_splitter] - Syntax-aware code chunking
  • process_config - Configuration for the process pipeline
  • pack_config - Configuration for the language pack (cache dir, languages to download)
  • error - Error types

Re-exports§

pub use error::Error;
pub use pack_config::PackConfig;
pub use parsing::ByteRange;
pub use parsing::Node;
pub use parsing::Parser;
pub use parsing::Point;
pub use parsing::Tree;
pub use parsing::TreeCursor;
pub use process_config::ProcessConfig;
pub use registry::LanguageRegistry;
pub use download::DownloadManager;

Modules§

download
error
pack_config
parsing
Universal parser/tree/node surface over tree_sitter.
process_config
registry

Structs§

ChunkContext
Metadata for a single chunk of source code.
CodeChunk
A chunk of source code with rich metadata.
CommentInfo
A comment extracted from source code.
Diagnostic
A diagnostic (syntax error, missing node, etc.) from parsing.
DocSection
A section within a docstring (e.g., Args, Returns, Raises).
DocstringInfo
A docstring extracted from source code.
ExportInfo
An export statement extracted from source code.
FileMetrics
Aggregate metrics for a source file.
ImportInfo
An import statement extracted from source code.
Language
An opaque object that defines how to parse a particular language. The code for each Language is generated by the Tree-sitter CLI.
ProcessResult
Complete analysis result from processing a source file.
Span
Byte and line/column range in source code.
StructureItem
A structural item (function, class, struct, etc.) in source code.
SymbolInfo
A symbol (variable, function, type, etc.) extracted from source code.

Enums§

CommentKind
The kind of a comment found in source code.
DiagnosticSeverity
Severity level of a diagnostic produced during parsing.
DocstringFormat
The format of a docstring extracted from source code.
ExportKind
The kind of an export statement found in source code.
StructureKind
The kind of structural item found in source code.
SymbolKind
The kind of a symbol definition found in source code.

Functions§

available_languages
List all available language names (sorted, deduplicated, includes aliases).
cache_dir
Return the effective cache directory path.
clean_cache
Delete all cached parser shared libraries.
configure
Apply download configuration without downloading anything.
detect_language
Detect language name from a file path or extension.
detect_language_from_content
Detect language name from file content using the shebang line (#!).
detect_language_from_extension
Detect language name from a file extension (without leading dot).
detect_language_from_path
Detect language name from a file path.
download
Download specific languages to the local cache.
download_all
Download all available languages from the remote manifest.
downloaded_languages
Return languages that are already downloaded and cached locally.
get_highlights_query
Get the highlights query for a language, if bundled.
get_injections_query
Get the injections query for a language, if bundled.
get_language
Get a tree-sitter Language by name using the global registry.
get_locals_query
Get the locals query for a language, if bundled.
get_parser
Get a Parser pre-configured for the given language.
has_language
Check if a language is available by name or alias.
init
Initialize the language pack with the given configuration.
language_count
Return the number of available languages.
manifest_languages
Return all language names available in the remote manifest (305).
process
Process source code and extract file intelligence using the global registry.