Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rust injections for c, c++, html, js, py #1526

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions runtime/queries/rust/injections.scm
Original file line number Diff line number Diff line change
@@ -1,14 +1,52 @@
([(line_comment) (block_comment)] @injection.content
(#set! injection.language "comment"))

((macro_invocation
((macro_rule
(token_tree) @injection.content)
(#set! injection.language "rust")
(#set! injection.include-children))

((macro_rule
; inline_c::assert_c
((macro_invocation
macro: (identifier) @_c (#eq? @_c "assert_c")
(token_tree) @injection.content)
(#set! injection.language "rust")
(#set! injection.language "c")
(#set! injection.include-children))

; inline_c::assert_cxx
((macro_invocation
macro: (identifier) @_cxx (#eq? @_cxx "assert_cxx")
(token_tree) @injection.content)
(#set! injection.language "cpp")
(#set! injection.include-children))

; typed_html::html
((macro_invocation
macro: (identifier) @_html (#eq? @_html "html")
(token_tree) @injection.content)
(#set! injection.language "html")
(#set! injection.include-children))

; inline_python::python
; TODO: fix bug where first import is not highlighted
((macro_invocation
macro: (scoped_identifier
name: (identifier) @_python (#eq? @_python "python"))
(token_tree) @injection.content)
(#set! injection.language "python")
(#set! injection.include-children))

((macro_invocation
macro: (identifier) @_python (#eq? @_python "python")
(token_tree) @injection.content)
(#set! injection.language "python")
(#set! injection.include-children))
Comment on lines +32 to +43
Copy link
Contributor Author

@pickfire pickfire Jan 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how can I simplify this so I leave it like this for now.

One is inline_python::python! and one is python!. I think this is probably applicable for others.


; embed_js::inline_js
((macro_invocation
macro: (identifier) @_js (#eq? @_js "include_js")
(token_tree) @injection.content)
(#set! injection.language "javascript")
(#set! injection.include-children))

(call_expression
Expand Down