feat(lsp): sync with OpenCode LSP implementation
- Add 50+ extension mappings to EXT_TO_LANG (Clojure, Erlang, F#, Haskell, Scala, OCaml, etc.) - Add missing BUILTIN_SERVERS: Biome, Oxlint, ty (Python), FSharp, Terraform-ls - Improve isServerInstalled() to check node_modules/.bin, ~/.config/opencode/bin paths - Add Windows .exe extension support for command detection - Fix GitHub issue #118 - LSP servers not being detected 🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -147,11 +147,31 @@ export function isServerInstalled(command: string[]): boolean {
|
||||
if (command.length === 0) return false
|
||||
|
||||
const cmd = command[0]
|
||||
const isWindows = process.platform === "win32"
|
||||
const ext = isWindows ? ".exe" : ""
|
||||
|
||||
const pathEnv = process.env.PATH || ""
|
||||
const paths = pathEnv.split(":")
|
||||
const pathSeparator = isWindows ? ";" : ":"
|
||||
const paths = pathEnv.split(pathSeparator)
|
||||
|
||||
for (const p of paths) {
|
||||
if (existsSync(join(p, cmd))) {
|
||||
if (existsSync(join(p, cmd)) || existsSync(join(p, cmd + ext))) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
const cwd = process.cwd()
|
||||
const additionalPaths = [
|
||||
join(cwd, "node_modules", ".bin", cmd),
|
||||
join(cwd, "node_modules", ".bin", cmd + ext),
|
||||
join(homedir(), ".config", "opencode", "bin", cmd),
|
||||
join(homedir(), ".config", "opencode", "bin", cmd + ext),
|
||||
join(homedir(), ".config", "opencode", "node_modules", ".bin", cmd),
|
||||
join(homedir(), ".config", "opencode", "node_modules", ".bin", cmd + ext),
|
||||
]
|
||||
|
||||
for (const p of additionalPaths) {
|
||||
if (existsSync(p)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user