diff options
| -rw-r--r-- | queries/ecma/folds.scm | 19 | ||||
| -rw-r--r-- | queries/ecma/highlights.scm | 271 | ||||
| -rw-r--r-- | queries/ecma/indents.scm | 30 | ||||
| -rw-r--r-- | queries/ecma/injections.scm | 20 | ||||
| -rw-r--r-- | queries/ecma/locals.scm | 61 | ||||
| -rw-r--r-- | queries/javascript/folds.scm | 21 | ||||
| -rw-r--r-- | queries/javascript/highlights.scm | 273 | ||||
| -rw-r--r-- | queries/javascript/indents.scm | 33 | ||||
| -rw-r--r-- | queries/javascript/injections.scm | 21 | ||||
| -rw-r--r-- | queries/javascript/locals.scm | 64 | ||||
| -rw-r--r-- | queries/typescript/folds.scm | 2 | ||||
| -rw-r--r-- | queries/typescript/highlights.scm | 2 | ||||
| -rw-r--r-- | queries/typescript/indents.scm | 2 | ||||
| -rw-r--r-- | queries/typescript/injections.scm | 2 | ||||
| -rw-r--r-- | queries/typescript/locals.scm | 2 |
15 files changed, 411 insertions, 412 deletions
diff --git a/queries/ecma/folds.scm b/queries/ecma/folds.scm new file mode 100644 index 000000000..ea48e1b6f --- /dev/null +++ b/queries/ecma/folds.scm @@ -0,0 +1,19 @@ +[ + (for_in_statement) + (for_statement) + (while_statement) + (arrow_function) + (function) + (function_declaration) + (class_declaration) + (method_definition) + (do_statement) + (with_statement) + (switch_statement) + (switch_case) + (import_statement) + (if_statement) + (try_statement) + (catch_clause) + (object) +] @fold diff --git a/queries/ecma/highlights.scm b/queries/ecma/highlights.scm new file mode 100644 index 000000000..c376bf6bd --- /dev/null +++ b/queries/ecma/highlights.scm @@ -0,0 +1,271 @@ +; Types + +; Javascript + +; Variables +;----------- +(identifier) @variable + +; Properties +;----------- + +(property_identifier) @property +(shorthand_property_identifier) @property + +; Special identifiers +;-------------------- + +((identifier) @constructor + (#match? @constructor "^[A-Z]")) + +((identifier) @constant + (#vim-match? @constant "^[A-Z_][A-Z\\d_]+$")) + +((shorthand_property_identifier) @constant + (#vim-match? @constant "^[A-Z_][A-Z\\d_]+$")) + +((identifier) @variable.builtin + (#vim-match? @variable.builtin "^(arguments|module|console|window|document)$")) + +((identifier) @function.builtin + (#eq? @function.builtin "require")) + +; Function and method definitions +;-------------------------------- + +(function + name: (identifier) @function) +(function_declaration + name: (identifier) @function) +(method_definition + name: (property_identifier) @method) + +(pair + key: (property_identifier) @method + value: (function)) +(pair + key: (property_identifier) @method + value: (arrow_function)) + +(assignment_expression + left: (member_expression + property: (property_identifier) @method) + right: (arrow_function)) +(assignment_expression + left: (member_expression + property: (property_identifier) @method) + right: (function)) + +(variable_declarator + name: (identifier) @function + value: (arrow_function)) +(variable_declarator + name: (identifier) @function + value: (function)) + +(assignment_expression + left: (identifier) @function + right: (arrow_function)) +(assignment_expression + left: (identifier) @function + right: (function)) + +; Function and method calls +;-------------------------- + +(call_expression + function: (identifier) @function) + +(call_expression + function: (member_expression + property: (property_identifier) @method)) + +; Variables +;---------- + +(formal_parameters (identifier) @parameter) + +(formal_parameters + (rest_parameter + (identifier) @parameter)) + +; ({ a }) => null +(formal_parameters + (object_pattern + (shorthand_property_identifier) @parameter)) + +; ({ a: b }) => null +(formal_parameters + (object_pattern + (pair + value: (identifier) @parameter))) + +; ([ a ]) => null +(formal_parameters + (array_pattern + (identifier) @parameter)) + +; a => null +(variable_declarator + value: (arrow_function + parameter: (identifier) @parameter)) + +; optional parameters +(formal_parameters + (assignment_pattern + (shorthand_property_identifier) @parameter)) + +; Variables +;---------- +(namespace_import + (identifier) @namespace) + +; Literals +;--------- + +(this) @variable.builtin +(super) @variable.builtin + +(true) @boolean +(false) @boolean +(null) @constant.builtin +(comment) @comment +(string) @string +(regex) @punctuation.delimiter +(regex_pattern) @string.regex +(template_string) @string +(number) @number + +; Punctuation +;------------ + +(template_substitution + "${" @punctuation.special + "}" @punctuation.special) @none + +"..." @punctuation.special + +";" @punctuation.delimiter +"." @punctuation.delimiter +"," @punctuation.delimiter +"?." @punctuation.delimiter + +(pair ":" @punctuation.delimiter) + +[ + "--" + "-" + "-=" + "&&" + "+" + "++" + "+=" + "&=" + "/=" + "**=" + "<<=" + "<" + "<=" + "<<" + "=" + "==" + "===" + "!=" + "!==" + "=>" + ">" + ">=" + ">>" + "||" + "%" + "%=" + "*" + "**" + ">>>" + "&" + "|" + "^" + "??" + "*=" + ">>=" + ">>>=" + "^=" + "|=" + "&&=" + "||=" + "??=" +] @operator + +(binary_expression "/" @operator) +(ternary_expression ["?" ":"] @operator) +(unary_expression ["!" "~" "-" "+" "delete" "void" "typeof"] @operator) + +"(" @punctuation.bracket +")" @punctuation.bracket +"[" @punctuation.bracket +"]" @punctuation.bracket +"{" @punctuation.bracket +"}" @punctuation.bracket + +; Keywords +;---------- + +[ +"if" +"else" +"switch" +"case" +"default" +] @conditional + +[ +"import" +"from" +"as" +] @include + +[ +"for" +"of" +"do" +"while" +"continue" +] @repeat + +[ +"async" +"await" +"break" +"class" +"const" +"debugger" +"export" +"extends" +"function" +"get" +"in" +"instanceof" +"let" +"return" +"set" +"static" +"switch" +"target" +"typeof" +"var" +"void" +"with" +"yield" +] @keyword + +[ + "new" + "delete" +] @keyword.operator + +[ + "throw" + "try" + "catch" + "finally" +] @exception diff --git a/queries/ecma/indents.scm b/queries/ecma/indents.scm new file mode 100644 index 000000000..aad719ce0 --- /dev/null +++ b/queries/ecma/indents.scm @@ -0,0 +1,30 @@ +[ + (object) + (array) + (arguments) + (statement_block) + (object_pattern) + (class_body) + (method_definition) + (named_imports) + (binary_expression) + (return_statement) + (template_substitution) + (expression_statement (call_expression)) + (export_clause) +] @indent + +[ + (arguments (object)) + "(" + ")" + "{" + "}" + "[" + "]" +] @branch + +[ + (comment) + (template_string) +] @ignore diff --git a/queries/ecma/injections.scm b/queries/ecma/injections.scm new file mode 100644 index 000000000..bec0f315e --- /dev/null +++ b/queries/ecma/injections.scm @@ -0,0 +1,20 @@ +((comment) @jsdoc) + +((regex_pattern) @regex) + +(call_expression + function: ((identifier) @language) + arguments: ((template_string) @content + (#offset! @content 0 1 0 -1))) + +(call_expression + function: ((identifier) @_name + (#eq? @_name "gql")) + arguments: ((template_string) @graphql + (#offset! @graphql 0 1 0 -1))) + +(call_expression + function: ((identifier) @_name + (#eq? @_name "hbs")) + arguments: ((template_string) @glimmer + (#offset! @glimmer 0 1 0 -1))) diff --git a/queries/ecma/locals.scm b/queries/ecma/locals.scm new file mode 100644 index 000000000..2f501f3a1 --- /dev/null +++ b/queries/ecma/locals.scm @@ -0,0 +1,61 @@ +; Scopes +;------- + +(statement_block) @scope +(function) @scope +(arrow_function) @scope +(function_declaration) @scope +(method_definition) @scope +(for_statement) @scope +(for_in_statement) @scope +(catch_clause) @scope + +; Definitions +;------------ + +(formal_parameters + (identifier) @definition.parameter) + +(formal_parameters + (object_pattern + (identifier) @definition.parameter)) + +; function(arg = []) { +(formal_parameters + (assignment_pattern + (shorthand_property_identifier) @definition.parameter)) + +; x => x +(arrow_function + parameter: (identifier) @definition.parameter) + +(formal_parameters + (object_pattern + (shorthand_property_identifier) @definition.parameter)) + +(formal_parameters + (array_pattern + (identifier) @definition.parameter)) + +(formal_parameters + (rest_parameter + (identifier) @definition.parameter)) + +(variable_declarator + name: (identifier) @definition.var) + +(import_specifier + (identifier) @definition.import) + +(namespace_import + (identifier) @definition.import) + +(function_declaration + ((identifier) @definition.var) + (#set! definition.var.scope parent)) + +; References +;------------ + +(identifier) @reference +(shorthand_property_identifier) @reference diff --git a/queries/javascript/folds.scm b/queries/javascript/folds.scm index ad10a00e5..b6d9b28bf 100644 --- a/queries/javascript/folds.scm +++ b/queries/javascript/folds.scm @@ -1,20 +1 @@ -; inherits: (jsx) -[ - (for_in_statement) - (for_statement) - (while_statement) - (arrow_function) - (function) - (function_declaration) - (class_declaration) - (method_definition) - (do_statement) - (with_statement) - (switch_statement) - (switch_case) - (import_statement) - (if_statement) - (try_statement) - (catch_clause) - (object) -] @fold +; inherits: ecma,jsx diff --git a/queries/javascript/highlights.scm b/queries/javascript/highlights.scm index 57cabd93e..b6d9b28bf 100644 --- a/queries/javascript/highlights.scm +++ b/queries/javascript/highlights.scm @@ -1,272 +1 @@ -; inherits: (jsx) -; Types - -; Javascript - -; Variables -;----------- -(identifier) @variable - -; Properties -;----------- - -(property_identifier) @property -(shorthand_property_identifier) @property - -; Special identifiers -;-------------------- - -((identifier) @constructor - (#match? @constructor "^[A-Z]")) - -((identifier) @constant - (#vim-match? @constant "^[A-Z_][A-Z\\d_]+$")) - -((shorthand_property_identifier) @constant - (#vim-match? @constant "^[A-Z_][A-Z\\d_]+$")) - -((identifier) @variable.builtin - (#vim-match? @variable.builtin "^(arguments|module|console|window|document)$")) - -((identifier) @function.builtin - (#eq? @function.builtin "require")) - -; Function and method definitions -;-------------------------------- - -(function - name: (identifier) @function) -(function_declaration - name: (identifier) @function) -(method_definition - name: (property_identifier) @method) - -(pair - key: (property_identifier) @method - value: (function)) -(pair - key: (property_identifier) @method - value: (arrow_function)) - -(assignment_expression - left: (member_expression - property: (property_identifier) @method) - right: (arrow_function)) -(assignment_expression - left: (member_expression - property: (property_identifier) @method) - right: (function)) - -(variable_declarator - name: (identifier) @function - value: (arrow_function)) -(variable_declarator - name: (identifier) @function - value: (function)) - -(assignment_expression - left: (identifier) @function - right: (arrow_function)) -(assignment_expression - left: (identifier) @function - right: (function)) - -; Function and method calls -;-------------------------- - -(call_expression - function: (identifier) @function) - -(call_expression - function: (member_expression - property: (property_identifier) @method)) - -; Variables -;---------- - -(formal_parameters (identifier) @parameter) - -(formal_parameters - (rest_parameter - (identifier) @parameter)) - -; ({ a }) => null -(formal_parameters - (object_pattern - (shorthand_property_identifier) @parameter)) - -; ({ a: b }) => null -(formal_parameters - (object_pattern - (pair - value: (identifier) @parameter))) - -; ([ a ]) => null -(formal_parameters - (array_pattern - (identifier) @parameter)) - -; a => null -(variable_declarator - value: (arrow_function - parameter: (identifier) @parameter)) - -; optional parameters -(formal_parameters - (assignment_pattern - (shorthand_property_identifier) @parameter)) - -; Variables -;---------- -(namespace_import - (identifier) @namespace) - -; Literals -;--------- - -(this) @variable.builtin -(super) @variable.builtin - -(true) @boolean -(false) @boolean -(null) @constant.builtin -(comment) @comment -(string) @string -(regex) @punctuation.delimiter -(regex_pattern) @string.regex -(template_string) @string -(number) @number - -; Punctuation -;------------ - -(template_substitution - "${" @punctuation.special - "}" @punctuation.special) @none - -"..." @punctuation.special - -";" @punctuation.delimiter -"." @punctuation.delimiter -"," @punctuation.delimiter -"?." @punctuation.delimiter - -(pair ":" @punctuation.delimiter) - -[ - "--" - "-" - "-=" - "&&" - "+" - "++" - "+=" - "&=" - "/=" - "**=" - "<<=" - "<" - "<=" - "<<" - "=" - "==" - "===" - "!=" - "!==" - "=>" - ">" - ">=" - ">>" - "||" - "%" - "%=" - "*" - "**" - ">>>" - "&" - "|" - "^" - "??" - "*=" - ">>=" - ">>>=" - "^=" - "|=" - "&&=" - "||=" - "??=" -] @operator - -(binary_expression "/" @operator) -(ternary_expression ["?" ":"] @operator) -(unary_expression ["!" "~" "-" "+" "delete" "void" "typeof"] @operator) - -"(" @punctuation.bracket -")" @punctuation.bracket -"[" @punctuation.bracket -"]" @punctuation.bracket -"{" @punctuation.bracket -"}" @punctuation.bracket - -; Keywords -;---------- - -[ -"if" -"else" -"switch" -"case" -"default" -] @conditional - -[ -"import" -"from" -"as" -] @include - -[ -"for" -"of" -"do" -"while" -"continue" -] @repeat - -[ -"async" -"await" -"break" -"class" -"const" -"debugger" -"export" -"extends" -"function" -"get" -"in" -"instanceof" -"let" -"return" -"set" -"static" -"switch" -"target" -"typeof" -"var" -"void" -"with" -"yield" -] @keyword - -[ - "new" - "delete" -] @keyword.operator - -[ - "throw" - "try" - "catch" - "finally" -] @exception +; inherits: ecma,jsx diff --git a/queries/javascript/indents.scm b/queries/javascript/indents.scm index f3796dbaf..b6d9b28bf 100644 --- a/queries/javascript/indents.scm +++ b/queries/javascript/indents.scm @@ -1,32 +1 @@ -; inherits: (jsx) - -[ - (object) - (array) - (arguments) - (statement_block) - (object_pattern) - (class_body) - (method_definition) - (named_imports) - (binary_expression) - (return_statement) - (template_substitution) - (expression_statement (call_expression)) - (export_clause) -] @indent - -[ - (arguments (object)) - "(" - ")" - "{" - "}" - "[" - "]" -] @branch - -[ - (comment) - (template_string) -] @ignore +; inherits: ecma,jsx diff --git a/queries/javascript/injections.scm b/queries/javascript/injections.scm index bec0f315e..b6d9b28bf 100644 --- a/queries/javascript/injections.scm +++ b/queries/javascript/injections.scm @@ -1,20 +1 @@ -((comment) @jsdoc) - -((regex_pattern) @regex) - -(call_expression - function: ((identifier) @language) - arguments: ((template_string) @content - (#offset! @content 0 1 0 -1))) - -(call_expression - function: ((identifier) @_name - (#eq? @_name "gql")) - arguments: ((template_string) @graphql - (#offset! @graphql 0 1 0 -1))) - -(call_expression - function: ((identifier) @_name - (#eq? @_name "hbs")) - arguments: ((template_string) @glimmer - (#offset! @glimmer 0 1 0 -1))) +; inherits: ecma,jsx diff --git a/queries/javascript/locals.scm b/queries/javascript/locals.scm index 99a40a6be..b6d9b28bf 100644 --- a/queries/javascript/locals.scm +++ b/queries/javascript/locals.scm @@ -1,63 +1 @@ -; inherits: (jsx) - -; Scopes -;------- - -(statement_block) @scope -(function) @scope -(arrow_function) @scope -(function_declaration) @scope -(method_definition) @scope -(for_statement) @scope -(for_in_statement) @scope -(catch_clause) @scope - -; Definitions -;------------ - -(formal_parameters - (identifier) @definition.parameter) - -(formal_parameters - (object_pattern - (identifier) @definition.parameter)) - -; function(arg = []) { -(formal_parameters - (assignment_pattern - (shorthand_property_identifier) @definition.parameter)) - -; x => x -(arrow_function - parameter: (identifier) @definition.parameter) - -(formal_parameters - (object_pattern - (shorthand_property_identifier) @definition.parameter)) - -(formal_parameters - (array_pattern - (identifier) @definition.parameter)) - -(formal_parameters - (rest_parameter - (identifier) @definition.parameter)) - -(variable_declarator - name: (identifier) @definition.var) - -(import_specifier - (identifier) @definition.import) - -(namespace_import - (identifier) @definition.import) - -(function_declaration - ((identifier) @definition.var) - (#set! definition.var.scope parent)) - -; References -;------------ - -(identifier) @reference -(shorthand_property_identifier) @reference +; inherits: ecma,jsx diff --git a/queries/typescript/folds.scm b/queries/typescript/folds.scm index 448f4d12a..dced30d9a 100644 --- a/queries/typescript/folds.scm +++ b/queries/typescript/folds.scm @@ -1,4 +1,4 @@ -; inherits: javascript +; inherits: ecma [ (interface_declaration) diff --git a/queries/typescript/highlights.scm b/queries/typescript/highlights.scm index dbc801396..77c21754f 100644 --- a/queries/typescript/highlights.scm +++ b/queries/typescript/highlights.scm @@ -1,4 +1,4 @@ -; inherits: javascript +; inherits: ecma [ "abstract" "declare" diff --git a/queries/typescript/indents.scm b/queries/typescript/indents.scm index 912dec6c6..d7f9cbc2a 100644 --- a/queries/typescript/indents.scm +++ b/queries/typescript/indents.scm @@ -1,4 +1,4 @@ -; inherits: javascript +; inherits: ecma [ (enum_declaration) diff --git a/queries/typescript/injections.scm b/queries/typescript/injections.scm index ff0ddfacf..04328f099 100644 --- a/queries/typescript/injections.scm +++ b/queries/typescript/injections.scm @@ -1 +1 @@ -; inherits: javascript +; inherits: ecma diff --git a/queries/typescript/locals.scm b/queries/typescript/locals.scm index 3e05f536e..405f5c026 100644 --- a/queries/typescript/locals.scm +++ b/queries/typescript/locals.scm @@ -1,4 +1,4 @@ -; inherits: javascript +; inherits: ecma (required_parameter (identifier) @definition) (optional_parameter (identifier) @definition) |
