turbo-moonbit
A Turbo C-style editor for MoonBit, written in Go.
Built on turbo-core, the library every Turbo editor shares. What is in this repository is the command, the profile that says this editor is for MoonBit, and the MoonBit scanner — about eleven hundred lines, comments and all. Everything else lives in the library.
A full-screen terminal IDE with the Borland furniture — a menu bar with hot keys, movable windows that cast shadows, modal dialogs, a clickable status bar — and the things a MoonBit editor needs: syntax colouring written against the language's published lexical grammar, loadable colour themes, completion and diagnostics from moon-lsp, shell windows, per-project settings, a project tree, snippets, and the moon toolchain a menu away.
File Edit Search Run Code Options Window Snippets MoonBit Help
╔═[x]═════════════════════════════ main.mbt ════════════════════════════════1═[■]╗
║ 1 ///| ▲║
║ 2 struct Greeting { ▓║
║ 3 name : String ░║
║ 4 times : Int ░║
║ 5 } derive(Debug) ░║
║ 6 ░║
║ 7 ///| ░║
║ 8 fn greet(g : Greeting) -> Unit { ░║
║ 9 for i in 0..<g.times { println("Hello, \{g.name}! (\{i + 1})") } ▼║
║◄▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░►║
╚════════════════════════════════════════════════════════════════════════════════╝
F1 Describe F2 Save F3 Open F6 Window F7 Next F10 Menu 1:1 LSP: ready
Getting started
make install
That builds the editor, puts it where your shell looks for commands, and reports what it found — the Go version it built with, where the binary went, whether that directory is on your PATH, and whether moon-lsp is installed. Then, from any MoonBit project:
turbo-moonbit cmd/main/main.mbt
To build without installing, make build leaves the binary in bin/turbo-moonbit. From the module proxy instead of a checkout: go install rickub.com/turbo-editors/turbo-moonbit@latest.
For completion and diagnostics, install the MoonBit toolchain as well — the editor works without it, and says so on the status bar:
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
That one command installs moon, moonc and moon-lsp together. moon-lsp alone is not enough: it works a project out by running moon, so a machine with the server but not the build system gets a server that starts and then knows nothing about any file. The install guide covers MOON_HOME, upgrading, and how to check the editor really found it.
The tutorial walks through a first session in about ten minutes, and demos/ holds three MoonBit projects to open in it — a small one, one with a library and tests, and a tour of every construct the scanner colours.
Features
- Every build knows what it is —
turbo-moonbit -versionand Help ▸ About name the version, the commit and the build date, stamped in by the linker fromgit describerather than read from a constant somebody forgot to bump - Turbo Vision interface — menu bar with
Alt-letter hot keys, overlapping movable and resizable windows, modal dialogs, mouse support throughout - Syntax colouring for nine languages — MoonBit by a hand-written scanner written against the language's published lexical grammar: every literal form including
b"…",re"…"and the#|/$|multi-line lines, every numeric suffix, attributes as whole lines, labelled arguments, package qualifiers, and the rule that makes1..=2an integer and a range rather than a double. Plus TOML, YAML, Markdown, JavaScript, HTML, XML, Dockerfiles and shell scripts from turbo-core - Nothing carried between lines — MoonBit has no block comment and no literal that may reach the next line, so an unterminated string cannot paint the rest of the file. It is the only editor in this family whose scanner needs no state at all
- Themes in TOML, eleven embedded — Borland navy, dark grey, paper white, espresso, Catppuccin Frappé and Latte, cobalt, Darcula and IntelliJ Light, and a hueless monochrome in both polarities — and any number of your own, with inheritance between files and between style keys. Every shipped theme is held to its contrast by tests
- Per-project settings in
.turbo-moonbit/settings.toml— pin a theme, turn on automatic saving — created from a menu item, never by itself, and re-read on every save so a change takes effect without a restart - Completion, hover, go-to-definition, references, symbols and diagnostics from
moon-lsp, entirely optional. The server is looked for in$MOON_HOME/binand~/.moon/binas well as onPATH, so an editor started from a shell that never read the installer's profile still finds it - Terminal windows —
F8opens a real shell in a window, with its own VT/ANSI emulator, scrollback and job control (Linux, macOS and Windows) - Project tree —
F9shows the project's files in a window; walk it with the arrows and press Enter to open one - Snippets — a
Snippetsmenu built from.turbo-moonbit/snippets.toml, grouped into submenus and filtered by the file you are in; the chosen text is inserted at the cursor, re-indented to match, and indented two spaces because that is whatmoon fmtwrites - The MoonBit toolchain a menu away —
Alt-Mrunsmoon check,moon fmt,moon build,moon test,moon run,moon add,moon infoandmoon cleanfrom.turbo-moonbit/tools.toml, each showing its output where the tool asked: a popup that fills in as it goes, a terminal window, or an editing window to search. Files the command rewrote are re-read for you, and a tool naming amenuof its own gets that menu on the bar - Editing with word movement, block indent, a shared clipboard, and undo that merges a run of typing into one step
- Faithful files — line endings and the trailing newline are preserved, and saving is atomic
- Automatic saving, off by default, writing a short while after you stop typing
Commands
| Command | What it does |
|---|---|
make install |
Build and install onto your PATH |
make build |
Compile into bin/turbo-moonbit |
make test |
Run the whole test suite |
make check |
fmt, vet, then the tests — what a commit should pass |
make run FILE=x.mbt |
Build and start the editor on a file |
make help |
List every target |
turbo-moonbit [-theme name] [-no-lsp] [file...]
turbo-moonbit -list-themes
Documentation
Full documentation in English and French, organised by the Diátaxis method:
| Tutorial | Your first MoonBit program in Turbo MoonBit |
| How-to | install the editor · install the MoonBit toolchain · run the tests · enable completion · write a theme · move around a file · ask about code · use a terminal · configure a project · browse a project · use snippets · run moon commands · make a release |
| Reference | command line · keyboard · menus · theme format · terminal windows · project settings · project tree · languages · snippets · MoonBit tools · the version number |
| Explanation | architecture · design decisions · colouring and completion · terminal windows · project settings · project tree · snippets · MoonBit tools |
The library's packages each carry their own README.md beside the code, in turbo-core.
Where the code is
main.go |
flags, the terminal, the wiring |
internal/moonbitlang |
the profile, the MoonBit scanner, the three starter files |
demos/ |
three MoonBit projects to open in the editor; each builds and runs |
| everything else | turbo-core |
The dependency graph is drawn in docs/diagrams/packages.drawio, checked against go list by diagram_test.go.
Design in one line
Two dependencies — tcell/v2 and BurntSushi/toml — and everything else from the standard library, including the scanner toolkit and the Language Server Protocol client. Both come through turbo-core; this repository adds none of its own. The design decisions page explains why.
Requirements
Go 1.26 or later to build it — the editor is written in Go even though it is an editor for MoonBit. A terminal with mouse reporting, which is all of them. The MoonBit toolchain is optional, and is what completion and the error marks need.
Licence
See LICENSE.