Skip to main content

compute_syntax_folds

Function compute_syntax_folds 

Source
pub fn compute_syntax_folds(syntax: &SyntaxSnapshot) -> Option<Vec<Fold>>
Expand description

Tree-sitter-driven fold provider. Runs the language’s compiled folds.scm query against lattice_syntax::Syntax’s parse tree and emits one Fold per @fold capture spanning more than a single line.

Returns None when:

  • The buffer’s language doesn’t ship a folds.scm (e.g. plain text or the inline-markdown parser). The caller cascades to the markdown / indent providers.
  • The syntax tree isn’t available yet (first parse hasn’t run).

Returns Some(Vec::new()) when the language has a query but the document genuinely has no foldable structures (an empty file, a single-line file). The empty Vec lets the caller know “syntax authoritative, just nothing to fold” so it doesn’t fall through to indent.