feat: third party lsp support - #639
Open
fltLi wants to merge 11 commits into
Open
Conversation
fltLi
marked this pull request as draft
August 4, 2026 01:06
This comment was marked as resolved.
This comment was marked as resolved.
fltLi
marked this pull request as ready for review
August 4, 2026 04:31
fltLi
marked this pull request as draft
August 4, 2026 06:52
This comment was marked as resolved.
This comment was marked as resolved.
- Implement textDocument/didSave notification forwarding - Server-side execution of workspace/applyEdit with real file system changes - Add workspace/didChangeConfiguration notification support - Handle workspace/willRenameFiles to perform actual file rename + edits - Provide public methods for triggering didSave / didChangeConfiguration / willRename - Enhance file watcher with pending registration queue and polling fallback - Clean up debug logs and comments This proxy now covers all LSP features that cannot be directly implemented in a browser-only Monaco environment, including file saving, editing, configuration changes, and rename operations.
fltLi
marked this pull request as ready for review
August 6, 2026 12:55
chokidar 5.x is ESM-only and dropped glob expansion in watch(), so the backend proxy forwarding workspace/didChangeWatchedFiles silently watched nothing in the pkg'd artifact. Local dev only worked because node_modules still carried chokidar 3.x. Pin chokidar to ^3.6.0. Refactor the third-party LSP proxy into focused modules and share control-request plumbing with the native server: extract UriMapper, FileWatcherRegistry and WorkspaceEditApplier; add a BaseLanguageServer and a single LanguageServer interface; drop a duplicated didClose forward.
fltLi
marked this pull request as draft
September 5, 2026 09:17
Contributor
Author
|
正在完成人工编写 PR 描述等任务,并审阅和优化相关实现,以便对齐最新文档指出的 AI 代码要求。 |
@monaco-editor/react mounts the editor with its default light theme and creates the model before the vscode services (theme + textmate grammar) finish initializing, so reloading straight into the editor — or a tab the browser discarded/awoke — left it white with plain black text. Gate the editor mount on monaco services being ready, re-apply the vscode editor config on mount and when the page regains visibility, and fix the dark theme id typo in the store (WebGAL Dark -> WebGAL Black).
Add Jest specs for the language-server factory, URI mapping, file-watcher registry, workspace-edit applier, launcher scanner, and the native/third-party servers (34 tests). Remove dead code and defensive branches: gateway debug logging, native config boilerplate, a no-op workspace sync block, and any types on the launcher. Fix workspace/applyEdit rename to read oldUri/newUri per the LSP spec, and use a Dropdown for the language-service selector so no text caret appears. Document the module architecture in Modules/lsp/README.md.
fltLi
marked this pull request as ready for review
September 5, 2026 11:04
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.
概述
为脚本编辑器加入第三方 LSP 支持。
使用者可以在用户数据目录下的
third-party-ls/目录下存放第三方 LSP,每个 LSP 需要包含一个start.js作为启动脚本,并导出:Terre 会自动扫描第三方 LSP 列表,使用者可以在
设置 -> 代码编辑器 -> 语言服务中查看并选择。其中
内置语言服务项为保留的原生实现。动机
目前 WebGAL 社区里有多个 LSP 实现,例如 xiaoxustudio/webgal-language-tools,以及我的 fltLi/webgal-lsp。
这些 LSP 都或多或少在某些方面提供了比 Terre 原生更丰富、多样化的语言服务实现。
如果能在脚本编辑中集成它们,将会为使用者在 Terre 本身完备的功能基础上带来更个性化的使用体验。
实现
后端新增一个 LSP 代理层,把 Monaco 客户端桥接到第三方 LSP 进程;内置与第三方共用同一套
LanguageServer接口,按languageServerId分流。详细设计见packages/terre2/src/Modules/lsp/README.md。ThirdPartyLanguageServer转发除控制请求外的 LSP 消息,并由 chokidar 代理文件监视、UriMapper做 URI 映射、WorkspaceEditApplier落地 applyEdit。测试
本次改动新增 7 个 spec、31 个用例,覆盖工厂分流、URI 映射、文件监视、applyEdit、launcher 扫描以及初始化 / 转发 / 生命周期,本地测试全部通过。
实际编写约 3k 行 WebGAL 脚本使用中暴露的问题均已修复。