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.
- JavaScript
- Rust
- Elixir
- CLI
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)
}
use lumis::{languages::available_languages, themes};
for language in available_languages() {
println!("{} {} {:?}", language.id, language.name, language.extensions);
}
for theme in themes::available_themes() {
println!("{} {:?}", theme.name, theme.appearance);
}
for language <- Lumis.available_languages() do
IO.inspect({language.id, language.name, language.extensions})
end
for theme <- Lumis.available_themes() do
IO.inspect({theme.name, theme.appearance})
end
lumis languages list
lumis themes list
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.
- JavaScript
- Rust
- Elixir
- CLI
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'
use lumis::{languages::Language, themes};
let language: Language = "js".parse()?;
println!("{:?}", language.info().extensions);
let theme = themes::get("catppuccin_frappe")?;
println!("{} {}", theme.name, theme.appearance);
Lumis.Languages.get("js")
# %{id: "javascript", name: "JavaScript", ...}
Lumis.Languages.get("nope")
# nil
Lumis.Theme.get("catppuccin_frappe")
# %Lumis.Theme{name: "catppuccin_frappe", appearance: "dark", ...}
lumis languages show js
lumis themes show 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.
- JavaScript
- Rust
- Elixir
- CLI
import {loadedLanguages} from '@lumis-sh/lumis'
loadedLanguages() // ['json', 'rust']
Languages are compiled in behind lang-* features, so everything in
available_languages() is ready to use.
Lumis.Languages.load("elixir")
Lumis.loaded_languages()
# ["elixir"]
Loading is global to the VM, so this is the same list in every process.
There is nothing to list. Each invocation is a fresh process that loads what the document needs and exits, so nothing stays loaded between runs.
What does persist is the parser cache on disk, which lumis languages cache
fills so later runs skip the download:
lumis languages cache rust javascript