LumisDocs
Recipes

List languages and themes

Inspect available languages and themes across Lumis runtimes.

Language metadata includes id, name, parser, aliases, extensions, globs, Emacs modes and shebangs. Lists are sorted by id. JavaScript also includes the npm parser packageName; Elixir includes the Hex package_name.

themes.available() and Lumis.Theme.available/0 return theme names and appearances. Rust's themes::available() returns complete themes. Use themes.get(name), themes::get(name), or Lumis.Theme.get/1 to look up one theme.

import * as languages from '@lumis-sh/lumis/languages';
import * as themes from '@lumis-sh/lumis/themes';

for (const language of languages.available()) {
  const {id, name, extensions} = language
  console.log(id, name, extensions)
}

for (const theme of themes.available()) {
  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 / TypeScript returns undefined and Elixir returns nil, both without raising, while Rust returns None for an unknown language and an error for an unknown theme. The CLI exits non-zero.

import * as languages from '@lumis-sh/lumis/languages';
import * as themes from '@lumis-sh/lumis/themes';

// { id: 'javascript', name: 'JavaScript', ... }
languages.get('js')
languages.get('nope')  // undefined

themes.get('catppuccin_frappe')

If you know the theme name ahead of time, an individual import keeps the rest of the catalog out of your bundle:

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

Find the parser package

A language id is not always its parser name. EJS and ERB both use embedded-template; MDX uses markdown. Read parser rather than building a package name from the language id. This lookup does not load the parser.

import * as languages from '@lumis-sh/lumis/languages';

languages.get('ejs')?.parser      // 'embedded-template'
languages.get('ejs')?.packageName // '@lumis-sh/wasm-embedded-template'
languages.get('mdx')?.packageName // '@lumis-sh/wasm-markdown'
languages.get('text')?.parser    // undefined

Plaintext has neither parser nor packageName.

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 * as languages from '@lumis-sh/lumis/languages';

languages.loaded() // ['json', 'rust']

On this page