| 1 | ; Variables |
| 2 | ;---------- |
| 3 | |
| 4 | (identifier) @variable |
| 5 | |
| 6 | ; Properties |
| 7 | ;----------- |
| 8 | |
| 9 | (property_identifier) @property |
| 10 | (shorthand_property_identifier) @property |
| 11 | (shorthand_property_identifier_pattern) @property |
| 12 | (private_property_identifier) @property |
| 13 | |
| 14 | ; Function and method definitions |
| 15 | ;-------------------------------- |
| 16 | |
| 17 | (function_expression |
| 18 | name: (identifier) @function) |
| 19 | (function_declaration |
| 20 | name: (identifier) @function) |
| 21 | (method_definition |
| 22 | name: (property_identifier) @function.method) |
| 23 | |
| 24 | (pair |
| 25 | key: (property_identifier) @function.method |
| 26 | value: [(function_expression) (arrow_function)]) |
| 27 | |
| 28 | (assignment_expression |
| 29 | left: (member_expression |
| 30 | property: (property_identifier) @function.method) |
| 31 | right: [(function_expression) (arrow_function)]) |
| 32 | |
| 33 | (variable_declarator |
| 34 | name: (identifier) @function |
| 35 | value: [(function_expression) (arrow_function)]) |
| 36 | |
| 37 | (assignment_expression |
| 38 | left: (identifier) @function |
| 39 | right: [(function_expression) (arrow_function)]) |
| 40 | |
| 41 | ; Function and method calls |
| 42 | ;-------------------------- |
| 43 | |
| 44 | (call_expression |
| 45 | function: (identifier) @function) |
| 46 | |
| 47 | (call_expression |
| 48 | function: (member_expression |
| 49 | property: (property_identifier) @function.method)) |
| 50 | |
| 51 | ; Special identifiers |
| 52 | ;-------------------- |
| 53 | |
| 54 | ((identifier) @type |
| 55 | (#match? @type "^[A-Z]")) |
| 56 | |
| 57 | ([ |
| 58 | (identifier) |
| 59 | (shorthand_property_identifier) |
| 60 | (shorthand_property_identifier_pattern) |
| 61 | ] @constant |
| 62 | (#match? @constant "^_*[A-Z_][A-Z\\d_]*$")) |
| 63 | |
| 64 | ((identifier) @variable.builtin |
| 65 | (#match? @variable.builtin "^(arguments|module|console|window|document)$") |
| 66 | (#is-not? local)) |
| 67 | |
| 68 | ((identifier) @function.builtin |
| 69 | (#eq? @function.builtin "require") |
| 70 | (#is-not? local)) |
| 71 | |
| 72 | ; Literals |
| 73 | ;--------- |
| 74 | |
| 75 | (this) @variable.builtin |
| 76 | (super) @variable.builtin |
| 77 | |
| 78 | [ |
| 79 | (true) |
| 80 | (false) |
| 81 | (null) |
| 82 | (undefined) |
| 83 | ] @constant.builtin |
| 84 | |
| 85 | (comment) @comment |
| 86 | |
| 87 | [ |
| 88 | (string) |
| 89 | (template_string) |
| 90 | ] @string |
| 91 | |
| 92 | (regex) @string.special |
| 93 | (number) @number |
| 94 | |
| 95 | ; Tokens |
| 96 | ;------- |
| 97 | |
| 98 | [ |
| 99 | ";" |
| 100 | (optional_chain) |
| 101 | "." |
| 102 | "," |
| 103 | ] @punctuation.delimiter |
| 104 | |
| 105 | [ |
| 106 | "-" |
| 107 | "--" |
| 108 | "-=" |
| 109 | "+" |
| 110 | "++" |
| 111 | "+=" |
| 112 | "*" |
| 113 | "*=" |
| 114 | "**" |
| 115 | "**=" |
| 116 | "/" |
| 117 | "/=" |
| 118 | "%" |
| 119 | "%=" |
| 120 | "<" |
| 121 | "<=" |
| 122 | "<<" |
| 123 | "<<=" |
| 124 | "=" |
| 125 | "==" |
| 126 | "===" |
| 127 | "!" |
| 128 | "!=" |
| 129 | "!==" |
| 130 | "=>" |
| 131 | ">" |
| 132 | ">=" |
| 133 | ">>" |
| 134 | ">>=" |
| 135 | ">>>" |
| 136 | ">>>=" |
| 137 | "~" |
| 138 | "^" |
| 139 | "&" |
| 140 | "|" |
| 141 | "^=" |
| 142 | "&=" |
| 143 | "|=" |
| 144 | "&&" |
| 145 | "||" |
| 146 | "??" |
| 147 | "&&=" |
| 148 | "||=" |
| 149 | "??=" |
| 150 | ] @operator |
| 151 | |
| 152 | [ |
| 153 | "(" |
| 154 | ")" |
| 155 | "[" |
| 156 | "]" |
| 157 | "{" |
| 158 | "}" |
| 159 | ] @punctuation.bracket |
| 160 | |
| 161 | (template_substitution |
| 162 | "${" @punctuation.special |
| 163 | "}" @punctuation.special) @embedded |
| 164 | |
| 165 | [ |
| 166 | "as" |
| 167 | "async" |
| 168 | "await" |
| 169 | "break" |
| 170 | "case" |
| 171 | "catch" |
| 172 | "class" |
| 173 | "const" |
| 174 | "continue" |
| 175 | "debugger" |
| 176 | "default" |
| 177 | "delete" |
| 178 | "do" |
| 179 | "else" |
| 180 | "export" |
| 181 | "extends" |
| 182 | "finally" |
| 183 | "for" |
| 184 | "from" |
| 185 | "function" |
| 186 | "get" |
| 187 | "if" |
| 188 | "import" |
| 189 | "in" |
| 190 | "instanceof" |
| 191 | "let" |
| 192 | "new" |
| 193 | "of" |
| 194 | "return" |
| 195 | "set" |
| 196 | "static" |
| 197 | "switch" |
| 198 | "target" |
| 199 | "throw" |
| 200 | "try" |
| 201 | "typeof" |
| 202 | "var" |
| 203 | "void" |
| 204 | "while" |
| 205 | "with" |
| 206 | "yield" |
| 207 | ] @keyword |