From 9fe09b962fdf64625f265729e9dcbe8689c3bf1d Mon Sep 17 00:00:00 2001 From: Ashi Krishnan Date: Tue, 24 Jul 2018 14:37:31 -0400 Subject: [PATCH] Highlight special variables, CONSTANT_VARIABLES, and ClassNames differently. --- grammars/tree-sitter-javascript.cson | 40 ++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/grammars/tree-sitter-javascript.cson b/grammars/tree-sitter-javascript.cson index bb04ab42..7b02b91a 100644 --- a/grammars/tree-sitter-javascript.cson +++ b/grammars/tree-sitter-javascript.cson @@ -62,18 +62,19 @@ comments: scopes: 'program': 'source.js' - 'class > identifier': 'entity.name.type.class' - 'property_identifier': 'variable.other.object.property' 'function > identifier': 'entity.name.function' - 'call_expression > identifier': 'entity.name.function' + + 'call_expression > identifier': [ + {match: '^require$', scopes: 'support.function'}, + {match: '^[A-Z]', scopes: 'meta.class'}, + 'entity.name.function' + ] 'method_definition > property_identifier': 'entity.name.function' 'call_expression > member_expression > property_identifier': 'entity.name.function' - 'new_expression > call_expression > identifier': 'meta.class.instance.constructor' - 'import_specifier > identifier': 'variable.other.module' 'import_clause > identifier': 'variable.other.module' @@ -97,6 +98,35 @@ scopes: '"{"': 'punctuation.definition.function.body.begin.bracket.curly' '"}"': 'punctuation.definition.function.body.end.bracket.curly' + 'identifier': [ + { + match: '^(global|module|exports|__filename|__dirname)$', + scopes: 'support.variable' + }, + { + exact: 'require', scopes: 'support.function' + } + { + match: '^[\$A-Z_]+$', + scopes: 'constant.other' + }, + { + match: '^[A-Z]', + scopes: 'meta.class' + }, + ] + + 'shorthand_property_identifier': [ + { + match: '^[\$A-Z_]+$', + scopes: 'constant.other' + }, + { + match: '^[A-Z]', + scopes: 'meta.class' + }, + ] + '"var"': 'storage.type' '"let"': 'storage.type' '"class"': 'storage.type'