microsoft/edit · error
No highlighting definition found for language {language:?}
Error message
No highlighting definition found for language {language:?} What it means
After assembling all highlighting definitions, run_render looks up an entrypoint whose name (underscores normalized to dashes) equals the given language ID. If no loaded .lsh definition declares that language, it errors with the unmatched language quoted.
Source
Thrown at crates/lsh-bin/src/main.rs:118
SubCommands::Render(cmd) => {
read_lsh_inputs(&cmd.lsh)?;
run_render(generator, cmd.input.as_deref(), cmd.language.as_deref())?;
}
}
Ok(())
}
fn run_render(
generator: lsh::compiler::Generator,
path: Option<&Path>,
language: Option<&str>,
) -> anyhow::Result<()> {
let assembly = generator.assemble()?;
let entrypoint = if let Some(language) = language {
assembly.entrypoints.iter().find(|ep| ep.name.replace('_', "-") == language).ok_or_else(
|| anyhow::anyhow!("No highlighting definition found for language {language:?}"),
)?
} else if let Some(path) = path {
assembly
.entrypoints
.iter()
.find(|ep| {
ep.paths.iter().any(|pattern| {
glob_match(pattern.as_bytes(), path.as_os_str().as_encoded_bytes())
})
})
.ok_or_else(|| anyhow::anyhow!("No matching highlighting definition found"))?
} else {
bail!("A language ID is required when reading from stdin");
};
let mut color_map = Vec::new();
let mut unknown_kinds = Vec::new();
for hk in &assembly.highlight_kinds {View on GitHub (pinned to 826b4c097b)
Solutions
- Check the exact entrypoint name in your .lsh files (underscores in names become dashes on the CLI) and retry with the correct ID.
- Ensure the .lsh file defining that language is included in the input paths passed to lsh.
- List available entrypoints (e.g. by inspecting the loaded definitions) to see valid language IDs.
Example fix
// before lsh --language rs main.rs // after lsh --language rust main.rs
Defensive patterns
Strategy: fallback
Validate before calling
const KNOWN_LANGS: &[&str] = &["rust", "c", "javascript"]; // from your .lsh entrypoints
let lang = "rs";
if !KNOWN_LANGS.contains(&lang) { eprintln!("unknown language {lang}"); } Try / catch
// run and surface the language error with available options
match status {
Err(_) if stderr_contains("No highlighting definition found for language") =>
eprintln!("try: lsh --language <one of: rust, c, ...>"),
s => s?,
} Prevention
- Keep a canonical language-ID table shared between your tooling and .lsh entrypoint names.
- Remember underscores in entrypoint names become dashes on the CLI.
- Regenerate/refresh the list of valid IDs whenever .lsh definitions change.
When it happens
Trigger: Calling lsh --language <id> (or passing language=Some(id) into run_render) where no entrypoint in the assembled generator has a matching name — typo, wrong case, or the definition file was never loaded.
Common situations: Typos like `--language rust-lang` when the entrypoint is `rust`; expecting built-in languages without supplying the .lsh definitions; definitions loaded from a directory that excludes the needed file.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- At least one .lsh file or directory is required
- A language ID is required when reading from stdin
- No matching highlighting definition found
- invalid language: "{}"
- unrecognized arguments: {:?}
AI-assisted analysis of microsoft/edit@826b4c097b (2026-09-06).
Data as JSON: /api/errors/4da3d13532da2075.
Report an issue: GitHub.