| Crates.io | tss |
| lib.rs | tss |
| version | 0.2.2 |
| created_at | 2025-11-03 13:31:56.062747+00 |
| updated_at | 2025-11-05 15:29:54.220589+00 |
| description | Generated node type enums and metadata from tree-sitter languages |
| homepage | https://github.com/lmmx/tree-sitter-symbols |
| repository | https://github.com/lmmx/tss |
| max_upload_size | |
| id | 1914629 |
| size | 19,988 |
Generated node type enums and metadata from tree-sitter languages.
This is a convenience wrapper if you are using multiple crates, or just want to switch between languages easily.
Whereas the individual language crates provide NodeType, this crate re-exports each language you
configure in via the features with the language name appended in Pascal case
So the Rust language tree-sitter-rust crate NODE_TYPES constant shipped as NodeType in
tss-rust as tree_sitter_symbols_rust::NodeType is re-exported in tss as
tree_sitter_symbols::NodeTypeRust. Distinctly named types can reduce the ability to get confused
about which you're working with when handling tree-sitter parse trees in multiple languages.
[dependencies]
tss = { version = "0.1", features = ["lang-rust"] }
tree-sitter = "0.24"
tree-sitter-rust = "0.24"
use tree_sitter_symbols::NodeTypeRust;
use std::str::FromStr;
let node_type = NodeTypeRust::from_str("function_item")?;
assert_eq!(node_type, NodeTypeRust::FunctionItem);
assert_eq!(node_type.to_string(), "function_item");
I might change this to be modules that always re-export the name NodeType in future.
Default includes all languages:
[features]
# Convenience features
default = ["lang-all"]
lang-all = ["lang-rust"]
# Language features
lang-rust = ["dep:tss-rust"]
# ...
You can override that to select particular languages:
tss = { version = "0.1", default-features = false, features = ["lang-rust"] }
For all available metadata features see the repo Cargo.toml.
At build time, each language reads the corresponding tree-sitter-* language crate's NODE_TYPES constant and generates:
NodeType enum with all node typesFromStr for parsing node type stringsDisplay for converting back to stringsThis allows a crate to ship this information as an enum type with zero runtime dependencies. All generation happens at compile time. This is useful for type safety (rather than checking for strings, as well as hopefully to demystify how tree-sitter languages work.
MIT licensed - see LICENSE for details.