A tree-sitter grammar for the TYPO3 Fluid
templating language. Extends tree-sitter-html with Fluid {expressions}, inline
ViewHelpers, pipelines (->), casts (as), arrays, {namespace ...} and
dynamic tag names (<{var}>). ViewHelper tags (<f:if>, <f:format.raw>) are
regular elements whose tag name carries a :.
Used by the TYPO3 Fluid Zed extension.
Scope: text.html.fluid. File types: *.fluid.html, *.fluid.
tree-sitter generate # regenerate src/parser.c, grammar.json, node-types.json
tree-sitter test # run test/corpus
tree-sitter parse FILE # parse a fileRequires the tree-sitter CLI 0.26 (emits parser ABI 15).
The generated
src/parser.c,src/grammar.json,src/node-types.jsonandsrc/tree_sitter/*are committed on purpose — the Zed extension builds the grammar from a pinned commit, so they must not be git-ignored.src/scanner.cis a hand-maintained fork of tree-sitter-html's external scanner (tag names extended to allow./_; external symbols renamedhtml→fluid); it is not produced bytree-sitter generate. After editinggrammar.js, re-runtree-sitter generateand commit the regenerated files.
test/corpus/*.txt holds tree-sitter test fixtures. Run tree-sitter test;
CI (.github/workflows/ci.yml) also checks that the committed generated sources
match a fresh tree-sitter generate.
- The interior of quoted string literals is opaque — interpolated
{expressions}inside a string are not tokenized (thestringrule is a single lexer token; tokenizing it risks parser conflicts). - CDATA content is opaque (a single
cdatatoken). <f:comment>content is parsed like a normal element rather than treated as raw/opaque; its plain text is dimmed via the highlight query, but a malformed expression inside it can still produce anERRORnode. Fully opaque handling needs scanner-level raw-text support (like<script>/<style>).- Dynamic tag pairs
<{expr}>…</{expr}>are not name-matched (any dynamic start pairs with any dynamic end — the closing expression is arbitrary and not expressible as a context-free constraint).