on master help sign in
Also highlight unchecked variants of the sqlx query methods (#6256)
commit3d230e701d4771377a6b3f3b8c68527af29ee066 authorMaxicarlos08 <maxicarlos08@gmail.com> dateFri 10 Mar 2023, 22:57 (4 years ago) parent3907358
1 file changed+27
runtime/queries/rust/injections.scm+27
runtime/queries/rust/injections.scm+27
@@ -51,3 +51,30 @@
5151 [(string_literal) (raw_string_literal)] @injection.content
5252 )
5353 (#set! injection.language "sql"))
54+
55+; Highlight SQL in `sqlx::query_unchecked!()`
56+(macro_invocation
57+ macro: (scoped_identifier
58+ path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
59+ name: (identifier) @_query_as (#eq? @_query_as "query_unchecked"))
60+ (token_tree
61+ ; Only the first argument is SQL
62+ .
63+ [(string_literal) (raw_string_literal)] @injection.content
64+ )
65+ (#set! injection.language "sql"))
66+
67+; Highlight SQL in `sqlx::query_as_unchecked!()`
68+(macro_invocation
69+ macro: (scoped_identifier
70+ path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
71+ name: (identifier) @_query_as (#eq? @_query_as "query_as_unchecked"))
72+ (token_tree
73+ ; Only the second argument is SQL
74+ .
75+ ; Allow anything as the first argument in case the user has lower case type
76+ ; names for some reason
77+ (_)
78+ [(string_literal) (raw_string_literal)] @injection.content
79+ )
80+ (#set! injection.language "sql"))