injections.scm

  1(((comment) @_jsdoc_comment
  2  (#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @injection.content
  3  (#set! injection.language "jsdoc"))
  4
  5(((comment) @reference
  6  (#match? @reference "^///\\s+<reference\\s+types=\"\\S+\"\\s*/>\\s*$")) @injection.content
  7  (#set! injection.language "html"))
  8
  9((regex) @injection.content
 10  (#set! injection.language "regex"))
 11
 12(call_expression
 13  function: (identifier) @_name (#eq? @_name "css")
 14  arguments: (template_string (string_fragment) @injection.content
 15                              (#set! injection.language "css"))
 16)
 17
 18(call_expression
 19  function: (member_expression
 20    object: (identifier) @_obj (#eq? @_obj "styled")
 21    property: (property_identifier))
 22  arguments: (template_string (string_fragment) @injection.content
 23                              (#set! injection.language "css"))
 24)
 25
 26(call_expression
 27  function: (call_expression
 28    function: (identifier) @_name (#eq? @_name "styled"))
 29  arguments: (template_string (string_fragment) @injection.content
 30                              (#set! injection.language "css"))
 31)
 32
 33(call_expression
 34  function: (identifier) @_name (#eq? @_name "html")
 35  arguments: (template_string) @injection.content
 36                              (#set! injection.language "html")
 37)
 38
 39(call_expression
 40  function: (identifier) @_name (#eq? @_name "js")
 41  arguments: (template_string (string_fragment) @injection.content
 42                              (#set! injection.language "javascript"))
 43)
 44
 45(call_expression
 46  function: (identifier) @_name (#eq? @_name "json")
 47  arguments: (template_string (string_fragment) @injection.content
 48                              (#set! injection.language "json"))
 49)
 50
 51(call_expression
 52  function: (identifier) @_name (#eq? @_name "sql")
 53  arguments: (template_string (string_fragment) @injection.content
 54                              (#set! injection.language "sql"))
 55)
 56
 57(call_expression
 58  function: (identifier) @_name (#eq? @_name "ts")
 59  arguments: (template_string (string_fragment) @injection.content
 60                              (#set! injection.language "typescript"))
 61)
 62
 63(call_expression
 64  function: (identifier) @_name (#match? @_name "^ya?ml$")
 65  arguments: (template_string (string_fragment) @injection.content
 66                              (#set! injection.language "yaml"))
 67)
 68
 69(call_expression
 70  function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
 71  arguments: (template_string (string_fragment) @injection.content
 72                              (#set! injection.language "graphql"))
 73)
 74
 75(call_expression
 76  function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
 77  arguments: (arguments (template_string (string_fragment) @injection.content
 78                              (#set! injection.language "graphql")))
 79)
 80
 81;; Angular Component template injection
 82(call_expression
 83  function: [
 84    (identifier) @_decorator (#eq? @_decorator "Component")
 85    (member_expression property: (property_identifier) @_decorator (#eq? @_decorator "Component"))
 86  ]
 87  arguments: (arguments (object
 88    (pair
 89      key: (property_identifier) @_prop (#eq? @_prop "template")
 90      value: [
 91        (string) @injection.content
 92        (template_string) @injection.content
 93        (template_string (string_fragment) @injection.content)
 94      ]
 95    )))
 96  (#set! injection.language "angular"))
 97
 98;; Angular Component styles injection
 99(call_expression
100  function: [
101    (identifier) @_decorator (#eq? @_decorator "Component")
102    (member_expression property: (property_identifier) @_decorator (#eq? @_decorator "Component"))
103  ]
104  arguments: (arguments (object
105    (pair
106      key: (property_identifier) @_prop (#eq? @_prop "styles")
107      value: [
108        (string) @injection.content
109        (template_string) @injection.content
110        (template_string (string_fragment) @injection.content)
111        (array (string) @injection.content)
112        (array (template_string) @injection.content)
113        (array (template_string (string_fragment)) @injection.content)
114      ]
115    )))
116  (#set! injection.language "css"))