| 📦 Turbo MoonBit cc1f595 k33g yesterday | 1 | # turbo-moonbit |
| 2 | |
| 3 | A Turbo C-style editor for MoonBit, written in Go. |
| 4 | |
| 5 | Built on **[turbo-core](https://rickub.com/turbo-editors/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. |
| 6 | |
| 7 | 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. |
| 8 | |
| 9 | ``` |
| 10 | File Edit Search Run Code Options Window Snippets MoonBit Help |
| 11 | ╔═[x]═════════════════════════════ main.mbt ════════════════════════════════1═[■]╗ |
| 12 | ║ 1 ///| ▲║ |
| 13 | ║ 2 struct Greeting { ▓║ |
| 14 | ║ 3 name : String ░║ |
| 15 | ║ 4 times : Int ░║ |
| 16 | ║ 5 } derive(Debug) ░║ |
| 17 | ║ 6 ░║ |
| 18 | ║ 7 ///| ░║ |
| 19 | ║ 8 fn greet(g : Greeting) -> Unit { ░║ |
| 20 | ║ 9 for i in 0..<g.times { println("Hello, \{g.name}! (\{i + 1})") } ▼║ |
| 21 | ║◄▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░►║ |
| 22 | ╚════════════════════════════════════════════════════════════════════════════════╝ |
| 23 | F1 Describe F2 Save F3 Open F6 Window F7 Next F10 Menu 1:1 LSP: ready |
| 24 | ``` |
| 25 | |
| 26 | ## Getting started |
| 27 | |
| 28 | ```bash |
| 29 | make install |
| 30 | ``` |
| 31 | |
| 32 | 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: |
| 33 | |
| 34 | ```bash |
| 35 | turbo-moonbit cmd/main/main.mbt |
| 36 | ``` |
| 37 | |
| 38 | 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`. |
| 39 | |
| 40 | For completion and diagnostics, install the MoonBit toolchain as well — the editor works without it, and says so on the status bar: |
| 41 | |
| 42 | ```bash |
| 43 | curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash |
| 44 | ``` |
| 45 | |
| 46 | 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](docs/en/how-to/install-the-moonbit-toolchain.md) covers `MOON_HOME`, upgrading, and how to check the editor really found it. |
| 47 | |
| 48 | The [tutorial](docs/en/tutorials/getting-started.md) walks through a first session in about ten minutes, and [`demos/`](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. |
| 49 | |
| 50 | ## Features |
| 51 | |
| 52 | - **Every build knows what it is** — `turbo-moonbit -version` and **Help ▸ About** name the version, the commit and the build date, stamped in by the linker from `git describe` rather than read from a constant somebody forgot to bump |
| 53 | - **Turbo Vision interface** — menu bar with `Alt`-letter hot keys, overlapping movable and resizable windows, modal dialogs, mouse support throughout |
| 54 | - **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 makes `1..=2` an integer and a range rather than a double. Plus TOML, YAML, Markdown, JavaScript, HTML, XML, Dockerfiles and shell scripts from turbo-core |
| 55 | - **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 |
| 56 | - **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 |
| 57 | - **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 |
| 58 | - **Completion, hover, go-to-definition, references, symbols and diagnostics** from `moon-lsp`, entirely optional. The server is looked for in `$MOON_HOME/bin` and `~/.moon/bin` as well as on `PATH`, so an editor started from a shell that never read the installer's profile still finds it |
| 59 | - **Terminal windows** — `F8` opens a real shell in a window, with its own VT/ANSI emulator, scrollback and job control (Linux, macOS and Windows) |
| 60 | - **Project tree** — `F9` shows the project's files in a window; walk it with the arrows and press Enter to open one |
| 61 | - **Snippets** — a `Snippets` menu 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 what `moon fmt` writes |
| 62 | - **The MoonBit toolchain a menu away** — `Alt-M` runs `moon check`, `moon fmt`, `moon build`, `moon test`, `moon run`, `moon add`, `moon info` and `moon clean` from `.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 a `menu` of its own gets that menu on the bar |
| 63 | - **Editing** with word movement, block indent, a shared clipboard, and undo that merges a run of typing into one step |
| 64 | - **Faithful files** — line endings and the trailing newline are preserved, and saving is atomic |
| 65 | - **Automatic saving**, off by default, writing a short while after you stop typing |
| 66 | |
| 67 | ## Commands |
| 68 | |
| 69 | | Command | What it does | |
| 70 | | --- | --- | |
| 71 | | `make install` | Build and install onto your `PATH` | |
| 72 | | `make build` | Compile into `bin/turbo-moonbit` | |
| 73 | | `make test` | Run the whole test suite | |
| 74 | | `make check` | `fmt`, `vet`, then the tests — what a commit should pass | |
| 75 | | `make run FILE=x.mbt` | Build and start the editor on a file | |
| 76 | | `make help` | List every target | |
| 77 | |
| 78 | ```bash |
| 79 | turbo-moonbit [-theme name] [-no-lsp] [file...] |
| 80 | turbo-moonbit -list-themes |
| 81 | ``` |
| 82 | |
| 83 | ## Documentation |
| 84 | |
| 85 | Full documentation in **[English](docs/en/)** and **[French](docs/fr/)**, organised by the [Diátaxis](https://diataxis.fr) method: |
| 86 | |
| 87 | | | | |
| 88 | | --- | --- | |
| 89 | | **Tutorial** | [Your first MoonBit program in Turbo MoonBit](docs/en/tutorials/getting-started.md) | |
| 90 | | **How-to** | [install the editor](docs/en/how-to/install.md) · [install the MoonBit toolchain](docs/en/how-to/install-the-moonbit-toolchain.md) · [run the tests](docs/en/how-to/run-the-tests.md) · [enable completion](docs/en/how-to/enable-completion.md) · [write a theme](docs/en/how-to/write-a-theme.md) · [move around a file](docs/en/how-to/navigate-code.md) · [ask about code](docs/en/how-to/ask-about-code.md) · [use a terminal](docs/en/how-to/use-a-terminal.md) · [configure a project](docs/en/how-to/configure-a-project.md) · [browse a project](docs/en/how-to/browse-a-project.md) · [use snippets](docs/en/how-to/use-snippets.md) · [run moon commands](docs/en/how-to/run-moon-commands.md) · [make a release](docs/en/how-to/make-a-release.md) | |
| 91 | | **Reference** | [command line](docs/en/reference/cli.md) · [keyboard](docs/en/reference/keyboard.md) · [menus](docs/en/reference/menus.md) · [theme format](docs/en/reference/themes.md) · [terminal windows](docs/en/reference/terminal.md) · [project settings](docs/en/reference/project-settings.md) · [project tree](docs/en/reference/project-tree.md) · [languages](docs/en/reference/languages.md) · [snippets](docs/en/reference/snippets.md) · [MoonBit tools](docs/en/reference/moonbit-tools.md) · [the version number](docs/en/reference/versioning.md) | |
| 92 | | **Explanation** | [architecture](docs/en/explanation/architecture.md) · [design decisions](docs/en/explanation/design-decisions.md) · [colouring and completion](docs/en/explanation/colouring-and-completion.md) · [terminal windows](docs/en/explanation/terminal-windows.md) · [project settings](docs/en/explanation/project-settings.md) · [project tree](docs/en/explanation/project-tree.md) · [snippets](docs/en/explanation/snippets.md) · [MoonBit tools](docs/en/explanation/moonbit-tools.md) | |
| 93 | |
| 94 | The library's packages each carry their own `README.md` beside the code, in [turbo-core](https://rickub.com/turbo-editors/turbo-core). |
| 95 | |
| 96 | ## Where the code is |
| 97 | |
| 98 | | | | |
| 99 | | --- | --- | |
| 100 | | `main.go` | flags, the terminal, the wiring | |
| 101 | | `internal/moonbitlang` | the profile, the MoonBit scanner, the three starter files | |
| 102 | | `demos/` | three MoonBit projects to open in the editor; each builds and runs | |
| 103 | | everything else | [turbo-core](https://rickub.com/turbo-editors/turbo-core) | |
| 104 | |
| 105 | The dependency graph is drawn in [`docs/diagrams/packages.drawio`](docs/diagrams/packages.drawio), checked against `go list` by `diagram_test.go`. |
| 106 | |
| 107 | ## Design in one line |
| 108 | |
| 109 | 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](docs/en/explanation/design-decisions.md) page explains why. |
| 110 | |
| 111 | ## Requirements |
| 112 | |
| 113 | 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. |
| 114 | |
| 115 | ## Licence |
| 116 | |
| 117 | See [LICENSE](LICENSE). |