Moggi documentation

Language server

moggi lsp is a language server over stdio. It is the same compiler: the server checks your project in the background, so diagnostics, types and navigation agree with what a build would say.

moggi lsp                 # stdio language server
moggi lsp --lib lib       # extra module roots, repeatable

VS Code

Install the extension from moggi-lang/moggi-vscode-plugin (the packaged .vsix is attached to each release). It starts a compiler you already have:

Setting Value
moggi.serverPath <installation>/bin/moggi, or <checkout>/moggi.php
moggi.phpPath the PHP 8.6.0 binary, when serverPath is a .php
moggi.libPaths extra --lib roots
moggi.inlayHints show or hide type inlays
moggi.testRoot fixture directory for Test Explorer (default tests/backend/runtime)

Commands: Moggi: Restart Language Server, Show Output, Moggi: Run (PHP). The status bar shows Moggi / Moggi: checking… while a check runs.

Any other editor can start moggi lsp directly; the server speaks LSP 3.18.

What it does

Area Supported
Diagnostics parse errors immediately, type errors after a short idle delay; stable codes (parse, unify, non-exhaustive, hole, …) and related information where a location helps
Typed holes _ reports the expected type; a code action fills a stub; hover shows it
Hover the type, its constraints, where the name is declared, and its doc comment
Completion locals, imports with auto-import, record fields inside { … }, and library search results
Navigation definition, declaration, type definition, implementation, references, document highlight, workspace symbols
Editing rename and prepare-rename (module-scoped binders, cross-file exports), formatting and range formatting, on-type formatting, linked editing
Structure document symbols, folding ranges, selection ranges, call hierarchy, type hierarchy
Display semantic tokens, inlay hints, code lens (reference counts), document links, inline values
Code actions add an import, fill a hole, add missing case arms, add a signature

Record support is worth knowing because a field is not a function: completion inside Person { … } or p { … } offers that record’s fields and omits the ones already written, and hover on a field label in a projection, construction, update or pattern shows label :: Type and the record that declares it.

The server checks with the PHP front end regardless of the backend you build for, so diagnostics describe the language, not a target.

What it does not do

Checking without an editor

moggi check, moggi build and moggi run use the same analysis (quickstart.md), and moggi repl exposes the stages interactively (repl.md).


Moggi compiles to PHP, the JVM and .NET. This site is generated from docs/ in the moggi-lang/moggi repository; the same pages are readable there as Markdown.