microsoft/edit · error
No matching highlighting definition found
Error message
No matching highlighting definition found
What it means
When a file path is given instead of a language ID, run_render picks the first entrypoint whose glob `paths` patterns match the path. If no loaded definition's path patterns match the file, it errors; the binary cannot guess a highlighting definition for the file.
Source
Thrown at crates/lsh-bin/src/main.rs:129
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 {
let color = match hk.identifier {
"other" => "",
"comment" => "\x1b[32m", // Green
"method" => "\x1b[93m", // Bright Yellow
"string" => "\x1b[91m", // Bright Red
"variable" => "\x1b[96m", // Bright Cyan
"constant.language" => "\x1b[94m", // Bright Blue
"constant.numeric" => "\x1b[92m", // Bright Green
"keyword.control" => "\x1b[95m", // Bright MagentaView on GitHub (pinned to 826b4c097b)
Solutions
- Add the file's extension/glob to the `paths` patterns of the appropriate .lsh entrypoint.
- Explicitly pass --language <id> instead of relying on path matching.
- Load the definition set that covers the file type you are rendering.
Example fix
// before (in .lsh definition) paths = ["*.rs"] // after paths = ["*.rs", "*.rs.in"]
Defensive patterns
Strategy: validation
Validate before calling
fn is_covered(path: &str, entrypoint_globs: &[&str]) -> bool {
entrypoint_globs.iter().any(|g| glob_match(g.as_bytes(), path.as_bytes()))
}
if !is_covered("foo.weird-ext", &GLOBS) { eprintln!("no definition covers this file; pass --language"); } Try / catch
// fall back to explicit language when path matching fails
let out = Command::new("lsh").arg(file).status()
.or_else(|_| Command::new("lsh").args(["--language", "plaintext"]).arg(file).status())?; Prevention
- Add globs for every extension your project renders to the relevant .lsh `paths`.
- Default to passing --language for files with uncommon extensions.
- Add a test that renders each tracked file type so gaps surface early.
When it happens
Trigger: Rendering a file whose name/extension matches none of the loaded entrypoints' path glob patterns, e.g. an extension the .lsh definitions do not declare.
Common situations: Rendering files with unusual extensions (.txt, custom extensions); definitions loaded but their `paths` globs were authored for different extensions; new file types added before updating the .lsh definition.
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 highlighting definition found for language {language:?}
- invalid language: "{}"
- unrecognized arguments: {:?}
AI-assisted analysis of microsoft/edit@826b4c097b (2026-09-06).
Data as JSON: /api/errors/7e402755f207c1d8.
Report an issue: GitHub.