[Feature] 后端启动的语言服务器也能声明一键安装器和工具最低版本(Java 插件改用用户自装 JDT LS 后的契约缺口)

未关闭
#2,057 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃

调研方向

Start with the Core plugin contract and the backend launch response decoding that currently accepts {kind: "tool", tool}; then trace where commandInstallers are limited to systemCommand. The issue describes two contract changes and Java plugin adoption, with related references in backend/src/jdtls.rs and backend/src/launch.rs. Done means the contract README, schema, fixture, and protocol update record are updated, and Java can use installer offers and a JDK 21 minimum.

由索引模型根据 Issue 内容生成。

描述

review: high
Problem to solve / 要解决的问题

Java Support 3.0.0 不再随包附带 Eclipse JDT LS 和 JDK(包从约 250 MiB 降到约 11 MiB),改为使用用户自己安装的 JDT LS,和 Go 插件用用户自己的 gopls 一样。但两者在“缺工具时一键安装”上的体验不一致:

  • Go 插件的语言服务器是 launch.kind: "systemCommand",可以声明 commandInstallers(go install golang.org/x/tools/gopls@latest),用户缺 gopls 时宿主给出安装按钮。
  • Java 插件必须用 launch.kind: "backend"(java.resolveLaunch):JDT LS 的命令行要按安装目录里的 org.eclipse.equinox.launcher_*.jar、config_<平台> 现算,还要拼 Lombok agent、扩展 bundle、工作区数据目录和设置,systemCommand 表达不了。而 Core 当前只把 commandInstallers 用于 systemCommand 启动,后端启动答复缺少命令时,插件只能返回 launch.server_missing 错误加文字说明(brew install jdtls 等),用户得自己去终端安装。

另一个相关缺口:后端答复 executable: {kind: "tool", tool: "jdtls-runtime"} 时不能声明最低版本。JDT LS 需要 JDK 21+,插件目前靠 requiresTools 收到的 tools["jdtls-runtime"].version 自己判断并返回 launch.runtime_too_old;宿主的工具选择和发现结果并不知道这个下限,自动选择也不会跳过低版本。

影响:所有 Java 用户升级到 3.0.0 后首次打开 Java 文件,如果没装 JDT LS,只能看到错误提示,需要离开 IDE 手动安装。

Proposed solution / 建议方案

在 Rust Core 插件契约里补两项能力(具体形状由 Core 设计决定):

  1. 后端启动也能用安装器:允许后端启动的语言服务器在 manifest 里声明 commandInstallers(或在启动函数的错误答复里引用一个已声明的安装器 id),宿主收到对应的 pluginErrorCode(如 launch.server_missing)时提供安装按钮,装完重试 resolveLaunch。Java 插件可以据此提供 brew install jdtls(macOS/Linuxbrew)、scoop install jdtls(Windows)等安装方式。
  2. 后端答复的工具可执行文件可声明最低版本:{kind: "tool", tool: "jdtls-runtime", minimumVersion: "21"},或在 manifest 的工具定义上声明下限,让宿主自动选择时跳过低版本 JDK,并在工具链设置里标出不满足的安装。

改契约时按 CLAUDE.md 在同一个 Core PR 里更新契约 README、schema、fixture 和协议更新记录,再升级 Java 插件使用新能力。

Target platform / 目标平台

Cross-platform / 跨平台

Area / 模块

Extensions / 扩展

Priority / 优先级

P2 / 后续考虑:目前不着急,可安排到后续版本

Alternatives considered / 已考虑的替代方案
  • 继续随包附带 JDT LS 和 JDK:就是 2.x 的做法,每个平台包约 250 MiB,这正是要解决的问题。
  • 插件运行时自己下载 JDT LS:违反插件规则(不得运行时下载,已安装插件包只读),也绕过了宿主的安装授权流程。
  • 把 Java 改成 systemCommand 启动:命令行依赖安装目录里带版本号的 launcher JAR 和平台配置目录,还要写入每次启动的 Equinox 配置副本,静态命令表达不了。

当前 3.0.0 的做法:找不到 JDT LS 时返回 launch.server_missing,错误信息写明安装方式和设置入口;JDK 低于 21 时返回 launch.runtime_too_old。

Additional context / 补充信息
  • Java 插件 PR:Lithe-IDEA/lithe-plugin-java 的 feat/user-jdtls(3.0.0)。查找顺序、错误码见 backend/src/jdtls.rs、backend/src/launch.rs。
  • Go 插件的对照做法:Lithe-IDEA/lithe-plugin-go 的 plugin.json(systemCommand + commandInstallers)。
  • Core 现状:后端启动答复的解码只接受 {kind: "tool", tool},没有版本字段;commandInstallers 只在 systemCommand 启动路径使用。
Checklist / 提交前检查
  • I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复建议。
主要语言
TypeScript
星标
1.8k
派生
151
平均合并
3 小时 48 分钟
30 天内合并 PR
571

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

1lck/Lithe-IDEA 的其他 Issue

查看 1lck/Lithe-IDEA 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。