summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBoston Cartwright <[email protected]>2025-11-11 19:51:33 -0700
committerGitHub <[email protected]>2025-11-11 20:51:33 -0600
commit18260b037bf8d99da52f7179c488bf183850c26e (patch)
tree0f8e85eeb89efd0da8f85d425f29c8530b3a63d6
parentad83dd3ad99cb6ec37c482d7f09485fd3689c420 (diff)
downloadopencode-18260b037bf8d99da52f7179c488bf183850c26e.tar.gz
opencode-18260b037bf8d99da52f7179c488bf183850c26e.zip
feat: add SourceKit LSP support (#1545)
Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Aiden Cline <[email protected]>
-rw-r--r--packages/opencode/src/lsp/server.ts34
-rw-r--r--packages/plugin/package.json2
-rw-r--r--packages/sdk/js/package.json2
-rw-r--r--packages/web/src/content/docs/lsp.mdx37
4 files changed, 55 insertions, 20 deletions
diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.ts
index 1132bbc7c..d9fff5b11 100644
--- a/packages/opencode/src/lsp/server.ts
+++ b/packages/opencode/src/lsp/server.ts
@@ -547,6 +547,40 @@ export namespace LSPServer {
},
}
+ export const SourceKit: Info = {
+ id: "sourcekit-lsp",
+ extensions: [".swift", ".objc", "objcpp"],
+ root: NearestRoot(["Package.swift", "*.xcodeproj", "*.xcworkspace"]),
+ async spawn(root) {
+ // Check if sourcekit-lsp is available in the PATH
+ // This is installed with the Swift toolchain
+ const sourcekit = Bun.which("sourcekit-lsp")
+ if (sourcekit) {
+ return {
+ process: spawn(sourcekit, {
+ cwd: root,
+ }),
+ }
+ }
+
+ // If sourcekit-lsp not found, check if xcrun is available
+ // This is specific to macOS where sourcekit-lsp is typically installed with Xcode
+ if (!Bun.which("xcrun")) return
+
+ const lspLoc = await $`xcrun --find sourcekit-lsp`.quiet().nothrow()
+
+ if (lspLoc.exitCode !== 0) return
+
+ const bin = lspLoc.text().trim()
+
+ return {
+ process: spawn(bin, {
+ cwd: root,
+ }),
+ }
+ },
+ }
+
export const RustAnalyzer: Info = {
id: "rust",
root: async (root) => {
diff --git a/packages/plugin/package.json b/packages/plugin/package.json
index 4aac8c25b..c9b2a0e97 100644
--- a/packages/plugin/package.json
+++ b/packages/plugin/package.json
@@ -24,4 +24,4 @@
"typescript": "catalog:",
"@typescript/native-preview": "catalog:"
}
-} \ No newline at end of file
+}
diff --git a/packages/sdk/js/package.json b/packages/sdk/js/package.json
index f556154f2..d6da3b763 100644
--- a/packages/sdk/js/package.json
+++ b/packages/sdk/js/package.json
@@ -26,4 +26,4 @@
"publishConfig": {
"directory": "dist"
}
-} \ No newline at end of file
+}
diff --git a/packages/web/src/content/docs/lsp.mdx b/packages/web/src/content/docs/lsp.mdx
index 97aadab57..1cd1d8258 100644
--- a/packages/web/src/content/docs/lsp.mdx
+++ b/packages/web/src/content/docs/lsp.mdx
@@ -11,24 +11,25 @@ OpenCode integrates with your Language Server Protocol (LSP) to help the LLM int
OpenCode comes with several built-in LSP servers for popular languages:
-| LSP Server | Extensions | Requirements |
-| ---------- | ---------------------------------------------------- | ------------------------------------------------------------ |
-| typescript | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts | `typescript` dependency in project |
-| deno | .ts, .tsx, .js, .jsx, .mjs | `deno` command available (auto-detects deno.json/deno.jsonc) |
-| eslint | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue | `eslint` dependency in project |
-| gopls | .go | `go` command available |
-| ruby-lsp | .rb, .rake, .gemspec, .ru | `ruby` and `gem` commands available |
-| pyright | .py, .pyi | `pyright` dependency installed |
-| elixir-ls | .ex, .exs | `elixir` command available |
-| zls | .zig, .zon | `zig` command available |
-| csharp | .cs | `.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 |
-| svelte | .svelte | Auto-installs for Svelte projects |
-| astro | .astro | Auto-installs for Astro projects |
-| jdtls | .java | `Java SDK (version 21+)` installed |
-| lua-ls | .lua | Auto-installs for Lua projects |
+| LSP Server | Extensions | Requirements |
+| ------------- | ---------------------------------------------------- | ------------------------------------------------------------ |
+| typescript | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts | `typescript` dependency in project |
+| deno | .ts, .tsx, .js, .jsx, .mjs | `deno` command available (auto-detects deno.json/deno.jsonc) |
+| eslint | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue | `eslint` dependency in project |
+| gopls | .go | `go` command available |
+| ruby-lsp | .rb, .rake, .gemspec, .ru | `ruby` and `gem` commands available |
+| pyright | .py, .pyi | `pyright` dependency installed |
+| elixir-ls | .ex, .exs | `elixir` command available |
+| zls | .zig, .zon | `zig` command available |
+| csharp | .cs | `.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 |
+| svelte | .svelte | Auto-installs for Svelte projects |
+| astro | .astro | Auto-installs for Astro projects |
+| jdtls | .java | `Java SDK (version 21+)` installed |
+| lua-ls | .lua | Auto-installs for Lua projects |
+| sourcekit-lsp | .swift, .objc, .objcpp | `swift` installed (`xcode` on macOS) |
LSP servers are automatically enabled when one of the above file extensions are detected and the requirements are met.