From 683059018326e3cc5a77c31eb87c3302472789d9 Mon Sep 17 00:00:00 2001 From: Nalin Singh <38408670+nalin-singh@users.noreply.github.com> Date: Mon, 15 Dec 2025 22:22:16 +0530 Subject: [PATCH] feat: add F# language server support (#5549) --- packages/opencode/src/lsp/server.ts | 40 +++++++++++++++++++++++++++ packages/web/src/content/docs/lsp.mdx | 1 + 2 files changed, 41 insertions(+) diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.ts index e3e3fdf7d..bd959184b 100644 --- a/packages/opencode/src/lsp/server.ts +++ b/packages/opencode/src/lsp/server.ts @@ -610,6 +610,46 @@ export namespace LSPServer { }, } + export const FSharp: Info = { + id: "fsharp", + root: NearestRoot([".sln", ".fsproj", "global.json"]), + extensions: [".fs", ".fsi", ".fsx", ".fsscript"], + async spawn(root) { + let bin = Bun.which("fsautocomplete", { + PATH: process.env["PATH"] + ":" + Global.Path.bin, + }) + if (!bin) { + if (!Bun.which("dotnet")) { + log.error(".NET SDK is required to install fsautocomplete") + return + } + + if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return + log.info("installing fsautocomplete via dotnet tool") + const proc = Bun.spawn({ + cmd: ["dotnet", "tool", "install", "fsautocomplete", "--tool-path", Global.Path.bin], + stdout: "pipe", + stderr: "pipe", + stdin: "pipe", + }) + const exit = await proc.exited + if (exit !== 0) { + log.error("Failed to install fsautocomplete") + return + } + + bin = path.join(Global.Path.bin, "fsautocomplete" + (process.platform === "win32" ? ".exe" : "")) + log.info(`installed fsautocomplete`, { bin }) + } + + return { + process: spawn(bin, { + cwd: root, + }), + } + }, + } + export const SourceKit: Info = { id: "sourcekit-lsp", extensions: [".swift", ".objc", "objcpp"], diff --git a/packages/web/src/content/docs/lsp.mdx b/packages/web/src/content/docs/lsp.mdx index 236b4db82..ad2085d81 100644 --- a/packages/web/src/content/docs/lsp.mdx +++ b/packages/web/src/content/docs/lsp.mdx @@ -22,6 +22,7 @@ OpenCode comes with several built-in LSP servers for popular languages: | elixir-ls | .ex, .exs | `elixir` command available | | zls | .zig, .zon | `zig` command available | | csharp | .cs | `.NET SDK` installed | +| fsharp | .fs, .fsi, .fsx, .fsscript | `.NET SDK` installed | | vue | .vue | Auto-installs for Vue projects | | rust | .rs | `rust-analyzer` command available | | clangd | .c, .cpp, .cc, .cxx, .c++, .h, .hpp, .hh, .hxx, .h++ | Auto-installs for C/C++ projects |