Integrations
Ratatui
Render Lumis terminal output inside Ratatui by converting ANSI output into styled text.
Ratatui already has a good bridge for ANSI-colored text: ansi-to-tui. Lumis already emits ANSI. So the clean integration path is:
- highlight with Lumis terminal output
- convert ANSI to
ratatui::text::Text - render that text in a widget
That gives you syntax highlighting in terminal UIs without a custom Lumis formatter just for Ratatui.
Add dependencies
[dependencies]
lumis = "0.16"
ratatui = "0.30"
ansi-to-tui = "8"Highlight and render
use ansi_to_tui::IntoText;
use lumis::{highlight, languages::Language, themes, TerminalBuilder};
use ratatui::widgets::{Block, Paragraph};
fn code_paragraph(
source: &str,
language: Language,
) -> Paragraph<'static> {
let theme = themes::get("catppuccin_frappe").unwrap();
let formatter = TerminalBuilder::new()
.language(language)
.theme(Some(theme))
.build()
.unwrap();
let ansi = highlight(source, formatter);
let text = ansi.into_text().unwrap();
Paragraph::new(text)
.block(Block::bordered().title("main.rs"))
}Use a dark theme (like catppuccin_frappe) for terminal UIs since they render on a dark background.