fix(lsp): Name the running server when it lacks a feature (#201)

ide-lsp returned the same `unavailable` error whether no server was running or a running server didn't implement the request, so the UI said no language server was available, and Invoke Inline Completion said no language server provides inline completion, while jdtls was running fine (it doesn't implement textDocument/inlineCompletion). When servers are running but none supports the feature, the error now names them ("jdtls doesn't support inline completion"), and every explicit action shares one message helper: Invoke Inline Completion, go to declaration / implementation / type declaration, quick documentation, parameter info, rename, reformat, intention actions, highlight usages, call / type hierarchy, find usages, safe delete and workspace symbols. With no server running it still says no language server is available. Background requests while typing stay silent.

Fixes #186

Claude-Session: https://claude.ai/code/session_01Dq6jQQn8ZhRfkkyj3PRutA
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-10-29 10:35:37 +08:00
1 джерело 4410da60a2
коміт c8e3fe9d2e
10 files changed
+148 -14

No files matched your search

+12
Переглянути файл
@@ -34,6 +34,18 @@ export function isCancelled(e: unknown): boolean {
return e instanceof IpcError && e.kind === "cancelled";
}
/** Backend `unavailable` message when servers run but none has the feature: "jdtls doesn't support inline completion". */
const LACKS_FEATURE = /^\S.* doesn't support \S.*$/;
/**
* What to tell the user when a language-server feature is `unavailable`: the
* running server that lacks it, so a working server doesn't read as missing;
* `fallback` when no server is running.
*/
export function unavailableText(e: unknown, fallback = "No language server available"): string {
return e instanceof IpcError && e.kind === "unavailable" && LACKS_FEATURE.test(e.message) ? e.message : fallback;
}
// Ids are shared by every window of the backend and outlive a reload there (a cancel that
// arrives before its request began is remembered), so each page starts at a random point.
let nextId = 1 + Math.floor(Math.random() * 0x7000_0000);
+21 -1
Переглянути файл
@@ -2575,7 +2575,27 @@
"Call Inline Completion": "调用内联补全",
"Inline completion is off for this language": "此语言已关闭内联补全",
"No inline suggestions": "没有内联建议",
"No language server provides inline completion": "没有语言服务器提供内联补全",
"{servers} doesn't support {feature}": "{servers} 不支持{feature}",
"completion": "代码补全",
"inline completion": "内联补全",
"hover": "快速文档",
"signature help": "形参信息",
"go to definition": "转到定义",
"go to declaration": "转到声明",
"go to type definition": "转到类型声明",
"go to implementation": "转到实现",
"find references": "查找用法",
"document highlights": "高亮用法",
"code actions": "代码操作",
"rename": "重命名",
"formatting": "重新格式化代码",
"range formatting": "格式化选中代码",
"inlay hints": "嵌入提示",
"code lens": "代码透镜",
"document links": "文档链接",
"call hierarchy": "调用层次结构",
"type hierarchy": "类型层次结构",
"workspace symbols": "工作区符号",
"Insert Inline Proposal": "插入内联建议",
"Insert Inline Proposal: Next Word": "插入内联建议:下一个单词",
"Hide Inline Proposal": "隐藏内联建议",