feat(lsp): add web worker language servers as defaults#2531
feat(lsp): add web worker language servers as defaults#2531bajrangCoder wants to merge 10 commits into
Conversation
Greptile SummaryThis PR introduces built-in Web Worker-based LSP servers for HTML, CSS/SCSS/Less, JSON/JSONC, and TypeScript/JavaScript, so those languages work out of the box without Alpine, STDIO processes, or WebSocket bridges. The STDIO equivalents are kept but disabled by default for advanced users. Significant infrastructure work accompanies the feature: a generic
Confidence Score: 5/5Safe to merge. The new web-worker runtime is a significant addition but the previous blocking issues (pending-client disposal race, post-crash worker leaks, factory rejection leaving the worker alive, codeAction crash with undefined formatting options) are all addressed in this PR. The remaining findings are minor behavioral quirks. The infrastructure changes are well-structured: AbortController cancellation for in-flight initialization, failTransport/fail() for post-ready crash propagation, workerScope.close() on factory rejection, and idempotent dispose() with a disposed guard. The three findings are non-blocking: inlay hints in HTML use a position-based language check that suppresses results for range-based requests starting before a script tag; completionItem/resolve in the JSON worker ignores the JSONC service; and WEB_WORKER_RUNTIME_ID is duplicated across two modules. Files Needing Attention: src/cm/lsp/workers/html.worker.ts (inlay-hint language check) and src/cm/lsp/workers/json.worker.ts (completionItem/resolve service dispatch). Important Files Changed
Sequence DiagramsequenceDiagram
participant Editor as Editor (CodeMirror)
participant CM as LspClientManager
participant WR as WebWorker Runtime
participant WT as WorkerTransport
participant W as LSP Worker (e.g. html.worker)
participant NW as Nested TS Worker
Editor->>CM: open document (html/css/json/ts)
CM->>WR: selectRuntimeProvider(server)
WR->>WT: "createWorkerTransport({url, configure, hostHandlers})"
WT->>W: new Worker(url)
WT->>W: "postMessage({kind:configure, serverId, rootUri})"
W-->>WT: "postMessage({kind:ready})"
WT-->>CM: ready resolved
CM->>W: initialize (JSON-RPC)
W-->>CM: capabilities
Note over W,NW: HTML worker lazily spawns nested TS sub-worker
Editor->>CM: textDocument/completion
CM->>W: JSON-RPC request
W->>NW: (if JS region) forward request
NW-->>W: result
W-->>CM: JSON-RPC response
CM-->>Editor: completion items
Editor->>CM: close last document for server
CM->>CM: onClientIdle - dispose()
CM->>WT: dispose()
WT->>W: worker.terminate()
Note over NW: nested TS worker terminated by W dispose()
Reviews (8): Last reviewed commit: "fix: dispose" | Re-trigger Greptile |
Summary
Add bundled Web Worker-based language servers as the default LSP experience for users.
HTML, CSS, JSON, JavaScript, and TypeScript now work without requiring Alpine, STDIO processes, manual installation, WebSocket URLs, or launcher bridges. Existing STDIO servers remain available as optional alternatives for advanced users who wants full workspace level stdio based lsp.
Changes
content://locations