Commit c1dc17e
authored
Add syntax highlighting for named arguments (#95)
## Summary
Adds syntax highlighting for PHP 8+ named arguments in function/method
calls.
Named arguments like `id:`, `firstName:`, `lastName:` in:
```php
$this->users->map(fn (User $user) => new UserDTO(
id: $user->id,
firstName: $user->first_name,
lastName: $user->last_name,
));
```
Are now highlighted with the `@label` token, which themes can style
distinctly (e.g., JetBrains IDEs use a muted blue for these).
## Implementation
Added a simple tree-sitter query that captures the `name` field of
`argument` nodes:
```scheme
(argument
name: (name) @Label)
```
The tree-sitter-php grammar already exposes the `name` field on
`argument` nodes for named arguments, so no grammar changes are needed.
## Test plan
- [x] Tested locally with `zed: install dev extension`
- [x] Named arguments now highlight correctly in PHP files1 parent 857cad3 commit c1dc17e
1 file changed
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
| |||
0 commit comments