Lumis
Features
- 70+ languages with Tree-sitter parsing
- 120+ Neovim themes
- HTML output with inline styles or CSS classes
- Multi-theme support for light/dark mode
- Terminal output with ANSI colors
- Language auto-detection via file extensions and shebangs
- Line highlighting with custom styling
- Custom HTML wrappers for code blocks
- Streaming-friendly - handles incomplete code gracefully
- Custom formatters via the
Formattertrait
Installation
Add to your Cargo.toml:
[]
= "0.1"
Or install the CLI:
Quick Start
use ;
let code = r#"fn main() { println!("Hello, world!"); }"#;
let theme = get.unwrap;
let formatter = new
.lang
.theme
.build
.unwrap;
let html = highlight;
For streaming to files or other writers, use write_highlight():
use ;
use File;
let code = "fn main() { }";
let formatter = new
.lang
.build
.unwrap;
let mut file = create.unwrap;
write_highlight.unwrap;
Formatters
Lumis provides four built-in formatters:
| Formatter | Output | Use When |
|---|---|---|
HtmlInlineBuilder |
HTML with inline styles | Standalone HTML, emails, no external CSS |
HtmlMultiThemesBuilder |
HTML with CSS variables | Light/dark mode, theme switching |
HtmlLinkedBuilder |
HTML with CSS classes | Multiple code blocks, custom styling |
TerminalBuilder |
ANSI escape codes | CLI tools, terminal output |
HTML Inline
Generates HTML with inline styles for each token:
use ;
let code = "puts 'Hello from Ruby!'";
let theme = get.unwrap;
let formatter = new
.lang
.theme
.pre_class // Custom CSS class for <pre>
.italic // Enable italic styles
.include_highlights // Add data-highlight attributes
.build
.unwrap;
let html = highlight;
HTML Linked
Generates HTML with CSS classes for styling (requires external CSS):
use ;
let code = "<div>Hello World</div>";
let formatter = new
.lang
.pre_class
.build
.unwrap;
let html = highlight;
CSS theme files are available in the css/ directory of the crate.
HTML Multi-Themes
Generates HTML with CSS custom properties for multiple themes, enabling light/dark mode support:
use ;
use HashMap;
let code = "const x = 42;";
let mut themes_map = new;
themes_map.insert;
themes_map.insert;
let formatter = new
.lang
.themes
.default_theme // or "light-dark()" for CSS function
.build
.unwrap;
let html = highlight;
Use CSS media queries for automatic theme switching:
{
}
}
Terminal
Generates ANSI escape codes for terminal output:
use ;
let code = "puts 'Hello from Ruby!'";
let theme = get.unwrap;
let formatter = new
.lang
.theme
.build
.unwrap;
let ansi = highlight;
println!;
Line Highlighting
Highlight specific lines with custom styling:
use ;
use ;
let code = "line 1\nline 2\nline 3\nline 4";
let theme = get.unwrap;
let highlight_lines = HighlightLines ;
let formatter = new
.lang
.theme
.highlight_lines
.build
.unwrap;
let html = highlight;
Custom HTML Wrappers
Wrap the formatted output with custom HTML elements:
use ;
let code = "fn main() { }";
let formatter = new
.lang
.header
.build
.unwrap;
let html = highlight;
// Output: <div class="code-wrapper"><pre class="lumis">...</pre></div>
Themes
120+ themes from popular Neovim colorschemes:
use themes;
// Get a theme by name
let theme = get.unwrap;
// Parse from string
let theme: Theme = "catppuccin_mocha".parse.unwrap;
// List all available themes
for theme in available_themes
// Filter by appearance
use Appearance;
let dark_themes: = available_themes
.filter
.collect;
Custom Themes
Load themes from JSON files or strings:
use themes;
// From file
let theme = from_file.unwrap;
// From JSON string
let json = r#"{
"name": "my_theme",
"appearance": "dark",
"revision": "v1.0.0",
"highlights": {
"keyword": { "fg": "#ff79c6", "bold": true },
"string": { "fg": "#f1fa8c" },
"comment": { "fg": "#6272a4", "italic": true }
}
}"#;
let theme = from_json.unwrap;
Custom Formatters
Implement the Formatter trait to create custom output formats:
use ;
use ;
CLI Usage
# Highlight a file
# Highlight with a specific language
# Output to terminal (default)
# List available themes
# List available languages
Language Feature Flags
By default, Lumis includes all languages. To reduce compile time and binary size, enable only the languages you need:
[]
= { = "0.1", = false, = ["lang-rust", "lang-javascript"] }
Available features:
all-languages- Enable all languages (default)lang-rust,lang-javascript,lang-typescript,lang-python, etc.
See the full list of language features in Cargo.toml.
Supported Languages
| Language | File Extensions |
|---|---|
| Angular | *.angular, component.html |
| Assembly | *.s, *.asm |
| Astro | *.astro |
| Bash | *.bash, *.sh, *.zsh, and more |
| C | *.c |
| C++ | *.cpp, *.cc, *.h, *.hpp |
| C# | *.cs |
| CSS | *.css |
| Clojure | *.clj, *.cljs, *.cljc |
| Dart | *.dart |
| Dockerfile | Dockerfile, *.dockerfile |
| Elixir | *.ex, *.exs |
| Erlang | *.erl, *.hrl |
| F# | *.fs, *.fsx |
| Gleam | *.gleam |
| Go | *.go |
| GraphQL | *.graphql |
| HTML | *.html, *.htm |
| Haskell | *.hs |
| HCL | *.hcl, *.tf |
| Java | *.java |
| JavaScript | *.js, *.mjs, *.cjs |
| JSON | *.json |
| Kotlin | *.kt |
| LaTeX | *.tex |
| Lua | *.lua |
| Markdown | *.md |
| Nix | *.nix |
| OCaml | *.ml, *.mli |
| PHP | *.php |
| Python | *.py |
| Ruby | *.rb |
| Rust | *.rs |
| SQL | *.sql |
| Scala | *.scala |
| Swift | *.swift |
| TOML | *.toml |
| TypeScript | *.ts |
| TSX | *.tsx |
| Vue | *.vue |
| YAML | *.yaml, *.yml |
| Zig | *.zig |
| ...and more | See docs for full list |
Available Themes
Themes are sourced from popular Neovim colorschemes:
- Catppuccin: catppuccin_frappe, catppuccin_latte, catppuccin_macchiato, catppuccin_mocha
- Dracula: dracula, dracula_soft
- GitHub: github_dark, github_light, github_dark_dimmed, and more
- Gruvbox: gruvbox_dark, gruvbox_light, and variants
- Tokyo Night: tokyonight_day, tokyonight_moon, tokyonight_night, tokyonight_storm
- One Dark: onedark, onedark_cool, onedark_darker, onelight
- Rose Pine: rosepine_dark, rosepine_dawn, rosepine_moon
- Nord: nord, nordic, nordfox
- Material: material_darker, material_oceanic, material_palenight
- Kanagawa: kanagawa_wave, kanagawa_dragon, kanagawa_lotus
- ...and 100+ more
Use themes::available_themes() or the CLI lumis themes for the complete list.
Acknowledgements
- Inkjet for the Rust implementation in early versions
- The Neovim community for the beautiful colorschemes
License
MIT