tree-sitter-rust
tree-sitter-rust copied to clipboard
feat: Add a content field and element to raw string literals.
This makes it possible to use language injection for this content. Which is useful since this is something that raw string literals are often used for.
A query like the following could for example be used to provide sql highlighting when using sqlx:
; extends
((macro_invocation
macro: (scoped_identifier
path: (identifier) @macropath (#eq? @macropath "sqlx")
name: (identifier) @macroname)
(token_tree
(raw_string_literal
content: (_) @injection.content)))
(#set! injection.language "sql")
)
Note: I have not ran tree-sitter-cli generate in order to keep the commit smaller for review purposes.
If you are interested in merging this but want me to change or add something (or run that code generation) then I am willing to do so.
@Natr1x what else needs to get done for this PR to move out of draft. This would be extremely useful for sql injections and would remove #offset! guesswork.
reworked it in #220