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
 39    (string_fragment) @injection.content
 40    (#set! injection.language "html")))
 41
 42(call_expression
 43  function: (identifier) @_name
 44  (#eq? @_name "js")
 45  arguments: (template_string
 46    (string_fragment) @injection.content
 47    (#set! injection.language "javascript")))
 48
 49(call_expression
 50  function: (identifier) @_name
 51  (#eq? @_name "json")
 52  arguments: (template_string
 53    (string_fragment) @injection.content
 54    (#set! injection.language "json")))
 55
 56(call_expression
 57  function: (identifier) @_name
 58  (#eq? @_name "sql")
 59  arguments: (template_string
 60    (string_fragment) @injection.content
 61    (#set! injection.language "sql")))
 62
 63(call_expression
 64  function: (identifier) @_name
 65  (#eq? @_name "ts")
 66  arguments: (template_string
 67    (string_fragment) @injection.content
 68    (#set! injection.language "typescript")))
 69
 70(call_expression
 71  function: (identifier) @_name
 72  (#match? @_name "^ya?ml$")
 73  arguments: (template_string
 74    (string_fragment) @injection.content
 75    (#set! injection.language "yaml")))
 76
 77(call_expression
 78  function: (identifier) @_name
 79  (#match? @_name "^g(raph)?ql$")
 80  arguments: (template_string
 81    (string_fragment) @injection.content
 82    (#set! injection.language "graphql")))
 83
 84(call_expression
 85  function: (identifier) @_name
 86  (#match? @_name "^g(raph)?ql$")
 87  arguments: (arguments
 88    (template_string
 89      (string_fragment) @injection.content
 90      (#set! injection.language "graphql"))))
 91
 92(call_expression
 93  function: (identifier) @_name
 94  (#match? @_name "^iso$")
 95  arguments: (arguments
 96    (template_string
 97      (string_fragment) @injection.content
 98      (#set! injection.language "isograph"))))
 99
100; Parse the contents of strings and tagged template
101; literals with leading ECMAScript comments:
102; '/* html */' or '/*html*/'
103(((comment) @_ecma_comment
104  [
105    (string
106      (string_fragment) @injection.content)
107    (template_string
108      (string_fragment) @injection.content)
109  ])
110  (#match? @_ecma_comment "^\\/\\*\\s*html\\s*\\*\\/")
111  (#set! injection.language "html"))
112
113; '/* sql */' or '/*sql*/'
114(((comment) @_ecma_comment
115  [
116    (string
117      (string_fragment) @injection.content)
118    (template_string
119      (string_fragment) @injection.content)
120  ])
121  (#match? @_ecma_comment "^\\/\\*\\s*sql\\s*\\*\\/")
122  (#set! injection.language "sql"))
123
124; '/* gql */' or '/*gql*/'
125; '/* graphql */' or '/*graphql*/'
126(((comment) @_ecma_comment
127  [
128    (string
129      (string_fragment) @injection.content)
130    (template_string
131      (string_fragment) @injection.content)
132  ])
133  (#match? @_ecma_comment "^\\/\\*\\s*(gql|graphql)\\s*\\*\\/")
134  (#set! injection.language "graphql"))
135
136; '/* css */' or '/*css*/'
137(((comment) @_ecma_comment
138  [
139    (string
140      (string_fragment) @injection.content)
141    (template_string
142      (string_fragment) @injection.content)
143  ])
144  (#match? @_ecma_comment "^\\/\\*\\s*(css)\\s*\\*\\/")
145  (#set! injection.language "css"))