feat: add ReScript LSP support
parent
5a0bfa7061
commit
e66b2ea49e
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"],
|
||||
|
|
|
|||
|
|
@ -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 |
|
||||
|
|
|
|||
Loading…
Reference in New Issue