Skip to content

Commit

Permalink
feat(php): highlight PHPDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
claytonrcarter committed May 14, 2024
1 parent d1ee2d0 commit 943365e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions extensions/php/extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ language_ids = { PHP = "php"}
repository = "https://github.com/tree-sitter/tree-sitter-php"
commit = "8ab93274065cbaf529ea15c24360cfa3348ec9e4"
path = "php"

[grammars.phpdoc]
repository = "https://github.com/claytonrcarter/tree-sitter-phpdoc"
commit = "1d0e255b37477d0ca46f1c9e9268c8fa76c0b3fc"
4 changes: 4 additions & 0 deletions extensions/php/languages/php/injections.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
((text) @content
(#set! "language" "html")
(#set! "combined"))

((comment) @content
(#match? @content "^/\\*\\*[^*]")
(#set! "language" "phpdoc"))
9 changes: 9 additions & 0 deletions extensions/php/languages/phpdoc/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name = "PHPDoc"
grammar = "phpdoc"
autoclose_before = "]})>"
brackets = [
{ start = "{", end = "}", close = true, newline = false },
{ start = "[", end = "]", close = true, newline = false },
{ start = "(", end = ")", close = true, newline = false },
{ start = "<", end = ">", close = true, newline = false },
]
13 changes: 13 additions & 0 deletions extensions/php/languages/phpdoc/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(tag_name) @keyword

(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

0 comments on commit 943365e

Please sign in to comment.