A conservative formatter for the Miranda functional programming language (.m files).
Hooks into VS Code's built-in Format Document command (Shift+Alt+F on Windows/Linux, ⇧⌥F on macOS). It never touches your indentation or alters semantics — when in doubt, it leaves the line exactly as-is.
Repository: TODO: add GitHub URL here
Formatting rules
| # | Rule | Example (before → after) |
|---|---|---|
| 1 | Remove trailing whitespace from every line | f x = 42 → f x = 42 |
| 2 | Collapse 2 or more consecutive blank lines into exactly one | a\n\n\nb → a\n\nb |
| 3 | Exactly one space on each side of = in definitions |
f x=42 → f x = 42 |
| 4 | No space before a comma; exactly one space after | [1 , 2,3] → [1, 2, 3] |
| 5 | Exactly one space after || in comments |
||note → || note |
| 6 | File ends with exactly one newline | hello\n\n → hello\n |
What is never changed
- Indentation — leading whitespace is sacred (Miranda uses the offside rule).
- String contents — rules 3 and 4 never apply inside
"...". - Comment contents — rules 3 and 4 never apply after
||. - Multi-char operators —
==,>=,<=,~=,:=are left untouched by rule 3. - Directives — lines starting with
%are treated like any other line; since they contain no bare=or,, they come out unchanged.
Requirements
- VS Code 1.85 or later.
- No external tools required — the formatter runs entirely inside VS Code.
Development
# Install dependencies
npm install
# Compile TypeScript → out/
npm run compile
# Run unit tests (no VS Code needed)
npm test
# Watch mode (recompile on save)
npm run watch
Running in debug mode (F5)
- Open this folder in VS Code.
- Press F5 — VS Code opens an Extension Development Host window with the extension loaded.
- In that window, open any
.mfile and pressShift+Alt+F(Format Document).
Packaging and publishing
# Install the VS Code Extension CLI (once)
npm install -g @vscode/vsce
# Package as a .vsix file
vsce package
# Publish to the Marketplace (requires a PAT)
vsce publish