-
Notifications
You must be signed in to change notification settings - Fork 19
Add syntax highlighting for named arguments #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
MrSubidubi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
Can you quickly elaborate why this shoud be highlighted as label? From an initial view, this seems unintuitive to me, but I might be lacking context here. Thanks!
Hello @MrSubidubi, you are welcome! And thanks for questioning this. The ideal semantic token would be
Alternatively, this could be an argument for Zed to support Source: https://zed.dev/docs/extensions/languages#syntax-highlighting The documentation provides a comprehensive list of captures supported by themes, and the only variable-related captures listed are:
|
|
Thanks for the detailed context! Sadly the documentation is outdated in that regard, we have quite a few |
|
Done @MrSubidubi! |
MrSubidubi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and nice improvement. Thanks!
## Summary Adds three syntax highlighting captures that are used across multiple language definitions but were missing from the documentation table in `docs/src/extensions/languages.md`. ## Added Captures | Capture | Used In | |---------|---------| | `@constant.builtin` | C, Go, C++, YAML, TSX | | `@type.builtin` | C++, Python, Rust, JavaScript, TSX | | `@variable.parameter` | TypeScript, JavaScript, Python, Rust, TSX, Diff | ## Context While working on a [PR to add named argument highlighting to the PHP extension](zed-extensions/php#95), I initially used `@label` because the documentation didn't list `@variable.parameter`. A reviewer pointed out that `@variable.parameter` is actually supported and preferred - the docs were just outdated. This PR fixes that documentation gap. Release Notes: - N/A
Summary
Adds syntax highlighting for PHP 8+ named arguments in function/method calls.
Named arguments like
id:,firstName:,lastName:in:Are now highlighted with the
@labeltoken, 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
namefield ofargumentnodes:The tree-sitter-php grammar already exposes the
namefield onargumentnodes for named arguments, so no grammar changes are needed.Test plan
zed: install dev extension