aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/teal/injections.scm
blob: decb4831c3eeab964a3e116213f49492de62bc0c (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
((function_call
  (index
    (identifier) @_cdef_identifier)
  (arguments
    (string) @injection.content))
  (#eq? @_cdef_identifier "cdef")
  (#lua-match? @injection.content "^[\"']")
  (#offset! @injection.content 0 1 0 -1)
  (#set! injection.language "c"))

((function_call
  (index
    (identifier) @_cdef_identifier)
  (arguments
    (string) @injection.content))
  (#eq? @_cdef_identifier "cdef")
  (#lua-match? @injection.content "^%[%[")
  (#offset! @injection.content 0 2 0 -2)
  (#set! injection.language "c"))

; string.format('...')
((function_call
  (index
    (identifier) @_base
    key: (identifier) @_entry)
  (arguments
    .
    (string) @injection.content))
  (#eq? @_base "string")
  (#eq? @_entry "format")
  (#set! injection.language "printf"))

; ('...'):format()
((function_call
  (method_index
    (parenthesized_expression
      (string) @injection.content)
    key: (identifier) @_func))
  (#eq? @_func "format")
  (#set! injection.language "printf"))

((comment) @injection.content
  (#set! injection.language "comment"))