Mojo Plus — Syntax, Snippets & Docs
A strict upgrade over the basic CristianAdamo.mojo syntax highlighter.
Mojo Plus ships a far richer TextMate grammar plus editor tooling so that
.mojo and .🔥 files look and feel first-class in Visual Studio Code.
Why "Plus"?
The original mojo extension provides only a minimal grammar. Mojo Plus adds:
| Capability |
mojo (basic) |
Mojo Plus |
.mojo / .🔥 association |
✅ |
✅ |
| Keyword highlighting |
partial |
✅ full (fn, struct, trait, var, let, alias, match, with, …) |
Type highlighting (SIMD, Int, Float64, Pointer, DType, …) |
❌ |
✅ |
Builtin functions (print, range, sizeof, bitcast, …) |
❌ |
✅ |
Number literals w/ suffixes (1.0f32, 42u8, 0xFF, 0b1010) |
❌ |
✅ |
Triple-quoted docstrings """…""" |
❌ |
✅ |
f-strings & raw strings (f"", r"") with interpolation scope |
❌ |
✅ |
Line doc comments (#| …) |
❌ |
✅ |
Decorators @fn / @value / @register / @test |
❌ |
✅ |
| Smart snippets |
❌ |
✅ 18+ |
| Hover docs for builtins / types / decorators |
❌ |
✅ |
| "Open Mojo Docs" & "Insert fn main()" commands |
❌ |
✅ |
Features
Rich syntax highlighting
- Keywords & modifiers —
fn, struct, trait, var, let, alias,
import, match, case, with, inout, borrowed, pub, parameter, …
- Types —
Int, UInt8…UInt128, Float16…Float64, SIMD, Pointer,
String, DType, List, Dict, Tuple, Optional, …
- Builtins —
print, println, range, len, sizeof, alignof,
bitcast, rebind, reinterpret, dunder methods, math helpers, …
- Numbers — decimal / hex / binary / octal with integer & float suffixes.
- Strings — double/single, raw (
r), format (f), char literals, and
triple-quoted docstrings, with {} interpolation highlighting inside f-strings.
- Comments —
# line and the Mojo doc-comment form #| ….
- Decorators —
@value, @register, @always_inline, @test, …
Snippets
Type a prefix and press Tab:
fnmain → fn main():
fn → function, struct → struct, trait → trait
var / let → typed variable bindings
for / while / if / ifelse / match / with
test → @test fn
doc → """…"""
- and more.
Hover documentation
Hovering a builtin (e.g. SIMD, fn, @value, print) shows a short
Markdown explanation. Toggle with Mojo Plus › Enable Hover Docs.
Commands
- Mojo Plus: Open Mojo Documentation — opens docs.modular.com/mojo.
- Mojo Plus: Insert fn main() template — drops a
fn main(): skeleton.
Requirements
None. Pure grammar + lightweight TypeScript activation.
Install
Search Mojo Plus in the Extensions view, or:
code --install-extension tetsuji16.mojo-plus
Build & test (for contributors)
npm install
npm run check # tsc --noEmit
npm test # node:test unit tests
npm run build # esbuild -> dist/extension.js
npm run package # vsce package -> mojo-plus-<ver>.vsix
License
MIT © tetsuji16. Implemented from the public Mojo language
reference and observable editor behavior — no third-party extension source copied.
If Mojo Plus saves you time, consider
sponsoring its development.
| |