feat(blade): update blade parser and queries

This commit is contained in:
Caleb White
2025-06-19 10:42:38 -05:00
committed by Christian Clason
parent 4eb12d7a1f
commit c9e4edc127
5 changed files with 86 additions and 22 deletions

View File

@@ -125,7 +125,7 @@ return {
},
blade = {
install_info = {
revision = 'fbe5f81b54f0f6153961824ce306ffc805134980',
revision = '5dd29dd50fa6c3de0bb5a2d24ec03f99ddb960bf',
url = 'https://github.com/EmranMR/tree-sitter-blade',
},
maintainers = { '@calebdw' },

View File

@@ -1,5 +1,6 @@
; inherits: html
[
(authorization)
(conditional)
(envoy)
(fragment)

View File

@@ -1,15 +1,16 @@
([
; inherits: html
[
(directive)
(directive_start)
(directive_end)
] @tag
(#set! priority 101))
([
(bracket_start)
(bracket_end)
] @tag.delimiter
(#set! priority 101))
((comment) @comment @spell
(#set! priority 101))
[
"{{"
"}}"
"{!!"
"!!}"
"("
")"
] @punctuation.bracket

View File

@@ -1,3 +1,15 @@
(directive_start) @indent.begin
; inherits: html
(directive_end) @indent.end
[
(conditional)
(envoy)
(fragment)
(livewire)
(loop)
(once)
(php_statement)
(section)
(stack)
(switch)
(verbatim)
] @indent.begin

View File

@@ -1,15 +1,65 @@
((text) @injection.content
(#set! injection.combined)
(#set! injection.language html))
; inherits: html
((php_only) @injection.content
(#set! injection.language "php_only"))
((parameter) @injection.content
(#set! injection.include-children)
(#set! injection.language "php_only"))
((text) @injection.content
(#has-ancestor? @injection.content "envoy")
(#set! injection.combined)
(#set! injection.language bash))
((php_only) @injection.content
(#set! injection.combined)
(#set! injection.language php_only))
; Livewire attributes
; <div wire:click="baz++">
(attribute
(attribute_name) @_attr
(#any-of? @_attr "wire:model" "wire:click" "wire:stream" "wire:text" "wire:show")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
((parameter) @injection.content
(#set! injection.language php_only))
; AlpineJS attributes
; <div x-data="{ foo: 'bar' }" x-init="baz()">
(attribute
(attribute_name) @_attr
(#lua-match? @_attr "^x%-%l+")
(#not-any-of? @_attr "x-teleport" "x-ref" "x-transition")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
(attribute
(attribute_name) @_attr
(#lua-match? @_attr "^[:@]%l+")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))
; Blade escaped JS attributes
; <x-foo ::bar="baz" />
(element
(_
(tag_name) @_tag
(#lua-match? @_tag "^x%-%l+")
(attribute
(attribute_name) @_attr
(#lua-match? @_attr "^::%l+")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "javascript"))))
; Blade PHP attributes
; <x-foo :bar="$baz" />
(element
(_
(tag_name) @_tag
(#lua-match? @_tag "^x%-%l+")
(attribute
(attribute_name) @_attr
(#lua-match? @_attr "^:%l+")
(quoted_attribute_value
(attribute_value) @injection.content)
(#set! injection.language "php_only"))))