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

Open
#2,057 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
java, rust, typescript

Research direction

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.

Written by the indexing model from the issue text.

Description

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,确认没有重复建议。
Dominant language
TypeScript
Stars
1.8k
Forks
151
Avg merge
3h 48m
Merged PRs (30d)
571

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 1lck/Lithe-IDEA

All issues in 1lck/Lithe-IDEA

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.