Skip to content

Commit 613b5fb

Browse files
authored
feat: add csharp lsp (anomalyco#1312)
1 parent 7ed0596 commit 613b5fb

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

packages/opencode/src/lsp/server.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,43 @@ export namespace LSPServer {
322322
}
323323
},
324324
}
325+
326+
export const CSharp: Info = {
327+
id: "csharp",
328+
root: NearestRoot([".sln", ".csproj", "global.json"]),
329+
extensions: [".cs"],
330+
async spawn(_, root) {
331+
let bin = Bun.which("csharp-ls", {
332+
PATH: process.env["PATH"] + ":" + Global.Path.bin,
333+
})
334+
if (!bin) {
335+
if (!Bun.which("dotnet")) {
336+
log.error(".NET SDK is required to install csharp-ls")
337+
return
338+
}
339+
340+
log.info("installing csharp-ls via dotnet tool")
341+
const proc = Bun.spawn({
342+
cmd: ["dotnet", "tool", "install", "csharp-ls", "--tool-path", Global.Path.bin],
343+
stdout: "pipe",
344+
stderr: "pipe",
345+
stdin: "pipe",
346+
})
347+
const exit = await proc.exited
348+
if (exit !== 0) {
349+
log.error("Failed to install csharp-ls")
350+
return
351+
}
352+
353+
bin = path.join(Global.Path.bin, "csharp-ls" + (process.platform === "win32" ? ".exe" : ""))
354+
log.info(`installed csharp-ls`, { bin })
355+
}
356+
357+
return {
358+
process: spawn(bin, {
359+
cwd: root,
360+
}),
361+
}
362+
},
363+
}
325364
}

0 commit comments

Comments
 (0)