php: Add syntax highlighting for Intelephense completions (#18774)

Release Notes:

- N/A

This PR introduces syntax highlighting for intelephense autocomple. The
styling was selected to roughly match PHPStorm's default scheme.

Please note that I'm not very familiar with writing Rust, but I'm happy
to adapt to any requested changes!

## Examples

### Object attributes, methods and constants

![Screenshot 2024-10-06 at 13 38
03](https://github.com/user-attachments/assets/a91634ff-0f2e-41f0-b548-ecb09c40947c)
![Screenshot 2024-10-06 at 13 38
11](https://github.com/user-attachments/assets/b6f179f4-898b-4d82-9d36-a3e82328325c)

### Typed enum members

![Screenshot 2024-10-06 at 13 38
53](https://github.com/user-attachments/assets/7133b981-4f68-4210-b233-403cdf3ec9bb)
![Screenshot 2024-10-06 at 13 38
41](https://github.com/user-attachments/assets/2e806f3d-3538-45f2-b075-b8be5902b786)

### Variables

Includes altered highlighting for [reserved variable
names](https://www.php.net/manual/en/reserved.variables.php).

![Screenshot 2024-10-06 at 13 39
30](https://github.com/user-attachments/assets/be426eb8-5879-432d-b302-391c2c68a7cb)

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
Roman ZippandMarshall Bowers authored and GitHub committed 2024-10-06 10:11:21 -04:00
1 parent 8376dd2011
commit 200b2bf70a
2 files changed
+116

No files matched your search

+14
View File
@@ -1,5 +1,6 @@
mod language_servers;
use zed::CodeLabel;
use zed_extension_api::{self as zed, serde_json, LanguageServerId, Result};
use crate::language_servers::{Intelephense, Phpactor};
@@ -53,6 +54,19 @@ impl zed::Extension for PhpExtension {
Ok(None)
}
fn label_for_completion(
&self,
language_server_id: &zed::LanguageServerId,
completion: zed::lsp::Completion,
) -> Option<CodeLabel> {
match language_server_id.as_ref() {
Intelephense::LANGUAGE_SERVER_ID => {
self.intelephense.as_ref()?.label_for_completion(completion)
}
_ => None,
}
}
}
zed::register_extension!(PhpExtension);