Expand description
§tree-sitter-language-pack
Pre-compiled tree-sitter grammars for 248 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());§Modules
registry- Thread-safe language registry for parser lookupintel- Source code intelligence extraction (structure, imports, exports, etc.)parse- Low-level tree-sitter parsing utilitiesnode- Tree node traversal and information extractionquery- Tree-sitter query executiontext_splitter- Syntax-aware code chunkingprocess_config- Configuration for theprocesspipelinepack_config- Configuration for the language pack (cache dir, languages to download)error- Error types
Re-exports§
pub use error::Error;pub use extensions::detect_language_from_content;pub use extensions::detect_language_from_extension;pub use extensions::detect_language_from_path;pub use extensions::extension_ambiguity;pub use extract::CaptureOutput;pub use extract::CaptureResult;pub use extract::CompiledExtraction;pub use extract::ExtractionConfig;pub use extract::ExtractionPattern;pub use extract::ExtractionResult;pub use extract::MatchResult;pub use extract::PatternResult;pub use extract::PatternValidation;pub use extract::ValidationResult;pub use intel::types::ChunkContext;pub use intel::types::CodeChunk;pub use intel::types::CommentInfo;pub use intel::types::CommentKind;pub use intel::types::Diagnostic;pub use intel::types::DiagnosticSeverity;pub use intel::types::DocSection;pub use intel::types::DocstringFormat;pub use intel::types::DocstringInfo;pub use intel::types::ExportInfo;pub use intel::types::ExportKind;pub use intel::types::FileMetrics;pub use intel::types::ImportInfo;pub use intel::types::ProcessResult;pub use intel::types::Span;pub use intel::types::StructureItem;pub use intel::types::StructureKind;pub use intel::types::SymbolInfo;pub use intel::types::SymbolKind;pub use node::NodeInfo;pub use node::extract_text;pub use node::find_nodes_by_type;pub use node::named_children_info;pub use node::node_info_from_node;pub use node::root_node_info;pub use pack_config::PackConfig;pub use parse::parse_string;pub use parse::tree_contains_node_type;pub use parse::tree_error_count;pub use parse::tree_has_error_nodes;pub use parse::tree_to_sexp;pub use process_config::ProcessConfig;pub use queries::get_highlights_query;pub use queries::get_injections_query;pub use queries::get_locals_query;pub use query::QueryMatch;pub use query::run_query;pub use registry::LanguageRegistry;pub use text_splitter::split_code;pub use download::DownloadManager;
Modules§
- download
- error
- extensions
- File extension to language name mapping.
- extract
- Pattern-based extraction from parsed syntax trees.
- intel
- Content intelligence and code chunking using tree-sitter.
- node
- pack_
config - parse
- process_
config - queries
- Bundled tree-sitter highlight, injection, and locals queries.
- query
- registry
- text_
splitter
Structs§
- Language
- An opaque object that defines how to parse a particular language. The code
for each
Languageis generated by the Tree-sitter CLI. - Parser
- A stateful object that this is used to produce a
Treebased on some source code. - Tree
- A tree that represents the syntactic structure of a source code file.
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.
- 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.
- extract_
patterns - Run extraction patterns against source code.
- get_
language - Get a tree-sitter
Languageby name using the global registry. - get_
parser - Get a tree-sitter
Parserpre-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 (248).
- process
- Process source code and extract file intelligence using the global registry.
- validate_
extraction - Validate extraction patterns without running them.