tuika-codeformatters
Tree-sitter syntax highlighting for tuika's
CodeBlock and Markdown components.
tuika owns the presentation of code — framing, background, language label,
wrapping — but deliberately depends on no grammar, so its dependency set stays
small. This companion crate fills the gap: a ready-made tuika::Highlighter
backed by tree-sitter grammars, mapping token classes onto the host Theme's
code palette so highlighted code follows the theme.
use ;
use TreeSitterHighlighter;
let theme = default;
let hl = new;
let block = new.highlighter;
// `block` is a `View`; render it with `tuika::paint` or embed it in a `Flex`.
# let _ = ;
Example
A runnable, interactive gallery of highlighted snippets across languages
(←/→ or Tab to switch, q to quit):
Supported languages
Rust, Python, TypeScript/JavaScript, TSX/JSX, Go, Java, Ruby, CSS, HTML, C#,
PHP, Zig, Scala, and SQL (with common aliases: rs, py, ts, js, rb,
c#, …). Unknown languages — or source that fails to parse — return None, and
the caller renders the block as plain, theme-colored code.
Compatibility
ratatui and tuika are part of this crate's public interface, so pin the same
minor versions in your own crate and Cargo will deduplicate them.
License
MIT