fix(lsp): add data dir to LSP server detection paths (#992)

OpenCode downloads LSP servers (like clangd) to ~/.local/share/opencode/bin,
but isServerInstalled() only checked ~/.config/opencode/bin. This caused
LSP tools to report servers as 'not installed' even when OpenCode had
successfully downloaded them.

Add ~/.local/share/opencode/bin to the detection paths to match OpenCode's
actual behavior.

Co-authored-by: yimingll <yimingll@users.noreply.github.com>
This commit is contained in:
yimingll 2026-01-23 15:37:40 +08:00 committed by GitHub
parent ec61df8c17
commit 7093583ec5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,7 +2,7 @@ import { existsSync, readFileSync } from "fs"
import { join } from "path"
import { BUILTIN_SERVERS, EXT_TO_LANG, LSP_INSTALL_HINTS } from "./constants"
import type { ResolvedServer, ServerLookupResult } from "./types"
import { getOpenCodeConfigDir } from "../../shared"
import { getOpenCodeConfigDir, getDataDir } from "../../shared"
interface LspEntry {
disabled?: boolean
@ -201,10 +201,12 @@ export function isServerInstalled(command: string[]): boolean {
const cwd = process.cwd()
const configDir = getOpenCodeConfigDir({ binary: "opencode" })
const dataDir = join(getDataDir(), "opencode")
const additionalBases = [
join(cwd, "node_modules", ".bin"),
join(configDir, "bin"),
join(configDir, "node_modules", ".bin"),
join(dataDir, "bin"),
]
for (const base of additionalBases) {