diff options
author | Indrajith K L | 2022-12-03 17:00:20 +0530 |
---|---|---|
committer | Indrajith K L | 2022-12-03 17:00:20 +0530 |
commit | f5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch) | |
tree | 2764fc62da58f2ba8da7ed341643fc359873142f /helix-22.03-x86_64-windows/runtime/queries/javascript | |
download | cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.gz cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.tar.bz2 cli-tools-windows-f5c4671bfbad96bf346bd7e9a21fc4317b4959df.zip |
Diffstat (limited to 'helix-22.03-x86_64-windows/runtime/queries/javascript')
7 files changed, 388 insertions, 0 deletions
diff --git a/helix-22.03-x86_64-windows/runtime/queries/javascript/highlights-jsx.scm b/helix-22.03-x86_64-windows/runtime/queries/javascript/highlights-jsx.scm new file mode 100644 index 0000000..751da08 --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/javascript/highlights-jsx.scm @@ -0,0 +1,4 @@ +(jsx_opening_element (identifier) @tag) +(jsx_closing_element (identifier) @tag) +(jsx_self_closing_element (identifier) @tag) +(jsx_attribute (property_identifier) @attribute) diff --git a/helix-22.03-x86_64-windows/runtime/queries/javascript/highlights-params.scm b/helix-22.03-x86_64-windows/runtime/queries/javascript/highlights-params.scm new file mode 100644 index 0000000..95ffc72 --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/javascript/highlights-params.scm @@ -0,0 +1,12 @@ +(formal_parameters + [ + (identifier) @variable.parameter + (array_pattern + (identifier) @variable.parameter) + (object_pattern + [ + (pair_pattern value: (identifier) @variable.parameter) + (shorthand_property_identifier_pattern) @variable.parameter + ]) + ] +) diff --git a/helix-22.03-x86_64-windows/runtime/queries/javascript/highlights.scm b/helix-22.03-x86_64-windows/runtime/queries/javascript/highlights.scm new file mode 100644 index 0000000..6163b68 --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/javascript/highlights.scm @@ -0,0 +1,205 @@ +; Special identifiers +;-------------------- + +([ + (identifier) + (shorthand_property_identifier) + (shorthand_property_identifier_pattern) + ] @constant + (#match? @constant "^[A-Z_][A-Z\\d_]+$")) + + +((identifier) @constructor + (#match? @constructor "^[A-Z]")) + +((identifier) @variable.builtin + (#match? @variable.builtin "^(arguments|module|console|window|document)$") + (#is-not? local)) + +((identifier) @function.builtin + (#eq? @function.builtin "require") + (#is-not? local)) + +; Function and method definitions +;-------------------------------- + +(function + name: (identifier) @function) +(function_declaration + name: (identifier) @function) +(method_definition + name: (property_identifier) @function.method) + +(pair + key: (property_identifier) @function.method + value: [(function) (arrow_function)]) + +(assignment_expression + left: (member_expression + property: (property_identifier) @function.method) + right: [(function) (arrow_function)]) + +(variable_declarator + name: (identifier) @function + value: [(function) (arrow_function)]) + +(assignment_expression + left: (identifier) @function + right: [(function) (arrow_function)]) + +; Function and method calls +;-------------------------- + +(call_expression + function: (identifier) @function) + +(call_expression + function: (member_expression + property: (property_identifier) @function.method)) + +; Variables +;---------- + +(identifier) @variable + +; Properties +;----------- + +(property_identifier) @variable.other.member + +; Literals +;--------- + +(this) @variable.builtin +(super) @variable.builtin + +[ + (true) + (false) + (null) + (undefined) +] @constant.builtin + +(comment) @comment + +[ + (string) + (template_string) +] @string + +(regex) @string.regexp +(number) @constant.numeric.integer + +; Tokens +;------- + +(template_substitution + "${" @punctuation.special + "}" @punctuation.special) @embedded + +[ + ";" + "?." + "." + "," +] @punctuation.delimiter + +[ + "-" + "--" + "-=" + "+" + "++" + "+=" + "*" + "*=" + "**" + "**=" + "/" + "/=" + "%" + "%=" + "<" + "<=" + "<<" + "<<=" + "=" + "==" + "===" + "!" + "!=" + "!==" + "=>" + ">" + ">=" + ">>" + ">>=" + ">>>" + ">>>=" + "~" + "^" + "&" + "|" + "^=" + "&=" + "|=" + "&&" + "||" + "??" + "&&=" + "||=" + "??=" +] @operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "as" + "async" + "await" + "break" + "case" + "catch" + "class" + "const" + "continue" + "debugger" + "default" + "delete" + "do" + "else" + "export" + "extends" + "finally" + "for" + "from" + "function" + "get" + "if" + "import" + "in" + "instanceof" + "let" + "new" + "of" + "return" + "set" + "static" + "switch" + "target" + "throw" + "try" + "typeof" + "var" + "void" + "while" + "with" + "yield" +] @keyword diff --git a/helix-22.03-x86_64-windows/runtime/queries/javascript/indents.toml b/helix-22.03-x86_64-windows/runtime/queries/javascript/indents.toml new file mode 100644 index 0000000..9d711ab --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/javascript/indents.toml @@ -0,0 +1,28 @@ +indent = [ + "array", + "object", + "arguments", + "formal_parameters", + + "statement_block", + "object_pattern", + "class_body", + "named_imports", + + "binary_expression", + "return_statement", + "template_substitution", + # (expression_statement (call_expression)) + "export_clause", + + # typescript + "enum_declaration", + "interface_declaration", + "object_type", +] + +outdent = [ + "}", + "]", + ")" +] diff --git a/helix-22.03-x86_64-windows/runtime/queries/javascript/injections.scm b/helix-22.03-x86_64-windows/runtime/queries/javascript/injections.scm new file mode 100644 index 0000000..e842911 --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/javascript/injections.scm @@ -0,0 +1,28 @@ +; Parse the contents of tagged template literals using +; a language inferred from the tag. + +(call_expression + function: [ + (identifier) @injection.language + (member_expression + property: (property_identifier) @injection.language) + ] + arguments: (template_string) @injection.content) + +; Parse the contents of gql template literals + +((call_expression + function: (identifier) @_template_function_name + arguments: (template_string) @injection.content) + (#eq? @_template_function_name "gql") + (#set! injection.language "graphql")) + +; Parse regex syntax within regex literals + +((regex_pattern) @injection.content + (#set! injection.language "regex")) + + ; Parse JSDoc annotations in comments + +((comment) @injection.content + (#set! injection.language "jsdoc")) diff --git a/helix-22.03-x86_64-windows/runtime/queries/javascript/locals.scm b/helix-22.03-x86_64-windows/runtime/queries/javascript/locals.scm new file mode 100644 index 0000000..5d680ac --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/javascript/locals.scm @@ -0,0 +1,23 @@ +; Scopes +;------- + +[ + (statement_block) + (function) + (arrow_function) + (function_declaration) + (method_definition) +] @local.scope + +; Definitions +;------------ + +(pattern/identifier)@local.definition + +(variable_declarator + name: (identifier) @local.definition) + +; References +;------------ + +(identifier) @local.reference diff --git a/helix-22.03-x86_64-windows/runtime/queries/javascript/tags.scm b/helix-22.03-x86_64-windows/runtime/queries/javascript/tags.scm new file mode 100644 index 0000000..a7bbd31 --- /dev/null +++ b/helix-22.03-x86_64-windows/runtime/queries/javascript/tags.scm @@ -0,0 +1,88 @@ +( + (comment)* @doc + . + (method_definition + name: (property_identifier) @name) @definition.method + (#not-eq? @name "constructor") + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.method) +) + +( + (comment)* @doc + . + [ + (class + name: (_) @name) + (class_declaration + name: (_) @name) + ] @definition.class + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.class) +) + +( + (comment)* @doc + . + [ + (function + name: (identifier) @name) + (function_declaration + name: (identifier) @name) + (generator_function + name: (identifier) @name) + (generator_function_declaration + name: (identifier) @name) + ] @definition.function + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +( + (comment)* @doc + . + (lexical_declaration + (variable_declarator + name: (identifier) @name + value: [(arrow_function) (function)]) @definition.function) + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +( + (comment)* @doc + . + (variable_declaration + (variable_declarator + name: (identifier) @name + value: [(arrow_function) (function)]) @definition.function) + (#strip! @doc "^[\\s\\*/]+|^[\\s\\*/]$") + (#select-adjacent! @doc @definition.function) +) + +(assignment_expression + left: [ + (identifier) @name + (member_expression + property: (property_identifier) @name) + ] + right: [(arrow_function) (function)] +) @definition.function + +(pair + key: (property_identifier) @name + value: [(arrow_function) (function)]) @definition.function + +( + (call_expression + function: (identifier) @name) @reference.call + (#not-match? @name "^(require)$") +) + +(call_expression + function: (member_expression + property: (property_identifier) @name) + arguments: (_) @reference.call) + +(new_expression + constructor: (_) @name) @reference.class |