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: (identifier) @_name (#eq? @_name "html")
 20  arguments: (template_string) @injection.content
 21                              (#set! injection.language "html")
 22)
 23
 24(call_expression
 25  function: (identifier) @_name (#eq? @_name "js")
 26  arguments: (template_string (string_fragment) @injection.content
 27                              (#set! injection.language "javascript"))
 28)
 29
 30(call_expression
 31  function: (identifier) @_name (#eq? @_name "json")
 32  arguments: (template_string (string_fragment) @injection.content
 33                              (#set! injection.language "json"))
 34)
 35
 36(call_expression
 37  function: (identifier) @_name (#eq? @_name "sql")
 38  arguments: (template_string (string_fragment) @injection.content
 39                              (#set! injection.language "sql"))
 40)
 41
 42(call_expression
 43  function: (identifier) @_name (#eq? @_name "ts")
 44  arguments: (template_string (string_fragment) @injection.content
 45                              (#set! injection.language "typescript"))
 46)
 47
 48(call_expression
 49  function: (identifier) @_name (#match? @_name "^ya?ml$")
 50  arguments: (template_string (string_fragment) @injection.content
 51                              (#set! injection.language "yaml"))
 52)
 53
 54(call_expression
 55  function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
 56  arguments: (template_string (string_fragment) @injection.content
 57                              (#set! injection.language "graphql"))
 58)
 59
 60(call_expression
 61  function: (identifier) @_name (#match? @_name "^g(raph)?ql$")
 62  arguments: (arguments (template_string (string_fragment) @injection.content
 63                              (#set! injection.language "graphql")))
 64)
 65
 66;; Angular Component template injection
 67(call_expression
 68  function: [
 69    (identifier) @_decorator (#eq? @_decorator "Component")
 70    (member_expression property: (property_identifier) @_decorator (#eq? @_decorator "Component"))
 71  ]
 72  arguments: (arguments (object
 73    (pair
 74      key: (property_identifier) @_prop (#eq? @_prop "template")
 75      value: [
 76        (string) @injection.content
 77        (template_string) @injection.content
 78        (template_string (string_fragment) @injection.content)
 79      ]
 80    )))
 81  (#set! injection.language "angular"))
 82
 83;; Angular Component styles injection
 84(call_expression
 85  function: [
 86    (identifier) @_decorator (#eq? @_decorator "Component")
 87    (member_expression property: (property_identifier) @_decorator (#eq? @_decorator "Component"))
 88  ]
 89  arguments: (arguments (object
 90    (pair
 91      key: (property_identifier) @_prop (#eq? @_prop "styles")
 92      value: [
 93        (string) @injection.content
 94        (template_string) @injection.content
 95        (template_string (string_fragment) @injection.content)
 96        (array (string) @injection.content)
 97        (array (template_string) @injection.content)
 98        (array (template_string (string_fragment)) @injection.content)
 99      ]
100    )))
101  (#set! injection.language "css"))