Summary
Create a tree-sitter-mds grammar that extends Markdown parsing with MDS-specific syntax nodes. This provides structural parsing for editors that use Tree-sitter (Neovim, Helix, Zed), enabling code folding, text object selections, indentation rules, and precise highlighting.
Motivation
Tree-sitter grammars provide deeper editor integration than TextMate grammars: structural navigation (jump to matching @end), code folding (@if...@end blocks), text objects (select entire @define block), and indent/dedent rules. This is the standard for Neovim, Helix, and Zed users.
Scope
- A
tree-sitter-mds grammar (C, generated from grammar.js)
- Parse nodes for all MDS directives:
import, export, define, if_block, for_block, include, extends, block, message
- Interpolation nodes:
interpolation, function_call, member_access
- Highlight queries (
highlights.scm)
- Fold queries (
folds.scm)
- Indent queries (
indents.scm)
- Text object queries (
textobjects.scm) for Neovim
- Published to the tree-sitter grammar registry
Design Considerations
- Tree-sitter MDS grammar should extend
tree-sitter-markdown as an injection (MDS nodes injected into Markdown parse tree)
- The grammar must handle MDS-in-Markdown (
.md files with type: mds frontmatter) and standalone .mds files
- Neovim integration via
nvim-treesitter parser config
- Helix and Zed pick up grammars from the tree-sitter registry automatically
- Repo: separate
tree-sitter-mds repository (tree-sitter convention)
Acceptance Criteria
Summary
Create a
tree-sitter-mdsgrammar that extends Markdown parsing with MDS-specific syntax nodes. This provides structural parsing for editors that use Tree-sitter (Neovim, Helix, Zed), enabling code folding, text object selections, indentation rules, and precise highlighting.Motivation
Tree-sitter grammars provide deeper editor integration than TextMate grammars: structural navigation (jump to matching
@end), code folding (@if...@endblocks), text objects (select entire@defineblock), and indent/dedent rules. This is the standard for Neovim, Helix, and Zed users.Scope
tree-sitter-mdsgrammar (C, generated fromgrammar.js)import,export,define,if_block,for_block,include,extends,block,messageinterpolation,function_call,member_accesshighlights.scm)folds.scm)indents.scm)textobjects.scm) for NeovimDesign Considerations
tree-sitter-markdownas an injection (MDS nodes injected into Markdown parse tree).mdfiles withtype: mdsfrontmatter) and standalone.mdsfilesnvim-treesitterparser configtree-sitter-mdsrepository (tree-sitter convention)Acceptance Criteria
tree-sitter-mdsgrammar parses all MDS syntax constructsnvim-treesitter