TREE-SITTER GRAMMAR (MOJO) — C, PACKAGED AS A NEOVIM PLUGIN — LUA

Blaze-ts.nvim

Blaze-ts.nvim

Version 1.00Source on GitHub

OVERVIEW

Blaze-ts.nvim is a Tree-sitter grammar for the Mojo programming language, packaged as a Neovim plugin: the grammar is adapted from tree-sitter-python's architecture and extended with Mojo constructs, and the plugin ships a prebuilt parser, Tree-sitter queries and opt-in editor integrations, with nvim-treesitter not required.

HOW IT WORKS

  1. 1`require("blaze-ts").setup({})` registers the `.mojo` (and `.🔥`) filetype, adds the plugin's `runtime/` directory so queries resolve, and registers the bundled parser (`parser/mojo.so`, plus a WebAssembly build at `parser/mojo.wasm`) with Neovim's built-in Tree-sitter support. Source: GitHub blaze-ts.nvim README.md, "Manual" installation.
  2. 2When nvim-treesitter is present, the plugin also registers a `mojo` parser config so `:TSInstall mojo` builds the parser from this repository's C sources (`src/parser.c`, `src/scanner.c`). Source: GitHub blaze-ts.nvim README.md.
  3. 3The grammar itself extends the Python-superset base with Mojo constructs — `fn`/`struct`/`trait`, `var`/`let`/`alias`, `raises` effect specifiers, argument conventions (`inout`, `owned`, `borrowed`, `out`, `read`, `mut`, `ref`), parametric declarations and f-string interpolation — parsed by an external scanner implementing indentation/newline/string tokens with fixed-size state (indent stack 128, delimiter stack 32). Source: GitHub blaze-ts.nvim README.md.
  4. 4The opinionated editor stack in `blaze-ts.config` is applied only when `setup()` receives one of its section tables (`ts`, `conform`, `lsp`, `completion`, `diagnostics`, `keymaps`, `filetype`); each integration degrades gracefully when its companion plugin or binary is absent. Source: GitHub blaze-ts.nvim README.md, "Commands and configuration".
  5. 5Correctness is gated by a Tree-sitter corpus suite (`test/corpus`, 24 cases including malformed-input cases), regenerable with `tree-sitter generate src/grammar.js` and rebuildable with `tree-sitter build`. Source: GitHub blaze-ts.nvim README.md, "Development".
How it works, step by step — each step as the project's own documentation states it.

CONCEPTS

FROM GRAMMAR.JS TO A LIVE SYNTAX TREEGRAMMAR.JSPython-superset base+ fn · struct · traitvar · let · alias · raisesGENERATEparser.c · scanner.cexternal scanner:indent 128 · delim 32SYNTAX TREEconcrete tree ofthe parsed bufferincremental reparse on editQUERIEShighlights · indentsfolds · localsresolved from runtime/GATED BY THE CORPUS SUITEtest/corpus — 24 cases, malformed input includedregenerate and rebuild with the tree-sitter CLIBUNDLED WITH THE PLUGINparser/mojo.so — prebuiltparser/mojo.wasm — WebAssemblyOR BUILT BY NVIM-TREESITTER:TSInstall mojonvim-treesitter not required for the bundled pathadapted from tree-sitter-python's architecture, extended with Mojo constructsargument conventions: inout · owned · borrowed · out · read · mut · ref
The grammar pipeline: grammar.js — a Python-superset base extended with Mojo constructs — generates the C parser and external scanner; the parser builds the concrete syntax tree editors query, and highlight, indent, and fold queries resolve from the plugin's runtime directory. A corpus suite of 24 cases, malformed input included, gates the grammar, and the parser ships prebuilt (with a WebAssembly build) or is built by nvim-treesitter.

CONFIGURATION

OptionDefaultWhat it does
ts(section table; `{}` enables it)nvim-treesitter setup + parser registration section passed to `setup()`
conform(section table; `{}` enables it)conform.nvim formatter definition (`mojo format`) section
lsp(section table; `{}` enables it)mojo-lsp-server wiring section (requires the binary on PATH)
completion(section table; `{}` enables it)omnifunc on Mojo buffers section
diagnostics(section table; `{}` enables it)`vim.diagnostic` configuration section
keymaps(section table; `{}` enables it)Buffer-local keymaps on Mojo buffers section
filetype(section table; `{}` enables it)Filetype and buffer options section
parser.auto_installtrueIn the repo's `lazy.lua` spec opts: auto-install the Mojo parser
nvim_treesitter.highlight.enabletrueIn `lazy.lua` opts (`additional_vim_regex_highlighting = false`)
nvim_treesitter.indent.enabletrueIn `lazy.lua` opts
auto_install (ts setup)truedefault(opts.auto_install, true)` in `Config.setup_ts
sync_install (ts setup)falsedefault(opts.sync_install, false)` in `Config.setup_ts
ensure_installed (ts setup){ "mojo" }Parsers ensured by the ts setup when not overridden
highlight / indent / fold (ts setup)true eachdefault(opts.highlight, true)`, `default(opts.indent, true)`, `default(opts.fold, true)

CONTROLS

ActionControl
Run `require("blaze-ts").setup()`:BlazeTS
Full health report (parser, queries, Mojo environment probe):BlazeHealth
Parser-only health (config registration, parser path, loadability):BlazeParserHealth
Reinstall parser (nvim-treesitter if available, else re-register bundled parser):BlazeReinstallParser
Blaze-TS health check (lazy spec key, Mojo buffers)<leader>mh
Mojo parser health (lazy spec key, Mojo buffers)<leader>mp
Reinstall Mojo parser (lazy spec key, Mojo buffers)<leader>mr
Start / expand incremental selection`<C-space>` (init and node-incremental)
Shrink incremental selection`<BS>` (node-decremental)
Scope-incremental selection<C-s>
Lua API equivalentsrequire("blaze-ts").health_check()`, `.parser_health()`, `.reinstall_parser()

NOT COVERED

- The README documents the seven `setup()` section tables only as empty `{}` examples; the contents/defaults of the `conform`, `lsp`, `completion`, `diagnostics`, `keymaps` and `filetype` sections were not documented there (defaults above for the `ts` section come from `lua/blaze-ts/config.lua`). - The sandbox clone's README (`~/workspace/repos/blaze-ts.nvim/README.md`) is an older, different text (it routes setup through `require("blaze").setup()`, contains a broken lazy spec quote, and lists only highlighting/incremental parsing/indentation/semantic analysis as blaze.nvim uses); the GitHub README above supersedes it and the two disagree. - Language-binding status in the README: Swift bindings are present but explicitly not verified; the Node.js binding test is blocked upstream (tree-sitter JS runtime 0.25.1 has no prebuild for Node 26's ABI). Source: GitHub blaze-ts.nvim README.md, "Language bindings". - The README states the grammar is under active development with breaking changes expected until it is fully registered with nvim-treesitter.

REFERENCES

  1. Tree-sitter documentationThe parser generator and incremental parsing library the Mojo grammar is built with.
  2. Tree-sitter — Creating parsersThe grammar.js to generated-parser workflow Blaze-ts.nvim's development loop follows: write the grammar, generate, and test against a corpus.
  3. Tree-sitter — QueriesThe query language behind the highlight, indent, and fold captures the plugin ships.