aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries
diff options
context:
space:
mode:
authorCaleb White <cdwhite3@pm.me>2025-06-19 10:42:38 -0500
committerChristian Clason <ch.clason+github@icloud.com>2025-07-11 17:34:30 +0200
commitc9e4edc127a90c3969e1bf5cdeab8892247e9c41 (patch)
treece134fb785edb1a549f6b17c0100f77c7ca618cd /runtime/queries
parentfeat(ziggy,ziggy-schema): update parser and queries (diff)
downloadnvim-treesitter-c9e4edc127a90c3969e1bf5cdeab8892247e9c41.tar
nvim-treesitter-c9e4edc127a90c3969e1bf5cdeab8892247e9c41.tar.gz
nvim-treesitter-c9e4edc127a90c3969e1bf5cdeab8892247e9c41.tar.bz2
nvim-treesitter-c9e4edc127a90c3969e1bf5cdeab8892247e9c41.tar.lz
nvim-treesitter-c9e4edc127a90c3969e1bf5cdeab8892247e9c41.tar.xz
nvim-treesitter-c9e4edc127a90c3969e1bf5cdeab8892247e9c41.tar.zst
nvim-treesitter-c9e4edc127a90c3969e1bf5cdeab8892247e9c41.zip
feat(blade): update blade parser and queries
Diffstat (limited to 'runtime/queries')
-rw-r--r--runtime/queries/blade/folds.scm3
-rw-r--r--runtime/queries/blade/highlights.scm21
-rw-r--r--runtime/queries/blade/indents.scm16
-rw-r--r--runtime/queries/blade/injections.scm66
4 files changed, 85 insertions, 21 deletions
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
+; <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"))))