Skip to content

Commit c1dc17e

Browse files
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 files
1 parent 857cad3 commit c1dc17e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

languages/php/highlights.scm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
(named_type (name) @type) @type
99
(named_type (qualified_name) @type) @type
1010

11+
; Named arguments (PHP 8+)
12+
13+
(argument
14+
name: (name) @variable.parameter)
15+
1116
; Functions
1217

1318
(array_creation_expression "array" @function.builtin)

0 commit comments

Comments
 (0)