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 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 lookup
  • intel - Source code intelligence extraction (structure, imports, exports, etc.)
  • parse - Low-level tree-sitter parsing utilities
  • node - Tree node traversal and information extraction
  • query - Tree-sitter query execution
  • 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 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 Language is generated by the Tree-sitter CLI.
Parser
A stateful object that this is used to produce a Tree based 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 Language by name using the global registry.
get_parser
Get a tree-sitter 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 (248).
process
Process source code and extract file intelligence using the global registry.
validate_extraction
Validate extraction patterns without running them.