Skip to content

feat: Tree-sitter grammar (Neovim, Helix, Zed) #66

@dean0x

Description

@dean0x

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

  • tree-sitter-mds grammar parses all MDS syntax constructs
  • Highlight, fold, indent, and textobject queries provided
  • Works as Markdown injection (preserves Markdown parsing)
  • Neovim integration tested with nvim-treesitter
  • Published to tree-sitter grammar registry
  • Corpus test suite covering all directive types

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttoolingEditor support, LSP, formatters

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions