Quick Start
Highlight code with the built-in JavaScript/TypeScript support:Tree-Sitter Client
Initialization
The Tree-sitter client manages parsers and performs highlighting:One-Time Highlighting
Highlight code without creating a CodeRenderable:Adding Custom Parsers
Extend language support by adding custom Tree-sitter parsers.Global Default Parsers
Add parsers that all clients will use:Per-Client Parsers
Add parsers to specific client instances:Finding Parsers and Queries
Official Tree-Sitter Parsers
Most popular languages have official parsers on GitHub:Pattern for Finding Parsers
Using Local Files
For better performance and offline support, bundle parsers with your app:Automated Parser Management
Automate parser downloads and configuration:Syntax Styles
Customize how syntax elements are colored:CodeRenderable
TheCodeRenderable component provides a full-featured code viewer:
Filetype Detection
Automatically detect filetype from file paths:js,jsx→ javascriptts,tsx→ typescriptpy→ pythonrs→ rustgo→ gorb→ rubyc,h→ ccpp,hpp,cc→ cpphtml→ htmlcss→ css- And many more
Complete Example: Code Viewer
Caching
Parsers and queries are automatically cached to avoid re-downloading:Performance Tips
Initialize Once
Initialize Once
Initialize the Tree-sitter client once at app startup:
Use Local Files in Production
Use Local Files in Production
Bundle parsers to avoid network requests:
Limit Language Support
Limit Language Support
Only include parsers you need:
Troubleshooting
Parser Not Found
Parser Not Found
Make sure the parser is added before using:
No Syntax Highlighting
No Syntax Highlighting
Check that:
- Client is initialized:
await client.initialize() - Filetype is correct:
filetype: "javascript"not"js" - Parser is added for that filetype
Download Failures
Download Failures
If parsers fail to download:
- Check internet connection
- Verify URLs are correct
- Use local files instead of URLs
Next Steps
Building Your First App
Build a complete TUI application
Styling and Colors
Master colors and text styling