diff options
| author | Yihui Khuu <[email protected]> | 2025-07-26 02:17:06 +1000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-25 12:17:06 -0400 |
| commit | 613b5fbe4814397e8e874fa24a3c98f4e3ce2e4f (patch) | |
| tree | 32296729fa0e958fdc925395860a817b489f0d02 | |
| parent | 7ed05962dbbac9957449d98192b7898bf8512b82 (diff) | |
| download | opencode-613b5fbe4814397e8e874fa24a3c98f4e3ce2e4f.tar.gz opencode-613b5fbe4814397e8e874fa24a3c98f4e3ce2e4f.zip | |
feat: add csharp lsp (#1312)
| -rw-r--r-- | packages/opencode/src/lsp/server.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.ts index 8c843fea1..f4648f0c2 100644 --- a/packages/opencode/src/lsp/server.ts +++ b/packages/opencode/src/lsp/server.ts @@ -322,4 +322,43 @@ export namespace LSPServer { } }, } + + export const CSharp: Info = { + id: "csharp", + root: NearestRoot([".sln", ".csproj", "global.json"]), + extensions: [".cs"], + async spawn(_, root) { + let bin = Bun.which("csharp-ls", { + PATH: process.env["PATH"] + ":" + Global.Path.bin, + }) + if (!bin) { + if (!Bun.which("dotnet")) { + log.error(".NET SDK is required to install csharp-ls") + return + } + + log.info("installing csharp-ls via dotnet tool") + const proc = Bun.spawn({ + cmd: ["dotnet", "tool", "install", "csharp-ls", "--tool-path", Global.Path.bin], + stdout: "pipe", + stderr: "pipe", + stdin: "pipe", + }) + const exit = await proc.exited + if (exit !== 0) { + log.error("Failed to install csharp-ls") + return + } + + bin = path.join(Global.Path.bin, "csharp-ls" + (process.platform === "win32" ? ".exe" : "")) + log.info(`installed csharp-ls`, { bin }) + } + + return { + process: spawn(bin, { + cwd: root, + }), + } + }, + } } |
