injections.scm

  1((comment) @injection.content
  2 (#set! injection.language "comment")
  3)
  4
  5(((comment) @_jsdoc_comment
  6  (#match? @_jsdoc_comment "(?s)^/[*][*][^*].*[*]/$")) @injection.content
  7  (#set! injection.language "jsdoc"))
  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(call_expression
 82  function: (identifier) @_name(#match? @_name "^iso$")
 83  arguments: (arguments (template_string (string_fragment) @injection.content
 84                              (#set! injection.language "isograph")))
 85)
 86
 87; Parse the contents of strings and tagged template
 88; literals with leading ECMAScript comments:
 89; '/* html */' or '/*html*/'
 90(
 91  ((comment) @_ecma_comment [
 92    (string (string_fragment) @injection.content)
 93    (template_string (string_fragment) @injection.content)
 94  ])
 95  (#match? @_ecma_comment "^\\/\\*\\s*html\\s*\\*\\/")
 96  (#set! injection.language "html")
 97)
 98
 99; '/* sql */' or '/*sql*/'
100(
101  ((comment) @_ecma_comment [
102    (string (string_fragment) @injection.content)
103    (template_string (string_fragment) @injection.content)
104  ])
105  (#match? @_ecma_comment "^\\/\\*\\s*sql\\s*\\*\\/")
106  (#set! injection.language "sql")
107)
108
109; '/* gql */' or '/*gql*/'
110; '/* graphql */' or '/*graphql*/'
111(
112  ((comment) @_ecma_comment [
113    (string (string_fragment) @injection.content)
114    (template_string (string_fragment) @injection.content)
115  ])
116  (#match? @_ecma_comment "^\\/\\*\\s*(gql|graphql)\\s*\\*\\/")
117  (#set! injection.language "graphql")
118)
119
120; '/* css */' or '/*css*/'
121(
122  ((comment) @_ecma_comment [
123    (string (string_fragment) @injection.content)
124    (template_string (string_fragment) @injection.content)
125  ])
126  (#match? @_ecma_comment "^\\/\\*\\s*(css)\\s*\\*\\/")
127  (#set! injection.language "css")
128)