Skip to main content

List languages and themes

A language is the same record everywhere, sorted by id: id, name, aliases, extensions, globs, emacsModes and shebangs.

Themes differ by what each runtime can return cheaply. Rust hands back the whole Theme, colours included, because they are already in the binary. Elixir and JavaScript return name and appearance, because sending every theme's highlights across the NIF or the wire would cost far more than the call is worth. Reach for one in full with themes::get or Lumis.Theme.get/2.

import {availableLanguages, availableThemes} from '@lumis-sh/lumis'
for (const language of availableLanguages()) {
console.log(language.id, language.name, language.extensions)
}
for (const theme of availableThemes()) {
console.log(theme.name, theme.appearance)
}

Look one up by name

Aliases resolve the way highlighting resolves them, so js finds JavaScript.

How an unknown name is reported follows each host's convention: JavaScript returns undefined and Elixir returns nil, both without raising, while Rust returns a Result and the CLI exits non-zero.

import {getLanguage} from '@lumis-sh/lumis'
getLanguage('js') // { id: 'javascript', name: 'JavaScript', ... }
getLanguage('nope') // undefined

Themes are separate modules, so import the one you want:

import frappe from '@lumis-sh/themes/catppuccin_frappe'

What is loaded right now

The catalog lists what Lumis knows about. This lists what can be highlighted without a download, which is a smaller set — highlighting loads what a document turns out to need.

Themes have no equivalent: every theme is compiled in, so there is nothing to load and nothing that could be missing.

import {loadedLanguages} from '@lumis-sh/lumis'
loadedLanguages() // ['json', 'rust']