# Tree-sitter-mojo

**URL:** <https://forum.modular.com/t/tree-sitter-mojo/3326>\
**Category:** Community Showcase\
**Created:** [July 15, 2026, 11:21am UTC](https://forum.modular.com/t/tree-sitter-mojo/3326 "2026-07-15T11:21:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmitry\_salin](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@dmitry\_salin](https://forum.modular.com/u/dmitry_salin)\
**Post date:** [July 15, 2026, 11:21am UTC](https://forum.modular.com/t/tree-sitter-mojo/3326/1 "2026-07-15T11:21:28Z")

</div>

[tree-sitter-mojo](https://github.com/dmitry-salin/tree-sitter-mojo)

My take on `Mojo` grammar for `tree-sitter`.

1. Supports all `Mojo` syntax described in the nightly [language reference](https://mojolang.org/nightly/docs/reference/) and targets the upcoming 1.0.0 release
2. In general, names of the rules are used as they are described in the language reference
3. Trying to optimize state count:
  - `Python` grammar
    - `src/parser.c`

  - After refactoring and adding `Mojo` features
    - `src/parser.c`

4. [neovim-treesitter](https://github.com/neovim-treesitter) repo now supports [Self-Contained Queries](https://github.com/neovim-treesitter/treesitter-parser-registry/blob/main/docs/self-contained-migration.md). Added [this](https://github.com/dmitry-salin/tree-sitter-mojo/tree/main/nvim-queries/mojo) to keep queries in sync with the grammar
5. In editors like [Ki](https://ki-editor.org/docs/normal-mode/selection-modes/primary/#named-node) syntax-node-based code navigation and editing is one of the core features. To improve the usability of this mode, additional adjustments to the grammar may be made

---

<div class="post-metadata">

**Author:** ![dmitry\_salin](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@dmitry\_salin](https://forum.modular.com/u/dmitry_salin)\
**Post date:** [August 18, 2026, 1:58am UTC](https://forum.modular.com/t/tree-sitter-mojo/3326/2 "2026-08-18T01:58:05Z")

</div>

The grammar has been updated for Mojo 1.0.0 - [Release v1.0.4 · dmitry-salin/tree-sitter-mojo · GitHub](https://github.com/dmitry-salin/tree-sitter-mojo/releases/tag/v1.0.4)
