sxyazi/yazi · error
No syntax
Error message
No syntax
What it means
The preview highlighter (yazi-core/src/highlighter.rs:125) processes a chunk of file bytes with syntax highlighting; highlighting requires a HighlightLines instance produced from a matched syntax. When none was provided (`h` is None), `process_hyper` bails with "No syntax" because it cannot render highlighted lines without one.
Source
Thrown at yazi-core/src/highlighter.rs:125
*i += 1;
if *i > self.skip + self.size.height as usize {
return Ok(false);
} else if *i > self.skip {
lines.push(spans.into_static_line());
}
self.ensure_not_cancelled()?;
}
Ok(true)
}
fn process_hyper(
&self,
buf: &[u8],
i: &mut usize,
lines: &mut Vec<Line>,
h: Option<&mut HighlightLines<'_>>,
) -> Result<bool> {
let Some(h) = h else { bail!("No syntax") };
let s = String::from_utf8_lossy(buf);
let line = [Self::to_line_widget(h.highlight_line(&s, self.syntaxes)?)];
let mut it = LineIter::parsed(&line, YAZI.preview.tab_size);
if let Some(wrap) = YAZI.preview.wrap.into() {
it = it.wrapped(wrap, self.size.width);
}
while let Some((spans, _)) = it.next() {
*i += 1;
if *i > self.skip + self.size.height as usize {
return Ok(false);
} else if *i > self.skip {
lines.push(spans.into_static_line());
}
self.ensure_not_cancelled()?;
}
Ok(true)View on GitHub (pinned to 5f901b886b)
Solutions
- Ensure the file type has a matching syntax definition; install/verify syntect syntax sets cover the extension.
- In callers, skip highlighting and render plain text when no syntax is available instead of passing None into process_hyper.
- Catch this error at the preview layer and fall back to unhighlighted output.
Example fix
// before
highlighter.highlight(buf).unwrap_or_else(|_| bail!("preview failed"))
// after
match highlighter.highlight(buf) {
Ok(lines) => lines,
Err(_) => render_plain(buf), // no syntax matched; show raw text
} Defensive patterns
Strategy: fallback
Try / catch
match highlighter.highlight(buf) {
Ok(lines) => lines,
Err(_) => render_plain(buf), // fall back to unhighlighted preview
} Prevention
- Ship/load a full syntect syntax set so common extensions resolve to a syntax.
- Have callers treat absence of syntax as 'render plain', not as a hard failure.
- Log unknown file types to extend the syntax mapping instead of hitting the error.
When it happens
Trigger: Calling `highlight`/`process_hyper` for a buffer when no syntax was resolved for the file's filetype, i.e. the `Option<HighlightLines>` is None and `let Some(h) = h else` triggers.
Common situations: Previewing a file whose extension/name has no matching syntect syntax definition (unknown or missing file type), or syntect syntax set failing to load so no syntax could be matched for the detected language.
Related errors
AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02).
Data as JSON: /api/errors/572c563e59b63c49.
Report an issue: GitHub.