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
php: Highlight PHPDoc comments #11695
Conversation
78ab25f
to
65b8dd7
Compare
@@ -1,3 +1,7 @@ | |||
((text) @content | |||
(#set! "language" "html") | |||
(#set! "combined")) | |||
|
|||
((comment) @content | |||
(#match? @content "^/\\*\\*[^*]") |
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.
Technically, phpdoc comments must start with /**
, so this prevents line comments and block comments that only start with /*
, or "banner" comments like /***********/
from being highlighted.
@@ -0,0 +1,13 @@ | |||
(tag_name) @keyword |
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.
This was copied from the jsdoc injection: https://github.com/zed-industries/zed/blob/main/crates/languages/src/jsdoc/highlights.scm#L1
(tag (variable_name) @variable) | ||
(variable_name "$" @operator) | ||
|
||
(tag | ||
(tag_name) @keyword | ||
(#eq? @keyword "@method") | ||
(name) @function.method) | ||
|
||
(primitive_type) @type.builtin | ||
(named_type (name) @type) @type | ||
(named_type (qualified_name) @type) @type |
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.
Most of these were copied from the php highligts: https://github.com/zed-industries/zed/blob/main/extensions/php/languages/php/highlights.scm#L6-L9
The @method
highlight was taken from neovim, and allows the highlighting of @method bool insufficient()
to match that of function insufficient()
.
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.
BTW the neovim highlight queries are at https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/phpdoc/highlights.scm. I don't know or use neovim, but I found that most of them were more specific than was needed just to get highlighting working (except for @method
as mentioned above)
65b8dd7
to
943365e
Compare
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!
This PR bumps the PHP extension to v0.0.3. Changes: - #11695 Release Notes: - N/A
This adds highlighting of phpdoc tags and PHP types to phpdoc comments, using [tree-sitter-phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc) (maintained by yours me, and also in use by neovim). <table> <tr> <td> <strong>Before</strong> <img src="https://github.com/zed-industries/zed/assets/1420419/bae4c502-8a2c-4399-893f-fcff4e5797b6"> </td> <td> <strong>After</strong> <img src="https://github.com/zed-industries/zed/assets/1420419/8848e9fb-61a0-4938-a118-7041da9589c0"> </td> </tr> </table> Release Notes: - N/A
This PR bumps the PHP extension to v0.0.3. Changes: - zed-industries#11695 Release Notes: - N/A
This adds highlighting of phpdoc tags and PHP types to phpdoc comments, using tree-sitter-phpdoc (maintained by yours me, and also in use by neovim).
Release Notes: