diff --git a/crates/ide-language/src/lib.rs b/crates/ide-language/src/lib.rs index 8324306f8..28be814e4 100644 --- a/crates/ide-language/src/lib.rs +++ b/crates/ide-language/src/lib.rs @@ -170,6 +170,11 @@ pub struct LanguageServerConfig { /// basedpyright): only used while none of those is installed. #[serde(default)] pub fallback: bool, + /// Names of servers listed after this one that it makes redundant (a PHP server + /// with its own Laravel support replaces `laravel-lsp`): they aren't used while + /// this one serves the file. + #[serde(default)] + pub replaces: Vec, /// What the server is used for (`completion`, `code-action`, `diagnostics`, /// … `FEATURES` in `ide-lsp/src/caps.rs`); empty means everything. The other /// capabilities it announces are ignored, so a refactoring-only server next diff --git a/crates/ide-language/src/registry.rs b/crates/ide-language/src/registry.rs index 3f68042fd..6f12ca20e 100644 --- a/crates/ide-language/src/registry.rs +++ b/crates/ide-language/src/registry.rs @@ -758,7 +758,10 @@ mod tests { let cfg = reg.get(&LanguageId::new("php")).unwrap(); let names: Vec<&str> = cfg.language_servers.iter().map(|s| s.name.as_str()).collect(); // After the fallback: hover, rename and symbols stay with Intelephense. - assert_eq!(names, ["intelephense", "phpactor", "laravel-lsp"]); + assert_eq!(names, ["intelephense", "phpactor", "phoxite", "laravel-lsp"]); + // Phoxite answers the Laravel strings itself. + let phoxite = cfg.language_servers.iter().find(|s| s.name == "phoxite").unwrap(); + assert!(phoxite.fallback && phoxite.replaces == ["laravel-lsp"]); let lsp = cfg.language_servers.iter().find(|s| s.name == "laravel-lsp").unwrap(); assert_eq!(lsp.command.as_str(), "laravel-lsp"); // Its `lsp` command takes no options and speaks over stdio; `--stdio` stops it at startup. diff --git a/crates/ide-lsp/src/lib.rs b/crates/ide-lsp/src/lib.rs index 5e2b8d731..1d05b417f 100644 --- a/crates/ide-lsp/src/lib.rs +++ b/crates/ide-lsp/src/lib.rs @@ -660,15 +660,17 @@ impl LspManager { /// The servers serving `path`: every regular one, and each `fallback` one /// only while all servers listed before it have given up (missing, not /// launchable, or crashed for good). One that requires a root marker serves - /// only files below one, and stands in for no other. + /// only files below one, and stands in for no other. One that a server before + /// it `replaces` is left out while that server serves the file. fn servers_for(&self, language: &LanguageId, path: &Path) -> Vec> { if let Some(servers) = self.arduino_servers(language, path) { return servers; } let mut out = Vec::new(); let mut available_before = false; + let mut replaced: Vec = Vec::new(); for sc in &self.language_servers(language) { - if sc.fallback && available_before { + if (sc.fallback && available_before) || replaced.contains(&sc.name) { continue; } if sc.require_root_marker @@ -678,6 +680,9 @@ impl LspManager { } let server = self.server_for(sc, language, path); available_before |= !sc.require_root_marker && !server.gave_up(); + if !server.gave_up() { + replaced.extend(sc.replaces.iter().cloned()); + } out.push(server); } out @@ -865,7 +870,7 @@ impl LspManager { ide_core::event::ServerStatus::Missing, Some(message), ) { - self.attach_fallbacks(); + self.fallbacks_take_over().await; } return; } @@ -878,7 +883,7 @@ impl LspManager { ide_core::event::ServerStatus::Misconfigured, Some(message), ) { - self.attach_fallbacks(); + self.fallbacks_take_over().await; } return; } @@ -891,7 +896,7 @@ impl LspManager { ide_core::event::ServerStatus::Crashed, Some(message), ) { - self.attach_fallbacks(); + self.fallbacks_take_over().await; } return; } @@ -1039,7 +1044,7 @@ impl LspManager { } } // Gave up (crashed repeatedly, or its build expired): the fallbacks it hid take over. - None => self.attach_fallbacks(), + None => self.fallbacks_take_over().await, } } @@ -3828,8 +3833,16 @@ impl LspManager { } } - /// A server enabled again shadows the fallbacks attached in its place: they - /// leave the open documents, and stop once no document uses them. + /// A server gave up: its fallbacks take over the open documents, and the servers + /// they replace leave. + async fn fallbacks_take_over(&self) { + self.attach_fallbacks(); + self.detach_shadowed_fallbacks().await; + } + + /// A server enabled again shadows the fallbacks attached in its place, and a + /// fallback that took over may replace a server attached earlier: they leave the + /// open documents, and stop once no document uses them. async fn detach_shadowed_fallbacks(&self) { let open: Vec<(DocId, LanguageId, PathBuf)> = self.docs.lock().iter().map(|(id, d)| (*id, d.language.clone(), d.path.clone())).collect(); @@ -3845,6 +3858,7 @@ impl LspManager { .filter(|a| { !wanted.iter().any(|w| w.id == a.server.id) && (configs.iter().any(|c| c.fallback && c.name == a.server.name) + || configs.iter().any(|c| c.replaces.contains(&a.server.name)) || (a.server.name == "clangd" && wanted.iter().any(|s| s.name == arduino::SERVER))) }) .map(|a| a.server.id) diff --git a/crates/ide-lsp/tests/mock_server.rs b/crates/ide-lsp/tests/mock_server.rs index 7c5d639a0..ff88d5e9b 100644 --- a/crates/ide-lsp/tests/mock_server.rs +++ b/crates/ide-lsp/tests/mock_server.rs @@ -264,6 +264,7 @@ fn server_cfg(name: &str) -> LanguageServerConfig { install_hint: Some(format!("install {name}")), connect: None, fallback: false, + replaces: Vec::new(), features: Vec::new(), code_action_kinds: Vec::new(), max_java: None, @@ -3286,6 +3287,67 @@ async fn a_server_requiring_a_root_marker_serves_only_files_below_one() { h.wait_status("alt", ServerStatus::Ready).await; } +/// A server that `replaces` another (a PHP server with its own Laravel support and +/// `laravel-lsp`) keeps it away while it serves, and only then. +#[tokio::test(flavor = "multi_thread")] +async fn a_replaced_server_stays_away_while_its_replacement_serves() { + let servers = [("main", incremental_caps()), ("alt", incremental_caps()), ("framework", incremental_caps())]; + let configure = |cfg: &mut LanguageServerConfig| match cfg.name.as_str() { + "alt" => { + cfg.fallback = true; + cfg.replaces = vec!["framework".into()]; + } + "framework" => cfg.require_root_marker = true, + _ => {} + }; + let h = harness_configured("mock", "mk", &servers, configure); + let disabled: Arc>> = Default::default(); + { + let disabled = disabled.clone(); + h.mgr.set_servers_hook(Box::new(move |_, defined| { + defined.iter().filter(|c| !disabled.lock().contains(&c.name)).cloned().collect() + })); + } + std::fs::write(h.root.join("mock.toml"), "").unwrap(); + let (_, path) = h.open("a.mk", "x"); + let uri = uri_of(&path); + + // The preferred server serves: the framework's server joins it, the alternative stays away. + h.wait_status("main", ServerStatus::Ready).await; + h.wait_status("framework", ServerStatus::Ready).await; + eventually(|| h.launcher.state("framework").docs.lock().contains_key(&uri)).await; + assert!(h.statuses("alt").is_empty()); + + // The alternative takes over: the server it replaces closes the document and stops. + disabled.lock().push("main".into()); + h.mgr.reconfigure().await; + h.wait_status("alt", ServerStatus::Ready).await; + eventually(|| h.launcher.state("alt").docs.lock().contains_key(&uri)).await; + assert!(!h.launcher.state("framework").notified("textDocument/didClose").is_empty()); + assert_eq!(h.statuses("framework").last(), Some(&ServerStatus::Stopped)); + assert_eq!(h.mgr.servers().iter().map(|s| s.name.as_str()).collect::>(), ["alt"]); + + // The preferred server again: the framework's server comes back with it. + disabled.lock().clear(); + h.mgr.reconfigure().await; + h.wait_status("main", ServerStatus::Ready).await; + eventually(|| h.statuses("framework").last() == Some(&ServerStatus::Ready)).await; + assert_eq!(h.statuses("alt").last(), Some(&ServerStatus::Stopped)); + + // A preferred server that is not installed: the alternative replaces the framework's + // server although that one attached first. + let servers = [("ghost", json!({})), ("alt", incremental_caps()), ("framework", incremental_caps())]; + let h = harness_configured("mock", "mk", &servers, configure); + h.launcher.state("ghost").missing.store(true, Ordering::SeqCst); + std::fs::write(h.root.join("mock.toml"), "").unwrap(); + let (_, path) = h.open("a.mk", "x"); + let uri = uri_of(&path); + h.wait_status("ghost", ServerStatus::Missing).await; + h.wait_status("alt", ServerStatus::Ready).await; + eventually(|| h.launcher.state("alt").docs.lock().contains_key(&uri)).await; + eventually(|| !h.mgr.servers().iter().any(|s| s.name == "framework")).await; +} + #[tokio::test(flavor = "multi_thread")] async fn a_fallback_leaves_when_the_preferred_server_is_enabled_again() { let h = harness_with_fallbacks(&[("main", incremental_caps()), ("alt", incremental_caps())], &["alt"]); diff --git a/crates/ide-lsp/tests/real_servers.rs b/crates/ide-lsp/tests/real_servers.rs index 7b1794455..757e9ec02 100644 --- a/crates/ide-lsp/tests/real_servers.rs +++ b/crates/ide-lsp/tests/real_servers.rs @@ -419,6 +419,7 @@ async fn missing_binary_is_reported_with_install_hint() { install_hint: Some("npm i -g nope-ls".into()), connect: None, fallback: false, + replaces: Vec::new(), features: Vec::new(), code_action_kinds: Vec::new(), max_java: None, @@ -692,6 +693,7 @@ async fn typescript_language_server_end_to_end() { install_hint: None, connect: None, fallback: false, + replaces: Vec::new(), features: Vec::new(), code_action_kinds: Vec::new(), max_java: None, @@ -745,6 +747,7 @@ fn npm_server(tools: &Path, name: &str, bin: &str, init: Option LanguageServerConfi }), connect: None, fallback: false, + replaces: Vec::new(), features: Vec::new(), code_action_kinds: Vec::new(), max_java: None, diff --git a/crates/ide-sdk/src/tests.rs b/crates/ide-sdk/src/tests.rs index abe5a174b..06ab11c2d 100644 --- a/crates/ide-sdk/src/tests.rs +++ b/crates/ide-sdk/src/tests.rs @@ -35,6 +35,7 @@ pub(crate) fn server(name: &str) -> LanguageServerConfig { install_hint: None, connect: None, fallback: false, + replaces: Vec::new(), features: Vec::new(), code_action_kinds: Vec::new(), max_java: None, diff --git a/crates/ide-tools/src/platform.rs b/crates/ide-tools/src/platform.rs index 1382f2d3d..a4df96bf7 100644 --- a/crates/ide-tools/src/platform.rs +++ b/crates/ide-tools/src/platform.rs @@ -170,6 +170,28 @@ mod tests { assert_eq!(select_asset(&["laravel-lsp"], rules, LINUX_X64), None); } + #[test] + fn phoxite_assets() { + let names = [ + "phoxite-lsp-aarch64-apple-darwin", + "phoxite-lsp-x86_64-apple-darwin", + "phoxite-lsp-aarch64-unknown-linux-gnu", + "phoxite-lsp-x86_64-unknown-linux-gnu", + "phoxite-lsp-x86_64-pc-windows-msvc.exe", + // Not for any platform here: the musl build, the checksums, the VS Code packages. + "phoxite-lsp-x86_64-unknown-linux-musl", + "phoxite-lsp-x86_64-unknown-linux-gnu.sha256", + "phoxite-lsp-x86_64-pc-windows-msvc.exe.sha256", + "phoxite-linux-x64-0.2.1.vsix", + ]; + let rules = crate::registry::find("phoxite").unwrap().asset_rules(); + assert_eq!(select_asset(&names, rules, MAC_ARM), Some(names[0])); + assert_eq!(select_asset(&names, rules, MAC_X64), Some(names[1])); + assert_eq!(select_asset(&names, rules, LINUX_ARM), Some(names[2])); + assert_eq!(select_asset(&names, rules, LINUX_X64), Some(names[3])); + assert_eq!(select_asset(&names, rules, WIN), Some(names[4])); + } + #[test] fn kmp_lsp_assets_include_the_native_jar_indexer() { let names = [ diff --git a/crates/ide-tools/src/registry.rs b/crates/ide-tools/src/registry.rs index 43160b737..614ddc8d4 100644 --- a/crates/ide-tools/src/registry.rs +++ b/crates/ide-tools/src/registry.rs @@ -458,6 +458,38 @@ pub static TOOLS: &[ToolSpec] = &[ homepage: "https://github.com/laravel/lsp", needs: &[], }, + ToolSpec { + name: "phoxite", + display: "Phoxite", + kind: LanguageServer, + commands: &["phoxite-lsp"], + // Plain binaries per platform (`phoxite-lsp-[.exe]`), each with a + // `.sha256` beside it. + method: Method::Release { + source: ReleaseSource::GitHub { repo: "samehelhawary/phoxite" }, + assets: &[ + rule(Mac, Arm64, "phoxite-lsp-aarch64-apple-darwin"), + rule(Mac, X64, "phoxite-lsp-x86_64-apple-darwin"), + rule(Linux, Arm64, "phoxite-lsp-aarch64-unknown-linux-gnu"), + rule(Linux, X64, "phoxite-lsp-x86_64-unknown-linux-gnu"), + rule(Windows, Arm64, "phoxite-lsp-aarch64-pc-windows-msvc.exe"), + rule(Windows, X64, "phoxite-lsp-x86_64-pc-windows-msvc.exe"), + ], + locate: &[ + "phoxite-lsp", + "phoxite-lsp-aarch64-apple-darwin", + "phoxite-lsp-x86_64-apple-darwin", + "phoxite-lsp-aarch64-unknown-linux-gnu", + "phoxite-lsp-x86_64-unknown-linux-gnu", + "phoxite-lsp-aarch64-pc-windows-msvc", + "phoxite-lsp-x86_64-pc-windows-msvc", + ], + }, + fallback: None, + version: ver("phoxite-lsp"), + homepage: "https://github.com/samehelhawary/phoxite", + needs: &[], + }, ToolSpec { name: "gopls", display: "gopls", diff --git a/docs/en/languages/adding.mdx b/docs/en/languages/adding.mdx index 757a32226..096b3e3e0 100644 --- a/docs/en/languages/adding.mdx +++ b/docs/en/languages/adding.mdx @@ -101,6 +101,7 @@ Each entry starts one LSP server. Servers are listed in order; all regular serve | `settings` | table | Answers the server's `workspace/configuration` requests. Without it, the requested sections are looked up in `initialization-options`. | | `install-hint` | string | Shown when the server is missing and the IDE cannot install it. | | `fallback` | bool | An alternative to the servers listed before it; used only while none of them is installed. | +| `replaces` | string array | Names of servers listed after this one that it makes redundant. They are not used while this server serves the file. Use it for an alternative that covers what an added server does. | | `features` | string array | Use the server only for these features; empty means everything. Values: `completion`, `inline-completion`, `hover`, `signature-help`, `definition`, `declaration`, `type-definition`, `implementation`, `references`, `document-highlight`, `document-symbol`, `workspace-symbol`, `code-action`, `code-lens`, `rename`, `formatting`, `inlay-hint`, `semantic-tokens`, `document-link`, `call-hierarchy`, `type-hierarchy`, `folding-range`, `selection-range`, `diagnostics`. | | `code-action-kinds` | string array | Keep only these code action kinds, matched by prefix (`refactor` keeps `refactor.extract`); empty keeps all. | | `connect` | string | `host:port` of a server that speaks LSP over TCP. See [TCP servers](#tcp-servers). | diff --git a/docs/en/languages/index.mdx b/docs/en/languages/index.mdx index 9eb94e48d..b84eac83e 100644 --- a/docs/en/languages/index.mdx +++ b/docs/en/languages/index.mdx @@ -148,7 +148,7 @@ The table lists every built-in language definition. Server and debugger names in | OCaml | `ocaml` | `.ml`, `.mll`, `.mly` | Yes | Yes | ocamllsp | ocamlearlybird | | OCaml Interface | `ocaml.interface` | `.mli` | Yes | Yes | ocamllsp | — | | Perl | `perl` | `.pl`, `.pm`, `.pod`, `.psgi`, `.cgi` | Yes | — | **perlnavigator** | — | -| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | Yes | Yes | **intelephense** → phpactor + **laravel-lsp** | **php-debug** | +| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | Yes | Yes | **intelephense** → phpactor → **phoxite** + **laravel-lsp** | **php-debug** | | Plain Text | `plaintext` | `.txt`, `.text` | — | — | — | — | | PowerShell | `powershell` | `.ps1`, `.psm1`, `.psd1`, `.pssc`, `.psrc` | Yes | — | powershell-editor-services | — | | Prisma | `prisma` | `.prisma` | Yes | Yes | **prisma-language-server** | — | diff --git a/docs/en/languages/php.mdx b/docs/en/languages/php.mdx index bfc8ad503..66b727555 100644 --- a/docs/en/languages/php.mdx +++ b/docs/en/languages/php.mdx @@ -7,11 +7,14 @@ OpenIDEA highlights PHP files (`.php`, `.phtml`, `.phpt` and older `.php3`–`.p ## Language servers -| Server | When it runs | -| -------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -| `intelephense` | Default. Workspace root: `composer.json`, `.phpactor.json` or `index.php`. | -| `phpactor` | Fallback: used only while Intelephense is not installed. | -| `laravel-lsp` | Laravel projects only (below an `artisan` file): hover, definition and completion inside `config('…')`, `route('…')` and `view('…')`. | +| Server | When it runs | +| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `intelephense` | Default. Workspace root: `composer.json`, `.phpactor.json` or `index.php`. | +| `phpactor` | Fallback: used only while Intelephense is not installed. | +| `phoxite` | Alternative with its own Laravel and Blade support: used while neither server above is installed, or when you pick it in **Settings › Languages & Frameworks › Language Servers**. | +| `laravel-lsp` | Laravel projects only (below an `artisan` file): hover, definition and completion inside `config('…')`, `route('…')` and `view('…')`. | + +While Phoxite serves a project, `laravel-lsp` is not started: Phoxite answers the Laravel strings itself. Intelephense checks code against the project's PHP version (see [Language level](#language-level)) and indexes the stubs and include paths you configure. @@ -25,6 +28,7 @@ When a `.php` file opens and Intelephense is missing, a notification offers **In | ------------------ | ---------------------------------------------------------------------- | | Intelephense | npm (`intelephense`) | | Laravel LSP | GitHub release (`laravel/lsp`) | +| Phoxite | GitHub release (`samehelhawary/phoxite`) | | PHP Debug (Xdebug) | Open VSX (`xdebug.php-debug`); needs Node.js to run | | phpactor | Not installable from the IDE; install it yourself and put it on `PATH` | @@ -77,12 +81,12 @@ See [Debugging](/en/guide/debugging). ## Framework support -- **Laravel**: Laravel LSP for `config()`, `route()` and `view()` strings, and an `artisan serve` configuration. +- **Laravel**: Laravel LSP for `config()`, `route()` and `view()` strings, and an `artisan serve` configuration. With Phoxite as the PHP server, routes, views, config, translations and Eloquent models get completion, navigation and rename from it instead. - **WordPress** and similar platforms: add their stubs under **Additional stubs** and the platform folder under **Include paths**. ## Limitations -- No Blade or Twig template support; only `.php` files get PHP code insight. +- No Blade or Twig template support with Intelephense; only `.php` files get PHP code insight. Phoxite adds code insight in `.blade.php` files, without Blade highlighting. - phpactor is not installed by the IDE. - Run with Coverage is not available for PHPUnit. - Debugging needs the Xdebug extension in your PHP; the IDE does not install it. diff --git a/docs/zh/languages/adding.mdx b/docs/zh/languages/adding.mdx index 02edaff3e..0b22b6507 100644 --- a/docs/zh/languages/adding.mdx +++ b/docs/zh/languages/adding.mdx @@ -101,6 +101,7 @@ root-markers = ["angular.json", "node_modules/@angular/core"] | `settings` | 表 | 用于响应服务器的 `workspace/configuration` 请求。不写时,从 `initialization-options` 中查找请求的配置节。 | | `install-hint` | 字符串 | 服务器缺失且 IDE 无法安装时显示的提示。 | | `fallback` | 布尔 | 作为前面服务器的备选,只在它们都未安装时使用。 | +| `replaces` | 字符串数组 | 排在它后面、因它而变得多余的服务器名称。它为文件提供服务时,这些服务器不会被使用。用于能覆盖附加服务器功能的备选服务器。 | | `features` | 字符串数组 | 只把服务器用于这些功能;为空表示全部。可选值:`completion`、`inline-completion`、`hover`、`signature-help`、`definition`、`declaration`、`type-definition`、`implementation`、`references`、`document-highlight`、`document-symbol`、`workspace-symbol`、`code-action`、`code-lens`、`rename`、`formatting`、`inlay-hint`、`semantic-tokens`、`document-link`、`call-hierarchy`、`type-hierarchy`、`folding-range`、`selection-range`、`diagnostics`。 | | `code-action-kinds` | 字符串数组 | 只保留这些种类的代码操作,按前缀匹配(`refactor` 包含 `refactor.extract`);为空则全部保留。 | | `connect` | 字符串 | 通过 TCP 提供 LSP 的服务器地址 `host:port`,见 [TCP 服务器](#tcp-服务器)。 | diff --git a/docs/zh/languages/index.mdx b/docs/zh/languages/index.mdx index 27944734d..b3f8cbd90 100644 --- a/docs/zh/languages/index.mdx +++ b/docs/zh/languages/index.mdx @@ -143,7 +143,7 @@ IDE 安装工具从不需要 `sudo`。工具装在本地数据目录下 IDE 自 | OCaml | `ocaml` | `.ml`, `.mll`, `.mly` | 是 | 是 | ocamllsp | ocamlearlybird | | OCaml Interface | `ocaml.interface` | `.mli` | 是 | 是 | ocamllsp | — | | Perl | `perl` | `.pl`, `.pm`, `.pod`, `.psgi`, `.cgi` | 是 | — | **perlnavigator** | — | -| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | 是 | 是 | **intelephense** → phpactor + **laravel-lsp** | **php-debug** | +| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | 是 | 是 | **intelephense** → phpactor → **phoxite** + **laravel-lsp** | **php-debug** | | Plain Text | `plaintext` | `.txt`, `.text` | — | — | — | — | | PowerShell | `powershell` | `.ps1`, `.psm1`, `.psd1`, `.pssc`, `.psrc` | 是 | — | powershell-editor-services | — | | Prisma | `prisma` | `.prisma` | 是 | 是 | **prisma-language-server** | — | diff --git a/docs/zh/languages/php.mdx b/docs/zh/languages/php.mdx index d16fccfa0..4870f1eda 100644 --- a/docs/zh/languages/php.mdx +++ b/docs/zh/languages/php.mdx @@ -7,11 +7,14 @@ OpenIDEA 开箱即可高亮 PHP 文件(`.php`、`.phtml`、`.phpt` 以及老 ## 语言服务器 -| 服务器 | 启用条件 | -| -------------- | --------------------------------------------------------------------------------------------------------------------- | -| `intelephense` | 默认。工作区根:`composer.json`、`.phpactor.json` 或 `index.php`。 | -| `phpactor` | 备选:仅在未安装 Intelephense 时使用。 | -| `laravel-lsp` | 仅限 Laravel 项目(`artisan` 文件所在目录之下):在 `config('…')`、`route('…')`、`view('…')` 中提供悬停、跳转和补全。 | +| 服务器 | 启用条件 | +| -------------- | ---------------------------------------------------------------------------------------------------------------------------- | +| `intelephense` | 默认。工作区根:`composer.json`、`.phpactor.json` 或 `index.php`。 | +| `phpactor` | 备选:仅在未安装 Intelephense 时使用。 | +| `phoxite` | 备选,自带 Laravel 和 Blade 支持:仅在以上两个服务器都未安装时使用,或在 **设置 › 语言和框架 › 语言服务器** 中选中它时使用。 | +| `laravel-lsp` | 仅限 Laravel 项目(`artisan` 文件所在目录之下):在 `config('…')`、`route('…')`、`view('…')` 中提供悬停、跳转和补全。 | + +Phoxite 为项目提供服务时不会启动 `laravel-lsp`:Laravel 相关的字符串由 Phoxite 自己处理。 Intelephense 会按项目的 PHP 版本检查代码(见下文“语言级别”),并索引你配置的 stub 和包含路径。 @@ -25,6 +28,7 @@ Intelephense 会按项目的 PHP 版本检查代码(见下文“语言级别 | ------------------ | -------------------------------------------------- | | Intelephense | npm(`intelephense`) | | Laravel LSP | GitHub release(`laravel/lsp`) | +| Phoxite | GitHub release(`samehelhawary/phoxite`) | | PHP Debug (Xdebug) | Open VSX(`xdebug.php-debug`),运行时需要 Node.js | | phpactor | IDE 不负责安装,请自行安装并放到 `PATH` 上 | @@ -77,12 +81,12 @@ PHPUnit 运行配置类型包含 **目标**、**配置文件**、**测试过滤 ## 框架支持 -- **Laravel**:Laravel LSP 支持 `config()`、`route()`、`view()` 中的字符串,并提供 `artisan serve` 运行配置。 +- **Laravel**:Laravel LSP 支持 `config()`、`route()`、`view()` 中的字符串,并提供 `artisan serve` 运行配置。以 Phoxite 作为 PHP 服务器时,路由、视图、配置、翻译和 Eloquent 模型的补全、跳转和重命名改由它提供。 - **WordPress** 等平台:在 **附加存根** 中加入对应 stub,在 **包含路径** 中加入平台代码目录。 ## 已知限制 -- 不支持 Blade 或 Twig 模板,只有 `.php` 文件有 PHP 代码智能。 +- 使用 Intelephense 时不支持 Blade 或 Twig 模板,只有 `.php` 文件有 PHP 代码智能。Phoxite 为 `.blade.php` 文件提供代码智能,但没有 Blade 语法高亮。 - IDE 不会安装 phpactor。 - PHPUnit 不支持使用覆盖率运行。 - 调试需要 PHP 已安装 Xdebug 扩展,IDE 不负责安装。 diff --git a/languages/php.toml b/languages/php.toml index 466cc9ddc..5f15448a0 100644 --- a/languages/php.toml +++ b/languages/php.toml @@ -26,6 +26,17 @@ args = ["language-server"] root-markers = ["composer.json", ".phpactor.json"] install-hint = "Install phpactor (https://phpactor.readthedocs.io/en/master/usage/standalone.html)" +# Alternative with its own Laravel and Blade support. https://github.com/samehelhawary/phoxite +[[language-servers]] +name = "phoxite" +fallback = true +command = "phoxite-lsp" +args = [] +root-markers = ["composer.json", "artisan", "index.php"] +# It answers the Laravel strings itself. +replaces = ["laravel-lsp"] +install-hint = "Install phoxite-lsp from https://github.com/samehelhawary/phoxite/releases and put it on PATH" + # Laravel projects only: hover, definition and completion inside # config('…'), route('…') and view('…'). Last: Intelephense keeps PHP hover, # rename and symbols. https://github.com/laravel/lsp