Update tree-sitter-blade and queries (#14097)

Co-authored-by: Emran <Emran@MacBook.local>
This commit is contained in:
Emran
2025-07-28 00:29:17 +01:00
committed by GitHub
parent 2f7cc9d0ae
commit 285a7440a3
7 changed files with 120 additions and 15 deletions

View File

@@ -13,7 +13,7 @@
| bibtex | ✓ | | | | | `texlab` |
| bicep | ✓ | | | | | `bicep-langserver` |
| bitbake | ✓ | | | | | `bitbake-language-server` |
| blade | ✓ | | | | | |
| blade | ✓ | | | | | |
| blueprint | ✓ | | | | | `blueprint-compiler` |
| c | ✓ | ✓ | ✓ | ✓ | ✓ | `clangd` |
| c-sharp | ✓ | ✓ | | ✓ | | `OmniSharp` |

View File

@@ -1185,7 +1185,7 @@ roots = ["composer.json", "index.php"]
[[grammar]]
name = "blade"
source = { git = "https://github.com/EmranMR/tree-sitter-blade", rev = "4c66efe1e05c639c555ee70092021b8223d2f440" }
source = { git = "https://github.com/EmranMR/tree-sitter-blade", rev = "59ce5b68e288002e3aee6cf5a379bbef21adbe6c" }
[[language]]
name = "twig"

View File

@@ -1,8 +1,9 @@
; inherits: html
((directive_start) @start
(directive_end) @end.after
(#set! role block))
((bracket_start) @start
(bracket_end) @end
(#set! role block))
(#set! role block))

View File

@@ -1,8 +1,16 @@
(directive) @tag
(directive_start) @tag
(directive_end) @tag
; inherits: html
(directive) @keyword.directive
(directive_start) @keyword.directive
(directive_end) @keyword.directive
(comment) @comment
; merged with blade punctuation
[
(bracket_start)
(bracket_end)
"{{"
"}}"
"{!!"
"!!}"
"("
")"
] @punctuation.bracket

View File

@@ -1,14 +1,108 @@
((text) @injection.content
(#set! injection.combined)
(#set! injection.language "php"))
; inherits: html
; tree-sitter-comment injection
; if available
((comment) @injection.content
(#set! injection.language "comment"))
((php_only) @injection.content
(#set! injection.language "php-only"))
((parameter) @injection.content
(#set! injection.include-children)
(#set! injection.language "php-only"))
((parameter) @injection.content
(#set! injection.include-children) ; You may need this, depending on your editor e.g Helix
(#set! injection.language "php-only"))
; ; Livewire attributes
(attribute
(attribute_name) @_attr
(#any-of? @_attr
"wire:click"
"wire:submit"
"wire:model"
"wire:loading"
"wire:navigate"
"wire:current"
"wire:cloak"
"wire:dirty"
"wire:confirm"
"wire:transition"
"wire:init"
"wire:poll"
"wire:offline"
"wire:ignore"
"wire:replace"
"wire:show"
"wire:stream"
"wire:text"
)
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
; ; See #33
; ; AlpineJS attributes
(attribute
(attribute_name) @_attr
(#match? @_attr "^x-[a-z]+")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
; ; Apline Events
(attribute
(attribute_name) @_attr
(#match? @_attr "^@[a-z]+")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
; ; normal HTML element alpine attributes
(element
(_
(tag_name) @_tag
(#match? @_tag "[^x][^-]")
(attribute
(attribute_name) @_attr
(#match? @_attr "^:[a-z]+")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.combined)
(#set! injection.language "javascript"))))
; ; ; Blade escaped JS attributes
; ; <x-foo ::bar="baz" />
(element
(_
(tag_name) @_tag
(#match? @_tag "^x-[a-z]+")
(attribute
(attribute_name) @_attr
(#match? @_attr "^::[a-z]+")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))))
; ; ; Blade escaped JS attributes
; ; <htmlTag :class="baz" />
(element
(_
(attribute_name) @_attr
(#match? @_attr "^:[a-z]+")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript")))
; Blade PHP attributes
(element
(_
(tag_name) @_tag
(#match? @_tag "^x-[a-z]+")
(attribute
(attribute_name) @_attr
(#match? @_attr "^:[a-z]+")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "php-only"))))

View File

@@ -0,0 +1 @@
; inherits: html

View File

@@ -0,0 +1 @@
; inherits: html