tree-sitter-rust icon indicating copy to clipboard operation
tree-sitter-rust copied to clipboard

feat: Add a content field and element to raw string literals.

Open Natr1x opened this issue 2 years ago • 1 comments

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 avatar Oct 29 '23 19:10 Natr1x

@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.

mkatychev avatar Feb 20 '24 17:02 mkatychev

reworked it in #220

amaanq avatar Apr 07 '24 03:04 amaanq