The open source coding agent.
TypeScript
Adding LSP: PHP Intelephense (#4504)
Daniel Politoe1089bc5dec7
diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.tsindex 87edb7c1905..efecd087910 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.mdxindex 13471a25468..bfcdb515cfd 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 intOpenCode 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.