Add motoko.lite setting to disable the language server - #474
Merged
Conversation
The extension boots a full language server that embeds the moc.js WASM compiler (~8MB bundled) and type-checks every open .mo file on each edit, which is heavy in both compute and memory. While we can't slim that down, we can let users opt out of it. Add a per-workspace `motoko.lite` setting (default false) that skips the language server entirely at activation: startup skips the eager compiler context, the Mops/Vessel/dfx workspace scan, and the typed-AST reparse loop, so the compiler never loads into the extension host. Lightweight features that don't depend on the server keep working - syntax highlighting (TextMate grammar), prettier formatting, snippets, and dfx.json schema validation. The `Motoko: Restart language server` command becomes a no-op with an explanatory message instead of silently failing. Disables in lite mode: diagnostics/type checking, completions, hover, go to definition, references/rename, code actions, signature help, workspace symbols, and the Import Mops Package command. Co-Authored-By: Claude Code <noreply@anthropic.com>
Lite mode was completely silent: the "Motoko Language Server" output channel never exists (the server never starts) and console output would vanish into the shared Extension Host channel. A user who set motoko.lite and forgot would have no signal why half the extension was dead. Add a Motoko log channel (created only in the lite branch) and write a single line when lite mode activates. It appears under Output -> Extension Logs -> Motoko and persists to the Extension Logs folder, so a confused user can find it. Regular mode creates nothing, so there is no footprint. Co-Authored-By: Claude Code <noreply@anthropic.com>
Review found that every 'formatting keeps working in lite mode' claim was wrong: formatting is only provided via connection.onDocumentFormatting in the language server (src/server/handlers.ts), and there is no client-side document formatting provider. So with the server skipped, 'Format Document' / format-on-save is disabled too. Align the copy (package.json description, README setting docs, the lite log line and code comment): formatting moves to the disabled list, and the kept-working list is syntax highlighting, snippets, and dfx.json schema validation. Also note in the README that motoko.lite is workspace-scoped, so a user-level setting has no effect. Co-Authored-By: Claude Code <noreply@anthropic.com>
The re-review flagged two doc issues: - The note claiming a user/remote-level motoko.lite 'has no effect' was wrong: resource-scoped settings are settable at every level, so a user-level value takes effect globally. Reword to say how to opt in everywhere vs. per-workspace. - Advanced Configuration's formatOnSave/defaultFormatter only works while the language server runs; cross-reference lite mode so users following both sections aren't surprised by a silent stop. Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the "heavy compute + memory" experience of the Motoko extension by letting users opt out of the language server entirely via a new per-workspace
motoko.litesetting (defaultfalse).The extension currently boots a full language server that embeds the bundled
moc.jsWASM compiler (~8MB once bundled) and type-checks every open/entry-point.moon each edit. We don't have time to slim that down, so this PR exposes the cheap alternative: skip the server at activation and keep only the features that don't depend on it.Key insight
Syntax highlighting never came from the server — it's the TextMate grammar registered purely via
contributes.grammars. So disabling the server keeps highlighting, snippets, anddfx.jsonschema validation (the built-in JSON validator) while dropping everything that needs the compiler/typed AST. Note that formatting is not kept: it is also server-provided (connection.onDocumentFormatting), so in lite mode format-on-save / Format Document is disabled along with the rest.What changes in lite mode
Keeps working (client-side, ~zero cost):
dfx.jsonschema validation (built-in JSON validator)Disabled (all server-dependent):
Memory/compute win: the language server never starts, so the
motokonpm package +moc.jsWASM compiler never load into the extension host. No workspace scan for Mops/Vessel/dfx, no check queue, no typed-AST reparse loop.Implementation
package.json: newmotoko.litesetting (boolean, scoperesource, defaultfalse); version bumped0.23.6 → 0.24.0src/extension.ts: early-return inactivate()when lite is on;Motoko: Restart language serverbecomes a no-op with an explanatory message instead of silently failingsrc/extension.ts: in lite mode, a single line is written to aMotokolog channel (Output → Extension Logs → Motoko, also persisted to disk) so users who set and forgotmotoko.litecan find why features are missing. The channel is only created in the lite branch — zero footprint in normal mode.README.md: documents lite mode, including the workspace/user scope semantics and that formatter settings only apply while the server runsTakes effect on window reload (documented). No server-side changes.
Verification
npm run compile✅npm run lint✅ (zero warnings)npm test✅ 24 suites / 276 tests all pass🤖 Generated with Claude Code