tree-sitter-language-pack 1.3.3

Core library for tree-sitter language pack - provides compiled parsers for 248 languages
Documentation

tree-sitter-language-pack — Rust

Rust core library providing access to 248 tree-sitter parsers with on-demand download and caching support.

Installation

cargo add ts-pack-core

Quick Start

use ts_pack_core::{get_language, get_parser, available_languages};

// Initialize and download specific languages (optional)
ts_pack_core::init(&["python", "javascript", "rust"]).unwrap();

// Get a language (auto-downloads if needed)
let lang = get_language("python").unwrap();

// Get a pre-configured parser
let mut parser = get_parser("python").unwrap();
let tree = parser.parse("def hello(): pass", None).unwrap();
println!("{}", tree.root_node().to_sexp());

// List all available languages
for lang in available_languages() {
    println!("{}", lang);
}

// Process source code (auto-downloads language if needed)
let config = ts_pack_core::ProcessConfig::new("python").all();
let result = ts_pack_core::process("def hello(): pass", &config).unwrap();
println!("Functions: {}", result.structure.len());
println!("Imports: {}", result.imports.len());

// Pre-download languages for offline use
ts_pack_core::download(&["python", "javascript"]).unwrap();

// With chunking
let config = ts_pack_core::ProcessConfig::new("python").all().with_chunking(1000);
let result = ts_pack_core::process(source, &config).unwrap();
println!("Chunks: {}", result.chunks.len());

Features

Feature Description
248+ Languages Pre-compiled parsers for 248+ programming languages
On-Demand Downloads Parsers are downloaded on-demand and cached locally for fast reuse
Selective Installation Download only the languages you need; unused parsers never downloaded
Polyglot Bindings Native bindings for Rust, Python, Node.js, Go, Java, Elixir, and C/C++
Automatic Caching Downloaded parsers cached in platform-specific directories for offline use
Feature Groups Curated language sets: web, systems, scripting, data, jvm, functional

Feature Groups

Enable curated language sets instead of individual languages:

[dependencies]
ts-pack-core = { version = "1.3.2", default-features = false, features = ["web"] }

Available groups: all (default), web, systems, scripting, data, jvm, functional.

API Reference

Language Discovery

  • available_languages() -- list all supported language names
  • has_language(name) -- check if a language is available
  • language_count() -- total number of supported languages

Language Detection

  • detect_language(path) -- detect language from file path
  • detect_language_from_content(content) -- detect language from shebang line
  • extension_ambiguity(ext) -- check if an extension is ambiguous (returns assigned language + alternatives)

Parsing

  • get_parser(name) / parse_string(source, language) -- parse source code into a syntax tree

Download API

  • init(languages) -- pre-download specific languages for offline use
  • download(languages) -- download parsers on demand

Intelligence

  • process(source, config) -- extract structured analysis (functions, classes, imports, comments, chunks) from source code

Syntax Highlighting Queries

  • get_highlights_query(language) -- get bundled highlights.scm query for a language
  • get_injections_query(language) -- get bundled injections.scm query
  • get_locals_query(language) -- get bundled locals.scm query

For full documentation, see kreuzberg.dev.

License

MIT -- see LICENSE for details.


Part of tree-sitter-language-pack -- A comprehensive collection of tree-sitter language parsers with polyglot bindings.