injections.scm

  1((comment) @injection.content
  2  (#set! injection.language "comment"))
  3
  4(((comment) @_jsdoc_comment
  5  (#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @injection.content
  6  (#set! injection.language "jsdoc"))
  7
  8((regex) @injection.content
  9  (#set! injection.language "regex"))
 10
 11(call_expression
 12  function: (identifier) @_name
 13  (#eq? @_name "css")
 14  arguments: (template_string
 15    (string_fragment) @injection.content
 16    (#set! injection.language "css")))
 17
 18(call_expression
 19  function: (member_expression
 20    object: (identifier) @_obj
 21    (#eq? @_obj "styled")
 22    property: (property_identifier))
 23  arguments: (template_string
 24    (string_fragment) @injection.content
 25    (#set! injection.language "css")))
 26
 27(call_expression
 28  function: (call_expression
 29    function: (identifier) @_name
 30    (#eq? @_name "styled"))
 31  arguments: (template_string
 32    (string_fragment) @injection.content
 33    (#set! injection.language "css")))
 34
 35(call_expression
 36  function: (identifier) @_name
 37  (#eq? @_name "html")
 38  arguments: (template_string) @injection.content
 39  (#set! injection.language "html"))
 40
 41(call_expression
 42  function: (identifier) @_name
 43  (#eq? @_name "js")
 44  arguments: (template_string
 45    (string_fragment) @injection.content
 46    (#set! injection.language "javascript")))
 47
 48(call_expression
 49  function: (identifier) @_name
 50  (#eq? @_name "json")
 51  arguments: (template_string
 52    (string_fragment) @injection.content
 53    (#set! injection.language "json")))
 54
 55(call_expression
 56  function: (identifier) @_name
 57  (#eq? @_name "sql")
 58  arguments: (template_string
 59    (string_fragment) @injection.content
 60    (#set! injection.language "sql")))
 61
 62(call_expression
 63  function: (identifier) @_name
 64  (#eq? @_name "ts")
 65  arguments: (template_string
 66    (string_fragment) @injection.content
 67    (#set! injection.language "typescript")))
 68
 69(call_expression
 70  function: (identifier) @_name
 71  (#match? @_name "^ya?ml$")
 72  arguments: (template_string
 73    (string_fragment) @injection.content
 74    (#set! injection.language "yaml")))
 75
 76(call_expression
 77  function: (identifier) @_name
 78  (#match? @_name "^g(raph)?ql$")
 79  arguments: (template_string
 80    (string_fragment) @injection.content
 81    (#set! injection.language "graphql")))
 82
 83(call_expression
 84  function: (identifier) @_name
 85  (#match? @_name "^g(raph)?ql$")
 86  arguments: (arguments
 87    (template_string
 88      (string_fragment) @injection.content
 89      (#set! injection.language "graphql"))))
 90
 91(call_expression
 92  function: (identifier) @_name
 93  (#match? @_name "^iso$")
 94  arguments: (arguments
 95    (template_string
 96      (string_fragment) @injection.content
 97      (#set! injection.language "isograph"))))
 98
 99; Parse the contents of strings and tagged template
100; literals with leading ECMAScript comments:
101; '/* html */' or '/*html*/'
102(((comment) @_ecma_comment
103  [
104    (string
105      (string_fragment) @injection.content)
106    (template_string
107      (string_fragment) @injection.content)
108  ])
109  (#match? @_ecma_comment "^\\/\\*\\s*html\\s*\\*\\/")
110  (#set! injection.language "html"))
111
112; '/* sql */' or '/*sql*/'
113(((comment) @_ecma_comment
114  [
115    (string
116      (string_fragment) @injection.content)
117    (template_string
118      (string_fragment) @injection.content)
119  ])
120  (#match? @_ecma_comment "^\\/\\*\\s*sql\\s*\\*\\/")
121  (#set! injection.language "sql"))
122
123; '/* gql */' or '/*gql*/'
124; '/* graphql */' or '/*graphql*/'
125(((comment) @_ecma_comment
126  [
127    (string
128      (string_fragment) @injection.content)
129    (template_string
130      (string_fragment) @injection.content)
131  ])
132  (#match? @_ecma_comment "^\\/\\*\\s*(gql|graphql)\\s*\\*\\/")
133  (#set! injection.language "graphql"))
134
135; '/* css */' or '/*css*/'
136(((comment) @_ecma_comment
137  [
138    (string
139      (string_fragment) @injection.content)
140    (template_string
141      (string_fragment) @injection.content)
142  ])
143  (#match? @_ecma_comment "^\\/\\*\\s*(css)\\s*\\*\\/")
144  (#set! injection.language "css"))