An open API service indexing awesome lists of open source software.

https://github.com/leandrocp/lumis

Syntax Highlighter powered by Tree-sitter and Neovim themes.
https://github.com/leandrocp/lumis

cli code-highlighter elixir java neovim rust syntax-highlighter syntax-highlighting tree-sitter tree-sitter-highlight

Last synced: 12 days ago
JSON representation

Syntax Highlighter powered by Tree-sitter and Neovim themes.

Awesome Lists containing this project

README

          

Lumis


Lumis Syntax Highlighter


lumis.sh
-
docs


Crates.io
npm
Hex.pm
Maven Central
License

---

## Features

- **110+ Tree-sitter languages** - Fast, accurate, and updated syntax parsing
- **250+ built-in Neovim themes** - Updated and curated themes from the Neovim community
- **6 runtimes** - CLI, Rust, Elixir, JavaScript, Browsers / CDN, Java
- **Multiple outputs** - HTML (inline/linked), Terminal (ANSI), Multi-theme (light/dark), BBCode, and custom formatters
- **Language auto-detection** - File extension, shebang, and emacs-mode support
- **Streaming-friendly** - Handles incomplete code

Ruby with Catppuccin Frappe theme
SQL with GitHub Light theme

## Quick Start

### [CLI](https://crates.io/crates/lumis-cli)

```bash
cargo install lumis-cli

lumis highlight app.js --theme dracula
```

### [Rust](https://crates.io/crates/lumis)

```rust
use lumis::{highlight, HtmlInlineBuilder, languages::Language, themes};

let theme = themes::get("dracula").unwrap();

let formatter = HtmlInlineBuilder::new()
.language(Language::Javascript)
.theme(Some(theme))
.build()
.unwrap();

let html = highlight("const x = 1", formatter);
```

### [JavaScript](https://www.npmjs.com/package/@lumis-sh/lumis)

Works in JavaScript runtimes including Node.js, Bun, and Deno.

```javascript
import { highlight } from '@lumis-sh/lumis'
import { htmlInline } from '@lumis-sh/lumis/formatters'
import javascript from '@lumis-sh/lumis/langs/javascript'
import dracula from '@lumis-sh/themes/dracula'

const html = await highlight('const x = 1', htmlInline({ language: javascript, theme: dracula }))
```

### [Browsers / CDN](https://www.npmjs.com/package/@lumis-sh/lumis)

Works in Browsers through bundlers or CDN imports.

```javascript
import { highlight } from 'https://esm.sh/@lumis-sh/lumis'
import { htmlInline } from 'https://esm.sh/@lumis-sh/lumis/formatters'
import javascript from 'https://esm.sh/@lumis-sh/lumis/langs/javascript'
import dracula from 'https://esm.sh/@lumis-sh/themes/dracula'

const html = await highlight('const x = 1', htmlInline({ language: javascript, theme: dracula }))
```

### [Elixir](https://hex.pm/packages/lumis)

```elixir
Lumis.highlight!("const x = 1", formatter: {:html_inline, language: "javascript", theme: "dracula"})
```

### [Java](https://github.com/roastedroot/lumis4j)

By [@andreaTP](https://github.com/andreaTP). More details at https://chicory.dev/blog/syntax-highlight

```java
import io.roastedroot.lumis4j.core.Lumis;
import io.roastedroot.lumis4j.core.Lang;
import io.roastedroot.lumis4j.core.Theme;

var lumis = Lumis.builder().build();

var highlighter = lumis.highlighter()
.withLang(Lang.JAVASCRIPT)
.withTheme(Theme.DRACULA)
.build();

var result = highlighter.highlight("const x = 1");
System.out.println(result.string());
```

## Documentation

| Runtime | Install | Package | Docs |
|----------|---------| ------- | -----|
| **CLI** | `cargo install lumis-cli` | [crates.io/lumis-cli](https://crates.io/crates/lumis-cli) | [README.md](crates/lumis-cli/README.md) |
| **Rust** | `cargo add lumis` | [crates.io/lumis](https://crates.io/crates/lumis) | [README.md](crates/lumis/README.md) • [docs.rs](https://docs.rs/lumis) |
| **Elixir** | `{:lumis, "~> 0.3"}` | [hex.pm/lumis](https://hex.pm/packages/lumis) | [README.md](packages/elixir/lumis/README.md) • [hexdocs](https://hexdocs.pm/lumis) |
| **JavaScript** | `npm install @lumis-sh/lumis` | [npmjs.com/@lumis-sh/lumis](https://www.npmjs.com/package/@lumis-sh/lumis) | [README.md](packages/javascript/lumis/README.md) |
| **Browsers / CDN** | `npm install @lumis-sh/lumis` | [npmjs.com/@lumis-sh/lumis](https://www.npmjs.com/package/@lumis-sh/lumis) | [README.md](packages/javascript/lumis/README.md) |
| **Java** | `io.roastedroot:lumis4j:0.0.7` | [io.roastedroot/lumis4j](https://central.sonatype.com/artifact/io.roastedroot/lumis4j) | [README.md](https://github.com/roastedroot/lumis4j/blob/main/README.md) |

## Architecture

Every Lumis package is built around the same three pieces:

- themes extracted from Neovim
- languages backed by Tree-sitter grammars
- formatters that turn highlighted tokens into output

Given some source code, Lumis parses it with the selected Tree-sitter language, resolves styles from the chosen theme, and then formats the highlighted result into HTML, ANSI, or any custom output.

### WASM Versions

The npm [WASM package](https://www.npmjs.com/search?q=keywords:lumis-sh) versions follow the pattern `.` where:

- `tree-sitter-version` is the major-minor version of the compatible Tree-sitter release
- `seq` is a patch number for Lumis own updates

For example, `@lumis-sh/wasm-rust@0.26.0` is the first published version compatible with Tree-sitter 0.26,
while `@lumis-sh/wasm-javascript@0.26.1` is a patch update compatible with Tree-sitter 0.26 (usually containing upstream parser updates).

## Contributing

Contributions are welcome. Feel free to open issues or PRs for bugs, features, new themes, or languages.

See [CONTRIBUTING.md](CONTRIBUTING.md)

## Acknowledgements
* [Makeup](https://hex.pm/packages/makeup) for setting up the baseline for the Elixir package
* [Inkjet](https://crates.io/crates/inkjet) for the Rust implementation in the initial versions
* [Shiki](https://shiki.style) and [syntect](https://crates.io/crates/syntect) for the hard work defining how syntax highlighters should work

## License

MIT