mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-20 09:14:22 +01:00
feat: add SourceKit LSP support (#1545)
Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
This commit is contained in:
committed by
GitHub
parent
ad83dd3ad9
commit
18260b037b
@@ -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 = {
|
export const RustAnalyzer: Info = {
|
||||||
id: "rust",
|
id: "rust",
|
||||||
root: async (root) => {
|
root: async (root) => {
|
||||||
|
|||||||
@@ -24,4 +24,4 @@
|
|||||||
"typescript": "catalog:",
|
"typescript": "catalog:",
|
||||||
"@typescript/native-preview": "catalog:"
|
"@typescript/native-preview": "catalog:"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,4 +26,4 @@
|
|||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"directory": "dist"
|
"directory": "dist"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
OpenCode comes with several built-in LSP servers for popular languages:
|
||||||
|
|
||||||
| LSP Server | Extensions | Requirements |
|
| LSP Server | Extensions | Requirements |
|
||||||
| ---------- | ---------------------------------------------------- | ------------------------------------------------------------ |
|
| ------------- | ---------------------------------------------------- | ------------------------------------------------------------ |
|
||||||
| typescript | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts | `typescript` dependency in project |
|
| 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) |
|
| 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 |
|
| eslint | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue | `eslint` dependency in project |
|
||||||
| gopls | .go | `go` command available |
|
| gopls | .go | `go` command available |
|
||||||
| ruby-lsp | .rb, .rake, .gemspec, .ru | `ruby` and `gem` commands available |
|
| ruby-lsp | .rb, .rake, .gemspec, .ru | `ruby` and `gem` commands available |
|
||||||
| pyright | .py, .pyi | `pyright` dependency installed |
|
| pyright | .py, .pyi | `pyright` dependency installed |
|
||||||
| elixir-ls | .ex, .exs | `elixir` command available |
|
| elixir-ls | .ex, .exs | `elixir` command available |
|
||||||
| zls | .zig, .zon | `zig` command available |
|
| zls | .zig, .zon | `zig` command available |
|
||||||
| csharp | .cs | `.NET SDK` installed |
|
| csharp | .cs | `.NET SDK` installed |
|
||||||
| vue | .vue | Auto-installs for Vue projects |
|
| vue | .vue | Auto-installs for Vue projects |
|
||||||
| rust | .rs | `rust-analyzer` command available |
|
| rust | .rs | `rust-analyzer` command available |
|
||||||
| clangd | .c, .cpp, .cc, .cxx, .c++, .h, .hpp, .hh, .hxx, .h++ | Auto-installs for C/C++ projects |
|
| clangd | .c, .cpp, .cc, .cxx, .c++, .h, .hpp, .hh, .hxx, .h++ | Auto-installs for C/C++ projects |
|
||||||
| svelte | .svelte | Auto-installs for Svelte projects |
|
| svelte | .svelte | Auto-installs for Svelte projects |
|
||||||
| astro | .astro | Auto-installs for Astro projects |
|
| astro | .astro | Auto-installs for Astro projects |
|
||||||
| jdtls | .java | `Java SDK (version 21+)` installed |
|
| jdtls | .java | `Java SDK (version 21+)` installed |
|
||||||
| lua-ls | .lua | Auto-installs for Lua projects |
|
| 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.
|
LSP servers are automatically enabled when one of the above file extensions are detected and the requirements are met.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user