From c9e4edc127a90c3969e1bf5cdeab8892247e9c41 Mon Sep 17 00:00:00 2001 From: Caleb White Date: Thu, 19 Jun 2025 10:42:38 -0500 Subject: feat(blade): update blade parser and queries --- runtime/queries/blade/folds.scm | 3 +- runtime/queries/blade/highlights.scm | 21 ++++++------ runtime/queries/blade/indents.scm | 16 +++++++-- runtime/queries/blade/injections.scm | 66 +++++++++++++++++++++++++++++++----- 4 files changed, 85 insertions(+), 21 deletions(-) (limited to 'runtime/queries/blade') diff --git a/runtime/queries/blade/folds.scm b/runtime/queries/blade/folds.scm index cc081a754..07c1fd86f 100644 --- a/runtime/queries/blade/folds.scm +++ b/runtime/queries/blade/folds.scm @@ -1,5 +1,6 @@ +; inherits: html + [ - (authorization) (conditional) (envoy) (fragment) diff --git a/runtime/queries/blade/highlights.scm b/runtime/queries/blade/highlights.scm index c05d2845f..b20999a5f 100644 --- a/runtime/queries/blade/highlights.scm +++ b/runtime/queries/blade/highlights.scm @@ -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 diff --git a/runtime/queries/blade/indents.scm b/runtime/queries/blade/indents.scm index bd3e84d16..a52bb3697 100644 --- a/runtime/queries/blade/indents.scm +++ b/runtime/queries/blade/indents.scm @@ -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 diff --git a/runtime/queries/blade/injections.scm b/runtime/queries/blade/injections.scm index 12fa9f953..e8a0d708d 100644 --- a/runtime/queries/blade/injections.scm +++ b/runtime/queries/blade/injections.scm @@ -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 +;
+(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 +;
+(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 +; +(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 +; +(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")))) -- cgit v1.2.3-70-g09d2