mirror of https://github.com/helix-editor/helix
Highlight sqlx's `query_scalar{,_unchecked}` macros as SQL (#6793)
* Highlight sqlx's `query_scalar{,_unchecked}` macros as SQL * Update injections.scm * fixup copy-pastapull/6436/merge
parent
8f1671eaaa
commit
6dd5054da4
|
@ -25,11 +25,11 @@
|
||||||
arguments: (arguments (raw_string_literal) @injection.content)
|
arguments: (arguments (raw_string_literal) @injection.content)
|
||||||
(#set! injection.language "regex"))
|
(#set! injection.language "regex"))
|
||||||
|
|
||||||
; Highlight SQL in `sqlx::query!()`
|
; Highlight SQL in `sqlx::query!()`, `sqlx::query_scalar!()`, and `sqlx::query_scalar_unchecked!()`
|
||||||
(macro_invocation
|
(macro_invocation
|
||||||
macro: (scoped_identifier
|
macro: (scoped_identifier
|
||||||
path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
|
path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
|
||||||
name: (identifier) @_query (#eq? @_query "query"))
|
name: (identifier) @_query (#match? @_query "^query(_scalar|_scalar_unchecked)?$"))
|
||||||
(token_tree
|
(token_tree
|
||||||
; Only the first argument is SQL
|
; Only the first argument is SQL
|
||||||
.
|
.
|
||||||
|
@ -37,38 +37,11 @@
|
||||||
)
|
)
|
||||||
(#set! injection.language "sql"))
|
(#set! injection.language "sql"))
|
||||||
|
|
||||||
; Highlight SQL in `sqlx::query_as!()`
|
; Highlight SQL in `sqlx::query_as!()` and `sqlx::query_as_unchecked!()`
|
||||||
(macro_invocation
|
(macro_invocation
|
||||||
macro: (scoped_identifier
|
macro: (scoped_identifier
|
||||||
path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
|
path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
|
||||||
name: (identifier) @_query_as (#eq? @_query_as "query_as"))
|
name: (identifier) @_query_as (#match? @_query_as "^query_as(_unchecked)?$"))
|
||||||
(token_tree
|
|
||||||
; Only the second argument is SQL
|
|
||||||
.
|
|
||||||
; Allow anything as the first argument in case the user has lower case type
|
|
||||||
; names for some reason
|
|
||||||
(_)
|
|
||||||
[(string_literal) (raw_string_literal)] @injection.content
|
|
||||||
)
|
|
||||||
(#set! injection.language "sql"))
|
|
||||||
|
|
||||||
; Highlight SQL in `sqlx::query_unchecked!()`
|
|
||||||
(macro_invocation
|
|
||||||
macro: (scoped_identifier
|
|
||||||
path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
|
|
||||||
name: (identifier) @_query_as (#eq? @_query_as "query_unchecked"))
|
|
||||||
(token_tree
|
|
||||||
; Only the first argument is SQL
|
|
||||||
.
|
|
||||||
[(string_literal) (raw_string_literal)] @injection.content
|
|
||||||
)
|
|
||||||
(#set! injection.language "sql"))
|
|
||||||
|
|
||||||
; Highlight SQL in `sqlx::query_as_unchecked!()`
|
|
||||||
(macro_invocation
|
|
||||||
macro: (scoped_identifier
|
|
||||||
path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
|
|
||||||
name: (identifier) @_query_as (#eq? @_query_as "query_as_unchecked"))
|
|
||||||
(token_tree
|
(token_tree
|
||||||
; Only the second argument is SQL
|
; Only the second argument is SQL
|
||||||
.
|
.
|
||||||
|
|
Loading…
Reference in New Issue