Skip to content
Early preview. Maxon is under active development — incomplete in places, with breaking changes expected before a 1.0 release.

Editor Support

Maxon’s editor support is the compiler itself: maxon lsp-server is a Language Server Protocol server, and the VS Code extension and the Claude Code plugin run it.

Install Maxon from the Visual Studio Marketplace or Open VSX (extension id maxon-lang.maxon-lsp-client). It activates in a workspace containing Maxon files and provides syntax highlighting, diagnostics with their quick fixes, hover, completion, go-to-definition, rename, formatting, the Compiler Explorer, a Test Explorer and, on every native target, debugging. .maxon sources, .maxproj project files, .maxtasks task files and .maxtest test files are all Maxon documents, served by the language server.

Finding the compiler. The extension runs maxon lsp-server from the first compiler it finds:

  1. the maxon.serverPath setting, when it points at an executable;
  2. maxon-bin/.maxon/maxon in a workspace folder that is a Maxon source checkout (it holds specs/, stdlib/, runtime/ and maxon-bin/), the first such folder in folder order. The compiler reads stdlib/ and runtime/ from beside its own executable, so a checkout is served by its own build. A checkout with no build yet is noted in the output channel and the search goes on. In an untrusted workspace a checkout’s own build is noted the same way and passed over;
  3. maxon on PATH;
  4. $MAXON_INSTALL/bin/maxon when MAXON_INSTALL is set, otherwise ~/.maxon/bin/maxon (the install script’s default location);
  5. maxon-bin/.maxon/maxon in the checkout the extension itself is part of, when it runs from source.

In a trusted workspace, a compiler found by a later step that opens a Maxon source checkout hands the session to that checkout’s own build once there is one (Serving a checkout).

If none is found, the extension offers to Install Maxon with the install script or to Locate… a compiler, which it saves to maxon.serverPath. Before offering, the extension asks the install script for its directory (--print-root, -PrintRoot), and names that directory in the prompt, the progress notification, the closing message and the Maxon Language Server output channel. When the script cannot be asked (offline, or a MAXON_INSTALL the script refuses), the prompt names the failure and $MAXON_INSTALL, otherwise ~/.maxon, and offers both choices. When the installer exits with an error and the compiler is in that directory’s bin, the closing message is a warning that names the directory. When claude is on PATH, Install first asks whether to install the Claude Code plugin too, and passes the answer to the script. The extension searches again each time the language server restarts, when a workspace folder is added or removed, and when maxon.serverPath changes. When the compiler in use, or the build of any open checkout, changes on disk (for example after an upgrade or a rebuild), the extension restarts the language server. Language server errors are written to the Maxon Language Server output channel. The status bar item turns red while the server is stopped and yellow while it loads a project. Its tooltip shows the compiler’s version and location, and links to Restart and Show Output.

Settings:

Setting Default Description
maxon.serverPath "" Absolute path to the maxon compiler. Empty means search as above.
maxon.formatting.insertSpaces false Indent formatted code with spaces instead of tabs
maxon.formatting.tabSize 2 Spaces per indent level, when insertSpaces is true

The formatting settings replace the editor’s own tab settings for Maxon files. The extension also turns on format-on-save and semantic highlighting for Maxon files by default. A capability word (isolated, immutable, mutable) qualifying a type is coloured #D85C8A, as the capability semantic token and by the TextMate grammar alike.

Commands:

Command What it does
Maxon: Restart Language Server Restart maxon lsp-server
Maxon: Show Language Server Output Open the Maxon Language Server output channel
Maxon: Open Compiler Explorer Focus the Compiler Explorer view

Compiler Explorer. A view in the Maxon activity-bar container with a Source pane and a Target IR pane. Half a second after you stop typing, it compiles the source for the host and shows the lowered Target IR, the same text maxon build --emit-ir writes, or the compile errors as Line <line>:<column>: <message>. Nothing is written to disk. The source is treated as a whole program, so it needs a main.

Test Explorer. The Maxon Tests controller lists the test declarations in the workspace’s *.maxtest files (the extension matched case and all, as the compiler matches it), one node per file, and runs them with the compiler the extension found, one maxon test <project> --json per project the selection touches. A test file’s project is the nearest directory holding a .maxproj, from the file’s own directory up to the workspace folder; a test file with none there runs alone, as maxon test <file> --json. When the workspace folder is the Maxon source checkout, a second controller, Maxon Spec Suite, lists the spec tests in specs/*.md and runs them with the checkout’s own compiler (maxon-bin/.maxon/maxon spec-test --filter=…).

Debugging. The extension contributes a maxon debugger whose adapter is maxon dap-server, run from the compiler it found, on every native target. F5 works without a launch.json: a configuration without program debugs the active editor’s .maxon file, or else the workspace folder when it holds a .maxproj file. A source file or project is built with debug info into the host’s Maxon cache first. The Test Explorer’s Debug Test builds the tests of each project, or lone test file, the selection touches once with maxon test --list --build --json, copies the test binary and its sidecar to a temporary directory, and debugs each selected test in turn under that copy (see Running the test binary); cancelling the run stops the session. The extension’s README describes the launch attributes and the panes.

Restricted mode. A test run, a debug session and a project file each run the workspace’s code, so an untrusted workspace gets the features that only read it. The language server is started untrusted and reads each project as its directory (see maxon lsp-server); the Test Explorer and the spec suite mark every requested test with a refusal that names trust; the debugger answers every launch with that refusal; and the compiler comes from the user’s maxon.serverPath, PATH or the install, with a checkout’s own build and a workspace’s maxon.serverPath passed over. Trusting the workspace tells the running language server and searches for the compiler again.

The maxon-lsp plugin gives Claude Code’s LSP tool the language server, so an agent gets diagnostics after each edit, hover, go-to-definition and find-references in Maxon documents. The install script and maxon upgrade offer to install it when claude is on PATH and the plugin is missing; without a terminal to ask in they print the command to run. The install script’s --claude-plugin (-ClaudePlugin) installs it without asking, and --no-claude-plugin (-NoClaudePlugin) skips the offer. To install it yourself, from Claude Code:

/plugin install maxon-lsp --marketplace maxon-lang/maxon

or from a shell: claude plugin install maxon-lsp --marketplace maxon-lang/maxon.

The plugin runs maxon lsp-server from PATH, for .maxon, .maxproj, .maxtasks, .maxtest and .test files. In a Maxon source checkout that server hands the session to the checkout’s own build, and to each rebuild of it (Serving a checkout). The MCP tools are configured separately (see MCP Server).

Terminal window
maxon lsp-server

Speaks the Language Server Protocol over stdin and stdout: JSON-RPC messages with Content-Length headers. Its one option is --log=, and it is normally started by an editor, not by hand.

Lifecycle. initialize returns the server’s capabilities and its serverInfo: name is maxon, and version is the line maxon version prints. initialized is accepted. shutdown answers null, and exit ends the process with code 0 after a shutdown and 1 otherwise (as it does when stdin closes or a message cannot be framed). The process ends at once, stopping any project check still running.

Serving a checkout. When initialize names a workspace root that is a Maxon source checkout (it holds stdlib/, runtime/ and maxon-bin/) and the client trusts the workspace, any server other than that checkout’s own build passes the session to it: it starts maxon-bin/.maxon/maxon lsp-server and relays every message both ways, so the checkout is served by the compiler built from it. After initialized the server asks the client to watch that binary: a client/registerCapability request for workspace/didChangeWatchedFiles, with a relative pattern rooted at the binary’s directory (an absolute glob where the client does not declare relativePatternSupport), so the binary may sit outside the workspace. A change event makes the server read the binary’s size and modification time, and a rebuilt one is started and the session replayed to it: initialize, initialized, the workspace notifications, and every open document at the version the client last sent. A build writes the new compiler into a staging directory and renames it into place, so the file is whole when the client reports it. Each request still waiting for an answer is answered with error -32801 (ContentModified), so the client asks again, and a shutdown with null. While no compiler is built into the checkout, requests are answered -32801 too, and the server answers initialize itself, as it does when the compiler ends before it has answered initialize. A client that does not declare dynamic registration of file watchers gets no hot reload: the server says so once, in a window/logMessage, and a compiler built after the session began is picked up when the session restarts. A compiler that cannot be started is reported once, in a window/logMessage, and started again when the binary’s size or modification time changes, the two things the server compares; what the relayed compiler writes to its stderr is passed on with the next message either side sends. A message from it longer than 64 MiB ends it.

Documents. Text synchronization is full: every textDocument/didChange carries the whole document. The server handles didOpen, didChange and didClose. Each buffer is analysed from its in-memory text, for the host target.

Every feature reads the project, where the document has one, and diagnostics are checked per buffer and then across the project. Hover, definition and completion resolve names through a separate index built by lexing every source of the document’s project (see the project’s files below) and folding its declarations — a lexing pass, far lighter than a compile — so a name declared in another file resolves, and a type declared there offers its members. The index matches what the matching command compiles: for a .maxon document it holds the project’s .maxon sources, and for a .maxtest document the project’s .maxtest files as well, so a test file sees the helpers its sibling test files declare and a production source sees production sources only. Diagnostics use that same index for one correction: a name a sibling file declares counts as declared. A call to a name no file declares is reported once, at that call, and the value it produces is accepted wherever it is used. This buffer check runs on the buffer together with the standard library. An error only the whole program merged across files can raise — two sibling files contesting one name, for example — comes from the project check described under Diagnostics below, which compiles the project as maxon build does.

A document’s uri may carry any scheme, and what the server can do with a document turns on the path that uri spells. Every scheme is accepted, so an editor that forwards whatever uri a buffer carries is served. Document symbols, folding ranges, formatting, linked editing and rename read the buffer alone and answer for every open document; code actions answer from the document’s published diagnostics. Semantic tokens answer for every open document too, and take the types a project declares from the project’s files and stdlib/ where the uri spells a path. The project half needs a path with a directory above it, and a document whose uri has one is the kind maxon/listProjects lists. An unsaved scratch buffer (untitled:Untitled-1) is checked and resolved against stdlib/ and runtime/ alone. A uri that spells a path outside the filesystem (git://host/repo/file.maxon) is resolved against the buffer and stdlib/: hover, definition, completion and semantic tokens find the types and members either declares. Diagnostics are published for filesystem documents only.

While a buffer is unsaved, the buffer check holds some diagnostics back. As long as the buffer matches the file on disk, the buffer check reports what compiling that file with the standard library reports. Once it has been edited, diagnostics about the buffer’s own text — syntax, tokens, literals — are still published immediately, while diagnostics that turn on what a declaration says wait for the project check, which compiles the edited text, or for the buffer to match disk again. That is what stops an editor inventing errors about names it cannot see, and it applies only when the buffer does use a name that only the project declares. This project view needs a .maxproj in the file’s directory or one above it, or a file inside stdlib/ or runtime/; any other file gets the per-buffer behaviour described below.

The project root is a ladder, and only a .maxproj or a library tier marks a project. The compiler’s own stdlib/ and runtime/ are one project each, rooted at the tier directory, which the server locates itself: every file inside a tier belongs to that tier’s project, and a runtime/ file is checked as the build checks tier source — its reserved names and __Raw calls are legal, its restrictions still apply, and a body no program reaches is exempt from the call checks. A .maxproj or .maxtasks document is a program of its own, as the driver compiles it: its diagnostics, hover, definition and completion see the library and itself. A saved .maxproj document also marks its project, so opening one loads the project rooted at its directory, and maxon/listProjects lists it as that project; an unsaved one is rooted as an unsaved source in its directory is. A .maxtasks document is rooted at its own file. Any other document is rooted at the nearest ancestor directory holding a .maxproj file, searched up to the nearest workspace folder the client named that contains the document. Failing that the document is a single file, checked against the library tiers alone, and its hover, definition and completion read the library and the document. A .maxproj at a volume root (/, C:\, a \\server\share) marks a single file too. Every entry of workspaceFolders caps the search for the documents inside it, and rootUri is read when the folders name none, so in a multi-root window each folder caps its own documents. A client that sends no root, or one whose root is a uri of another scheme than file: — what Remote-SSH, WSL, dev containers and Codespaces send — searches for the .maxproj up to the volume root. The .maxproj file marks where a project begins, and the server runs none of it. A .maxproj file inside another project’s tree is published with E2074, and the outer project’s walk skips the directory holding it.

The roots are not fixed for the session. The initialize response advertises workspace.workspaceFolders with supported and changeNotifications both true, and the server then handles workspace/didChangeWorkspaceFolders: a folder added to the window caps the .maxproj search at once, and a folder removed from it stops capping it, with no restart of the editor. Nothing else in the workspace is renegotiated.

Every path stays in the spelling the client sent, and the physical path decides which file, folder and project is meant. A document is read, indexed and answered under the uri the editor opened it with: its diagnostics are published under that uri, a definition names the file under the spelling the project was loaded with, and maxon/projectLoading and maxon/listProjects name a root by the spelling that reached it first. Where two spellings could mean one thing, the server asks the host for the physical path of each — every symbolic link followed, as maxon build keys its compiler-version record — and treats equal answers as one: two spellings of a file are one source of the project, two spellings of a project are one held project, and a workspace folder named by two spellings is closed when its last spelling is. A path the host refuses to resolve (a directory above it the server may not search, or, on Linux, an unmounted /proc) is reported by name and its sentence says what to check: on the document as one error item at its first character, for a workspace folder as a window/showMessage of type 1, and for maxon/generateIR as an internal error.

A project holds the files its .maxproj file describes, as maxon build reads them. The ladder names the project’s directory. When its .maxproj declares targets, the server runs the project file as maxon build runs it and holds the sources the target describes, rooted at the one directory they all lie under, so a file’s namespace is the one the build gives it. With several targets the project holds the sources of every one. A .maxproj that declares no target, a directory with no .maxproj, and a project file that does not compile are each their directory’s walk.

The project file runs beside the session, for up to 30 seconds, and every request is answered meanwhile. Each project’s file runs on its own, so a slow one holds up only its own project’s answer. The project check of a document in that project starts once the answer arrives, and every open document in that project is then checked again. An answer holds while what it was resolved from is unchanged: the .maxproj text, every .maxproj it delegates to, and the bytes of each file the build declares in inputs. A declared input that is missing is held as missing, and its appearance runs the project file again, as do its deletion and an edit that changes its bytes; one rewritten with the same bytes keeps the answer. A file the project file reads without declaring it keeps the held answer when it changes. A project file that failed to compile, failed, or was refused is run again after ten seconds. maxon build runs the project file on every build. Three gaps remain: an input whose modification time lies in the future is read again on every ask; an input the previous run did not declare that is deleted while the run that declares it is under way leaves that run’s answer held; and on a filesystem whose clock is coarse or skewed against the server’s, a write made during a run can go unseen. A project file that fails or describes no usable build — no build, or no sources — is a refusal: the line maxon build prints for it is published on the .maxproj document, and with the project check of each document in the project, at the document’s first character.

The server runs a project file only in a trusted workspace. initialize’s initializationOptions.trustedWorkspace states the trust, and a client that sends none is trusted. The maxon/workspaceTrust notification changes it for the rest of the session, and every open document is then checked again:

{ "trusted": true }

In an untrusted workspace every project is its directory’s walk, and a .maxproj whose targets would be run carries one Information diagnostic at its first character: this project's source list applies once the workspace is trusted; until then the project is its directory.

A project’s .maxproj document carries the breaking changes since the project’s last build. Each publish of the .maxproj reads the project’s compiler-version record, in a trusted and an untrusted workspace alike, and adds one Information diagnostic at the document’s first character for each breaking change since the recorded release: This project was last built with maxon <release>. <version>: <change> Fix: <fix>. A record that does not hold a release version, or cannot be read, is one Error diagnostic carrying the line maxon build refuses with. maxon build writes the record and the server reads it, so a build shows in these diagnostics the next time the .maxproj is published: after an edit to it, or, once the record has changed since the open .maxproj last published, after an open or edit of any document of the project.

A project is built when a document in it opens. On didOpen the server builds the index that document reads, before it publishes the document’s diagnostics, when the document’s root is a known project: a directory holding a .maxproj, stdlib/ or runtime/. A single-file document has only the library built, by its first hover, definition or completion.

Projects are held across requests, the eight most recently used roots at a time, and a source is re-read when its size or modification time changes on disk. Removing a workspace folder also drops every project held under it, once no other spelling of that folder is still open. The list of files under a root is re-walked at most once a second, so a file created on disk after the project was built is resolved into shortly afterwards rather than at once, and a file deleted from disk leaves the project at that same walk — definition, hover and completion stop resolving into it, and a name it was the only declaration of stops being one the project declares. A rename is the two together: the answer moves to the new path, rather than one declaration being answered out of both. Creating and deleting are noticed at the next walk, a change to a file’s contents on the next request. A walk that cannot list a directory leaves the previous list standing rather than treating the files under it as gone.

Diagnostics are published with textDocument/publishDiagnostics after every didOpen and didChange, and cleared on didClose. Each has the error code (for example E3005) as code, source: "maxon" and severity Error; the untrusted-workspace notice and the breaking-change notices above have severity Information. A document is checked with the lint rules, and is published with a discarded result (E3064, E3065). “No main function” (E3001) and the unused-declaration diagnostics (E3092, E3219, E3062) are claims about the whole program. The buffer check withholds all four. The project check below, which compiles the whole project, publishes E3092, E3219 and E3062 on the document they name, each with its quick fix, and E3001 is published by the command line alone, in the output of maxon build and maxon lint. When they are the only errors, a document is published with its unneeded casts (E3010) and target refusals (E3074, E3104).

A .maxon document in a project is published twice per version: the buffer check’s set, then the project check’s. This applies where the document’s root is a directory holding a .maxproj. The buffer check’s set is published at once. The project check then compiles the document’s whole project from disk, with the buffer’s current text — saved or not — in place of the file, through type checking and range checking, and publishes the diagnostics that compile reports on this document: a range error in a call to a function a sibling file declares, a partial implementation of a sibling’s interface, an unused variable, and every other error maxon lint reports. A diagnostic with no position of its own is published when the buffer check raised it too. .maxtest, .maxproj and .maxtasks documents, and files of stdlib/ and runtime/, get the buffer check’s set alone.

The project check starts once edits have paused for 300 ms, so a burst of keystrokes is checked once, at its last version. When the client sends a newer version, the older version’s check is superseded: one that has not started is skipped, one that is running stops, and a result that arrives late is dropped, so the editor receives only sets for the version it holds. Each project root has a checker service of its own that never blocks the session and runs that root’s checks one at a time, while the checks of different roots run side by side; a check waiting behind the running one is replaced by a newer check of the same document. Each project root keeps its compiled project between checks, so a re-check re-reads, re-lexes and re-parses only the files that changed, and runs the whole-program checks again in full. Hover, definition, completion and the other requests are answered while a check runs.

When the project cannot be loaded — a source under the root cannot be read, or the root cannot be walked — the second publish is the buffer check’s set plus the line maxon build prints for that failure (for example error: could not read <path>), as an item carrying only a message, at the document’s first character. A document the project’s walk skips, such as one under a directory a .maxonignore marks, has the buffer check’s set published a second time.

Each project check the server is asked for sends one window/logMessage notification, with type 4 (Log) and this message:

maxon: project check <uri> version <version> <outcome>

<version> is the version the client sent with the document, or unversioned when it sent none. <outcome> is one of:

Outcome What happened
published the project check’s diagnostics were published
unloadable the project could not be loaded, and the buffer check’s set was published with the build’s error line
unlisted the project’s walk skips the document, and the buffer check’s set was published again
abandoned a newer version arrived while the check ran, and the check stopped
superseded a newer version arrived before the check started or before its result was written, and the result was dropped

Quick fixes. initialize advertises codeActionProvider as an options object whose codeActionKinds is ["quickfix"]. Every published diagnostic that carries a repair is offered as a quick fix built from that repair, the one maxon lint --fix writes: the compiler computes it with the diagnostic, against the text the editor last sent, saved or not. A textDocument/codeAction request is answered from the set last published for the document’s current version, the project check’s once it has landed, so E3092, E3219 and E3062 get theirs from the project check; until the current version’s set is published the answer is []. Each diagnostic of that set whose range touches the requested range, and whose repair edits this document alone, is one action:

  • kind quickfix, a title naming what it does (Discard the result of 'note', Delete the unneeded cast to 'Tally'), diagnostics holding that diagnostic as it was published, and edit, a WorkspaceEdit whose changes edit the document’s uri, ranged in UTF-16 units of that text.
  • When the answer holds one and the document has two or more repairs, one more action, titled Apply all <n> quick fixes in this file, applies them all in one edit and names each diagnostic it repairs. Where two repairs would edit overlapping text, the first is taken and the other waits for the diagnostics the edited text publishes.

A diagnostic with two or more reasonable repairs, one whose repair the compiler cannot place with certainty, one in stdlib/, runtime/ or a scriptlib package, and one in a file that holds an #if publish with no repair, as lint --fix leaves them. A diagnostic the buffer check takes from the file on disk while the buffer differs from it is published without its repair. Only an action the user picks rewrites a document, and quickfix is the one kind advertised.

Requests served:

Method Result
textDocument/hover Markdown: the declaration as written in a maxon code block, its /// doc comment, and for a variable or parameter what it is and its type. A binding is named for where it lives — a module-level constant, a field of the type that declares it, a local, or a loop variable — and for its kind, a constant (let), a variable (var) or a view (view), and its type is read from whatever gives it one: a written type, a literal, a call’s declared return type, a try … otherwise, a field of another type, the element type of the collection a for … in walks, or the element of a generic container reached through a type alias. A name declared outside the buffer is looked up in the project, and so is a member of one: a field or method of a type declared in a sibling file or in the standard library renders too, a method an interface extension publishes onto that type included, and only where that file’s visibility rules let this file name it. A bare call inside a type renders the type’s own method before a free function of that name, a bare call anywhere else renders the free function, and self and Self name the type whose body holds the cursor. Where the type cannot be named — an element still standing for a type parameter — the hover says it could not infer the type. A qualified chain reads as the compiler reads it: sub.Calc in sub.Calc.make() renders the type sub/ declares and make that type’s static, and a chain whose head is a binding in scope reads that binding. Keywords and math intrinsics are described too. Once the project check of the buffer’s current version has finished, a variable, parameter or self also shows the capability the compiler recorded at that read, as <type> — <capability>: mutable, read-only while 'fill' is open (mutable outside it) inside a modify or acquire block, frozen (immutable), or isolated. A value that has moved says moved at line N (consumed at line N for a linear one), naming the line of the move, a partial move out of a union included. Until it moves, a linear value says to consume it with a finalizer on every path and names the type’s consuming self methods, wherever the type is declared, and a promise tied to its caller’s data says to await or cancel it. A parameter shows the capability its function needs: any capability when it only reads the value, otherwise mutable only or immutable only with the call or line that decides it, followed by the capability each call site in the project passes (mutable (main:24, live), immutable (main:25, frozen)). The name of a function the buffer declares, at its declaration and at a call that resolves to it, says whether it takes consuming self and whether it may wait, with the call chain down to the wait. A buffer edited since its last project check, and a check that did not complete, are hovered from the text alone.
textDocument/definition The declaration of the name under the cursor. A declaration in the same document is answered from it; otherwise the project’s index says which file declares the name, and the answer points into that file. A member resolves on the type of its receiver (or an extension over it) in the document or file that declares the type, and only when the open file may name it. A bare name inside a type’s body resolves to the type’s own member before a free function. A module-level let resolves wherever the file writes it, and one in another file only where that file’s visibility lets the open file name it. A member of a chained receiver (a.b.c, a.m().n()) resolves through the same walk the hover uses, so it lands on its declaration too, and so does a qualified chain: sub.Calc lands on the type sub/ declares, and a chain whose head is a local binding on that binding’s member. A name the compiler would refuse as ambiguous, or one no visible declaration carries, answers null.
textDocument/completion Members after . (the trigger character), and while a partial member name is being typed: fields, methods, static functions and enum cases. The receiver may be a type name, self or Self, a field of the enclosing type, a for … in loop variable, a local whose type is evident — including one bound by a call or by a try … otherwise — a chain of any of these (a.b.c, a.m().n()), a receiver whose declared type is a generic-instance type alias, resolved to the base it names, an element taken out of a generic container (try xs.get(0)), a field or method of a type declared in another file of the project, or a service handle, whose surface is its service’s messages plus shutdown and clone — what the compiler accepts on a handle — and not the synthesized companion’s own field. A type the buffer declares is answered from the buffer, including the members an extension over it adds; inside an extension over a type the buffer does not declare, the offered members are that type’s own together with the extension’s. Each offered member is one the compiler lets the open file name: the member’s tier and its type’s tier are applied, a field with no tier keyword is offered inside its own type’s body, and the raw surface (.managed, Promise.inner) is offered to files of stdlib/ and runtime/. There is no completion of bare identifiers.
textDocument/formatting One edit replacing the whole document with maxon fmt’s layout, or null when it is already formatted or fmt would refuse it. insertSpaces: false indents with tabs; true indents with tabSize spaces.
textDocument/documentSymbol The top-level declarations: functions, types, enums, unions, interfaces and extensions. A block whose end '…' the author has not typed yet is left out
textDocument/foldingRange Every closed block spanning more than one line
textDocument/linkedEditingRange A block’s opening name and its end '…' label, edited together
textDocument/rename Renames a declaration’s name and its matching end '…' label. References elsewhere are not renamed.
textDocument/codeAction The quick fixes of the published diagnostics the requested range touches, and an action applying every quick fix of the document when it has two or more (see Quick fixes above)
textDocument/semanticTokens/full Semantic tokens with the legend keyword, type, struct, enum, interface, function, method, variable, parameter, modifier, enumMember, property, string, number, comment, operator, capability and no modifiers. Every reference to a type is type: a type the project, a sibling file or stdlib/ declares, a type the buffer declares, a type parameter, and the compiler’s own __Builtins, __Raw and __DebugStream names and built-in managed types. A local or parameter named like a type is variable. int, float, bool, cstring, byte, the sized integer and float names and Self are type. The word isolated, immutable or mutable qualifying a type is capability

Any other request is answered with JSON-RPC error -32601 (method not found).

maxon/generateIR is a Maxon-specific request, not advertised in the capabilities, that compiles a source text in memory for the host and returns its Target IR. It is what the Compiler Explorer uses.

{ "source": "function main() returns ExitCode\n\treturn 0\nend 'main'\n", "filename": "explorer.maxon" }

Both params are required (otherwise -32602). The result:

{ "ir": "…", "errors": [ { "message": "…", "line": 1, "column": 1 } ] }

ir is the text maxon build --emit-ir writes, and is empty when the compile fails. errors lists every diagnostic with a 1-based line and column. A diagnostic located in another file is placed at line 1, column 1 of the source, and its message is prefixed with where it is: <path>:<line>:<column>: , or <path>: for one that names a file and no position.

maxon/listProjects is a Maxon-specific request, not advertised in the capabilities, that lists the projects the server holds. It is what the VS Code status bar shows. It takes no params. The open documents are grouped by the project root the ladder above resolves each of them to, one entry per distinct root — two files of one project are one entry, and two sibling projects are two:

{ "projects": [ { "rootPath": "/home/me/app", "isSingleFile": false, "fileCount": 12 } ] }

rootPath is that root directory, as a filesystem path in the spelling the root was first reached by — a project opened through a symbolic link and by its physical path is one entry, named by the spelling that reached it first; for a file of stdlib/ or runtime/ it is that tier directory. isSingleFile is true where the ladder roots a document at its own file — a .maxtasks document, or any document no .maxproj marks — and then rootPath is that file and fileCount is 1. A document resolves to a root when its uri spells a filesystem path with a directory above it, so the list can name fewer projects than there are open documents. fileCount is the number of production .maxon sources under that root, whether the open document is a .maxon or a .maxtest file. This request reads the projects the server holds, and counts 0 for a root it holds no build of: a root whose walk or build failed, and a root that has left the held projects until an open or a request builds it again. The answer after a build carries the real count. The projects are listed in path order.

maxon/projectLoading is a Maxon-specific notification the server sends around each build of a project: loading: true immediately before the build and loading: false immediately after it, on every outcome, and each true is followed by its false before the next build begins. A project is built when a document in it opens, and the pair arrives before that document’s textDocument/publishDiagnostics. The pair belongs to a project or library tier root; a single file is checked with no announcement. A project that has left the held projects is built again by the next open or request that needs it, and a build that yields no project is repeated each time the project is needed. A root is held as two views, the production sources and the sources with the test files, and each view’s build is announced, so opening a .maxtest document in a project already loaded for a .maxon one announces the same rootPath again. stdlib/ and runtime/ are announced the same way, once each. rootPath is spelled exactly as maxon/listProjects reports that root. The VS Code status bar turns yellow while any project is loading.

{ "rootPath": "/home/me/app", "loading": true }
Terminal window
maxon dap-server

Speaks the Debug Adapter Protocol over stdin and stdout, with the same Content-Length framing as maxon lsp-server. An option or an argument after the command word is refused with exit 1. It drives the same debugger as maxon debug, so it serves the same hosts; the VS Code extension runs it as its debug adapter.

Requests: initialize, launch, setBreakpoints, setFunctionBreakpoints, configurationDone, threads, stackTrace, scopes, variables, evaluate, continue, next, stepIn, stepOut, pause, disconnect, terminate. Any other request is answered success: false with the message unsupported request: <command>.

launch arguments: program, args, env, cwd, stopOnEntry, maxProcs, trace, stopTimeoutSeconds. stopTimeoutSeconds is a number of seconds, default 10, with a fraction honoured to the millisecond, from 0.001 to 922337203685; maxProcs is a whole number of processors from 1 to 2147483647, passed to the program as MAXON_MAX_PROCS. A value outside its bounds refuses the launch, naming the argument.

Events: initialized, stopped, continued, output, exited, terminated.

One adapter debugs one launch. program is a .maxon file or a project directory, which is built with debug info into the host’s Maxon cache (a failed build refuses the launch with the compiler’s diagnostics), or an executable already built with its sidecar. A .maxtest file is refused by name: a test file’s debug build is maxon test --list --build, and the test binary it builds is the program to give. The program starts at configurationDone; with stopOnEntry it is reported stopped with reason entry before main. As it starts, the adapter removes the debug builds left by servers that have ended; see maxon cache.

  • Breakpoints. setBreakpoints answers each line verified, or unverified with a message — a line with no code, or a condition the debugger cannot evaluate. Breakpoints set while the program runs are armed without stopping it. setFunctionBreakpoints resolves names as break does.
  • Stops. A stopped event carries allThreadsStopped: true and a reason of breakpoint, step, pause, entry, or exception for a trap or a fault. continue, next, stepIn, stepOut and pause are answered at once and the stopped event follows; pause stops every thread, whatever threadId it names.
  • Inspecting. threads lists the green threads, or one thread main in a program without a scheduler. stackTrace includes inlined frames, marked presentationHint: "subtle". variables expands a value’s fields and elements on request, and a value the debugger cannot read is shown as <optimized out>, <not live here>, <read failed> or <layout not described>. evaluate in the watch, hover, clipboard or variables context prints an expression; in the repl context it runs any maxon debug command and answers the transcript.
  • The end. The program’s stdout and stderr arrive as output events; its exit is exited with the exit code, then terminated. After the program has ended, threads, stackTrace, scopes and variables answer empty lists. terminate reaps a program still running. disconnect honours terminateDebuggee: true, and the default when the client omits it, reaps it; false detaches and leaves it running.

Lines and columns are 1-based unless initialize says linesStartAt1 or columnsStartAt1 is false.

Any editor with an LSP client can use the server. Configure it to start the command maxon with the argument lsp-server over stdio for files with the .maxon, .maxproj, .maxtasks and .maxtest extensions (language id maxon), and to send full-document synchronization.