summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDaniel Polito <[email protected]>2025-11-19 19:01:18 -0300
committerGitHub <[email protected]>2025-11-19 16:01:18 -0600
commite1089bc5dec734a763842adbfa05707ae4611d81 (patch)
tree0b34b169fbb96625eb5393830e15ffb668032b91
parent618c654aa00af5b3b8df638d4e9b791b30223cef (diff)
downloadopencode-e1089bc5dec734a763842adbfa05707ae4611d81.tar.gz
opencode-e1089bc5dec734a763842adbfa05707ae4611d81.zip
Adding LSP: PHP Intelephense (#4504)
Co-authored-by: Aiden Cline <[email protected]>
-rw-r--r--packages/opencode/src/lsp/server.ts40
-rw-r--r--packages/web/src/content/docs/lsp.mdx54
2 files changed, 74 insertions, 20 deletions
diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.ts
index 87edb7c19..efecd0879 100644
--- a/packages/opencode/src/lsp/server.ts
+++ b/packages/opencode/src/lsp/server.ts
@@ -1125,4 +1125,44 @@ export namespace LSPServer {
}
},
}
+
+ export const PHPIntelephense: Info = {
+ id: "php intelephense",
+ extensions: [".php"],
+ root: NearestRoot(["composer.json", "composer.lock", ".php-version"]),
+ async spawn(root) {
+ let binary = Bun.which("intelephense")
+ const args: string[] = []
+ if (!binary) {
+ const js = path.join(Global.Path.bin, "node_modules", "intelephense", "lib", "intelephense.js")
+ if (!(await Bun.file(js).exists())) {
+ if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
+ await Bun.spawn([BunProc.which(), "install", "intelephense"], {
+ cwd: Global.Path.bin,
+ env: {
+ ...process.env,
+ BUN_BE_BUN: "1",
+ },
+ stdout: "pipe",
+ stderr: "pipe",
+ stdin: "pipe",
+ }).exited
+ }
+ binary = BunProc.which()
+ args.push("run", js)
+ }
+ args.push("--stdio")
+ const proc = spawn(binary, args, {
+ cwd: root,
+ env: {
+ ...process.env,
+ BUN_BE_BUN: "1",
+ },
+ })
+ return {
+ process: proc,
+ initialization: {},
+ }
+ },
+ }
}
diff --git a/packages/web/src/content/docs/lsp.mdx b/packages/web/src/content/docs/lsp.mdx
index 13471a254..bfcdb515c 100644
--- a/packages/web/src/content/docs/lsp.mdx
+++ b/packages/web/src/content/docs/lsp.mdx
@@ -11,26 +11,27 @@ 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 |
-| yaml-ls | .yaml, .yml | Auto-installs Red Hat yaml-language-server |
-| 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 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 |
+| yaml-ls | .yaml, .yml | Auto-installs Red Hat yaml-language-server |
+| 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) |
+| php intelephense | .php | Auto-installs for PHP projects |
LSP servers are automatically enabled when one of the above file extensions are detected and the requirements are met.
@@ -106,3 +107,16 @@ You can add custom LSP servers by specifying the command and file extensions:
}
}
```
+
+---
+
+## Additional Information
+
+### PHP Intelephense
+
+PHP Intelephense offers premium features through a license key. Uou can provide a license key by placing (only) the key in a text file at:
+
+- On macOS/Linux: `$HOME/intelephense/licence.txt`
+- On Windows: `%USERPROFILE%/intelephense/licence.txt`
+
+The file should contain only the license key with no additional content.