@@ -24,3 +24,30 @@
2424 name: (identifier) @_new (#eq? @_new "new"))
2525 arguments: (arguments (raw_string_literal) @injection.content)
2626 (#set! injection.language "regex"))
27+
28+; Highlight SQL in `sqlx::query!()`
29+(macro_invocation
30+ macro: (scoped_identifier
31+ path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
32+ name: (identifier) @_query (#eq? @_query "query"))
33+ (token_tree
34+ ; Only the first argument is SQL
35+ .
36+ [(string_literal) (raw_string_literal)] @injection.content
37+ )
38+ (#set! injection.language "sql"))
39+
40+; Highlight SQL in `sqlx::query_as!()`
41+(macro_invocation
42+ macro: (scoped_identifier
43+ path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
44+ name: (identifier) @_query_as (#eq? @_query_as "query_as"))
45+ (token_tree
46+ ; Only the second argument is SQL
47+ .
48+ ; Allow anything as the first argument in case the user has lower case type
49+ ; names for some reason
50+ (_)
51+ [(string_literal) (raw_string_literal)] @injection.content
52+ )
53+ (#set! injection.language "sql"))