Skip to content

Commit

Permalink
Elixir: update tree-sitter queries (helix-editor#3645)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorlay authored and Shekhinah Memmel committed Dec 11, 2022
1 parent f76227a commit 268734b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
50 changes: 42 additions & 8 deletions runtime/queries/elixir/injections.scm
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
; Elixir Code Comments
((comment) @injection.content
(#set! injection.language "comment"))

; Elixir Regular Expressions
((sigil
(sigil_name) @_sigil_name
(quoted_content) @injection.content)
(#match? @_sigil_name "^(r|R)$")
(#match? @_sigil_name "^(R|r)$")
(#set! injection.language "regex")
(#set! injection.combined))

((sigil
(sigil_name) @_sigil_name
(quoted_content) @injection.content)
(#eq? @_sigil_name "H")
(#set! injection.language "heex")
(#set! injection.combined))

; Elixir Markdown Documentation
(unary_operator
operator: "@"
operand: (call
Expand All @@ -23,3 +19,41 @@
(string (quoted_content) @injection.content)
(sigil (quoted_content) @injection.content)
])) (#set! injection.language "markdown"))

; Zigler Sigils
((sigil
(sigil_name) @_sigil_name
(quoted_content) @injection.content)
(#match? @_sigil_name "^(Z|z)$")
(#set! injection.language "zig")
(#set! injection.combined))

; Jason Sigils
((sigil
(sigil_name) @_sigil_name
(quoted_content) @injection.content)
(#match? @_sigil_name "^(J|j)$")
(#set! injection.language "json")
(#set! injection.combined))

; Phoenix Live View HEEx Sigils
((sigil
(sigil_name) @_sigil_name
(quoted_content) @injection.content)
(#eq? @_sigil_name "H")
(#set! injection.language "heex")
(#set! injection.combined))

; Phoenix Live View Component Macros
(call
(identifier) @_identifier
(arguments
(atom)+
(keywords (pair
((keyword) @_keyword (#eq? @_keyword "doc: "))
[
(string (quoted_content) @injection.content)
(sigil (quoted_content) @injection.content)
]))
(#match? @_identifier "^(attr|slot)$")
(#set! injection.language "markdown")))
2 changes: 1 addition & 1 deletion runtime/queries/elixir/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
(do_block (_)* @test.inside)?)
(#match? @_keyword "^(test|describe)$")) @test.around

(comment) @comment.around @comment.inside
(comment)+ @comment.around @comment.inside

0 comments on commit 268734b

Please sign in to comment.