Expand description
Tree-sitter parser initialization and caching for all supported languages.
Provides cached, zero-cost access to tree-sitter language parsers. Each parser is initialized once and cached using
std::sync::OnceLock for thread-safe, lazy initialization.
§Feature Flags
§all-parsers
When enabled (default), imports all tree-sitter parser crates and provides full parser functionality. Disable for WebAssembly builds where tree-sitter cannot be compiled.
§Individual Language Features
Each language has its own feature flag, so you can enable whichever ones you need.
§napi-environment
Disables tree-sitter parsing functionality because tree-sitter cannot build in a NAPI environment. NAPI (Node.js API) is used for building WASM modules for Node.js. (note: WASM builds for browser or other environments can support tree-sitter)
§Napi-compatible Languages
You can use these languages in a NAPI environment:
- You can use the
napi-compatibleflag as a shortcut to enable all napi-compatible languages. csshtmljavascripttypescripttsx
§Parser Functions
Each language has a corresponding language_*() function that returns a
cached TSLanguage instance:
use thread_language::parsers::{language_rust, language_javascript};
let rust_lang = language_rust();
let js_lang = language_javascript();§Caching Strategy
Parsers use std::sync::LazyLock for optimal performance:
- First call initializes the parser
- Subsequent calls return the cached instance
- Thread-safe with no synchronization overhead after initialization
Functions§
- language_
bash - language_
c - language_
c_ sharp - language_
cpp - language_
css - language_
elixir - language_
go - language_
haskell - language_
hcl - language_
html - language_
java - language_
javascript - language_
json - language_
kotlin - language_
lua - language_
nix - language_
php - language_
python - language_
ruby - language_
rust - language_
scala - language_
solidity - language_
swift - language_
tsx - language_
typescript - language_
yaml