Tree‑sitter
Semantic syntax highlighting with parsers.
Tree‑sitter
Tree‑sitter enables semantic syntax highlighting in Cascade. Use the getTreeSitterClient function to obtain a client instance and call initialize() to load parsers. You can then pass the client to Code or Markdown renderables that support syntax‑aware styling.
import { getTreeSitterClient } from "@cascadetui/core"
const client = getTreeSitterClient()
await client.initialize()To add parsers globally, import the language assets and register them. You can also provide your own worker script by setting CASCADE_TREE_SITTER_WORKER_PATH in your environment.
A typical workflow is: initialize once at startup, then reuse the same client for any Code/Markdown instances you create. This keeps highlighting consistent and avoids repeated parser loading.
If highlighting doesn’t appear, validate that the worker path is correct and that the environment variable is visible to your Bun process. On Windows, prefer setting env vars inline per command (as shown above) or through your shell profile to avoid “invisible env” bugs.