feat: add ReScript LSP support

pull/17995/head
Abhishek Chorotiya 2026-03-18 00:52:18 +05:30
parent 5a0bfa7061
commit e66b2ea49e
3 changed files with 42 additions and 0 deletions

View File

@ -115,6 +115,8 @@ export const LANGUAGE_EXTENSIONS: Record<string, string> = {
".tfvars": "terraform-vars",
".hcl": "hcl",
".nix": "nix",
".res": "rescript",
".resi": "rescript",
".typ": "typst",
".typc": "typst",
} as const

View File

@ -1930,6 +1930,45 @@ export namespace LSPServer {
},
}
export const ReScript: Info = {
id: "rescript",
extensions: [".res", ".resi"],
root: NearestRoot(["rescript.json", "bsconfig.json"]),
async spawn(root) {
let binary = which("rescript-language-server")
const args: string[] = []
if (!binary) {
const js = path.join(Global.Path.bin, "node_modules", "@rescript", "language-server", "out", "cli.js")
if (!(await Filesystem.exists(js))) {
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
await Process.spawn([BunProc.which(), "install", "@rescript/language-server"], {
cwd: Global.Path.bin,
env: {
...process.env,
BUN_BE_BUN: "1",
},
stdout: "pipe",
stderr: "pipe",
stdin: "pipe",
}).exited
}
binary = BunProc.which()
args.push("run", js)
}
args.push("--stdio")
const proc = spawn(binary, args, {
cwd: root,
env: {
...process.env,
BUN_BE_BUN: "1",
},
})
return {
process: proc,
}
},
}
export const Nixd: Info = {
id: "nixd",
extensions: [".nix"],

View File

@ -35,6 +35,7 @@ OpenCode comes with several built-in LSP servers for popular languages:
| oxlint | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue, .astro, .svelte | `oxlint` dependency in project |
| php intelephense | .php | Auto-installs for PHP projects |
| prisma | .prisma | `prisma` command available |
| rescript | .res, .resi | Auto-installs @rescript/language-server |
| pyright | .py, .pyi | `pyright` dependency installed |
| ruby-lsp (rubocop) | .rb, .rake, .gemspec, .ru | `ruby` and `gem` commands available |
| rust | .rs | `rust-analyzer` command available |