aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries/elixir/injections.scm
blob: 4853b84b64d8edf10061f27b1f10556d92927ab2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
; 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)$")
 (#set! injection.language "regex")
 (#set! injection.combined))

; Elixir Markdown Documentation
(unary_operator
  operator: "@"
  operand: (call
  target: ((identifier) @_identifier (#match? @_identifier "^(module|type|short)?doc$"))
    (arguments [
      (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")))