Skip to content

M23: Syntax highlighting for TUI code blocks #344

@bug-ops

Description

@bug-ops

Tree-sitter-based syntax highlighting for fenced code blocks in the TUI chat widget.

Current state: Code blocks render with a single flat color (theme.code_block).
Goal: Language-aware syntax coloring using tree-sitter grammars already in the workspace.

Architecture

  • SyntaxHighlighter in crates/zeph-tui/src/highlight.rs wraps tree-sitter-highlight
  • SyntaxTheme maps tree-sitter capture names (keyword, string, comment, etc.) to ratatui styles
  • MdRenderer calls highlighter when rendering code block text with a known language tag
  • LazyLock<SyntaxHighlighter> for zero-cost initialization
  • Feature-gated grammars: lang-rust, lang-python, lang-js, lang-config

Languages (MVP)

Rust, Python, JavaScript, TypeScript, JSON, TOML, Bash

Sub-issues

Plan

.local/plan/m23-syntax-highlighting.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions