aboutsummaryrefslogtreecommitdiffstats
path: root/queries/ecma
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2023-06-12 09:54:30 -0600
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commit692b051b09935653befdb8f7ba8afdb640adf17b (patch)
tree167162b6b129ae04f68c5735078521a72917c742 /queries/ecma
parentfeat(c-family): inherit injections (diff)
downloadnvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'queries/ecma')
-rw-r--r--queries/ecma/folds.scm24
-rw-r--r--queries/ecma/highlights.scm392
-rw-r--r--queries/ecma/indents.scm82
-rw-r--r--queries/ecma/injections.scm203
-rw-r--r--queries/ecma/locals.scm42
5 files changed, 0 insertions, 743 deletions
diff --git a/queries/ecma/folds.scm b/queries/ecma/folds.scm
deleted file mode 100644
index a348f3444..000000000
--- a/queries/ecma/folds.scm
+++ /dev/null
@@ -1,24 +0,0 @@
-[
- (arguments)
- (for_in_statement)
- (for_statement)
- (while_statement)
- (arrow_function)
- (function_expression)
- (function_declaration)
- (class_declaration)
- (method_definition)
- (do_statement)
- (with_statement)
- (switch_statement)
- (switch_case)
- (switch_default)
- (import_statement)+
- (if_statement)
- (try_statement)
- (catch_clause)
- (array)
- (object)
- (generator_function)
- (generator_function_declaration)
-] @fold
diff --git a/queries/ecma/highlights.scm b/queries/ecma/highlights.scm
deleted file mode 100644
index cec2f4e3e..000000000
--- a/queries/ecma/highlights.scm
+++ /dev/null
@@ -1,392 +0,0 @@
-; Types
-; Javascript
-; Variables
-;-----------
-(identifier) @variable
-
-; Properties
-;-----------
-(property_identifier) @variable.member
-
-(shorthand_property_identifier) @variable.member
-
-(private_property_identifier) @variable.member
-
-(object_pattern
- (shorthand_property_identifier_pattern) @variable)
-
-(object_pattern
- (object_assignment_pattern
- (shorthand_property_identifier_pattern) @variable))
-
-; Special identifiers
-;--------------------
-((identifier) @type
- (#lua-match? @type "^[A-Z]"))
-
-((identifier) @constant
- (#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
-
-((shorthand_property_identifier) @constant
- (#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
-
-((identifier) @variable.builtin
- (#any-of? @variable.builtin "arguments" "module" "console" "window" "document"))
-
-((identifier) @type.builtin
- (#any-of? @type.builtin
- "Object" "Function" "Boolean" "Symbol" "Number" "Math" "Date" "String" "RegExp" "Map" "Set"
- "WeakMap" "WeakSet" "Promise" "Array" "Int8Array" "Uint8Array" "Uint8ClampedArray" "Int16Array"
- "Uint16Array" "Int32Array" "Uint32Array" "Float32Array" "Float64Array" "ArrayBuffer" "DataView"
- "Error" "EvalError" "InternalError" "RangeError" "ReferenceError" "SyntaxError" "TypeError"
- "URIError"))
-
-(statement_identifier) @label
-
-; Function and method definitions
-;--------------------------------
-(function_expression
- name: (identifier) @function)
-
-(function_declaration
- name: (identifier) @function)
-
-(generator_function
- name: (identifier) @function)
-
-(generator_function_declaration
- name: (identifier) @function)
-
-(method_definition
- name: [
- (property_identifier)
- (private_property_identifier)
- ] @function.method)
-
-(method_definition
- name: (property_identifier) @constructor
- (#eq? @constructor "constructor"))
-
-(pair
- key: (property_identifier) @function.method
- value: (function_expression))
-
-(pair
- key: (property_identifier) @function.method
- value: (arrow_function))
-
-(assignment_expression
- left: (member_expression
- property: (property_identifier) @function.method)
- right: (arrow_function))
-
-(assignment_expression
- left: (member_expression
- property: (property_identifier) @function.method)
- right: (function_expression))
-
-(variable_declarator
- name: (identifier) @function
- value: (arrow_function))
-
-(variable_declarator
- name: (identifier) @function
- value: (function_expression))
-
-(assignment_expression
- left: (identifier) @function
- right: (arrow_function))
-
-(assignment_expression
- left: (identifier) @function
- right: (function_expression))
-
-; Function and method calls
-;--------------------------
-(call_expression
- function: (identifier) @function.call)
-
-(call_expression
- function: (member_expression
- property: [
- (property_identifier)
- (private_property_identifier)
- ] @function.method.call))
-
-(call_expression
- function: (await_expression
- (identifier) @function.call))
-
-(call_expression
- function: (await_expression
- (member_expression
- property: [
- (property_identifier)
- (private_property_identifier)
- ] @function.method.call)))
-
-; Builtins
-;---------
-((identifier) @module.builtin
- (#eq? @module.builtin "Intl"))
-
-((identifier) @function.builtin
- (#any-of? @function.builtin
- "eval" "isFinite" "isNaN" "parseFloat" "parseInt" "decodeURI" "decodeURIComponent" "encodeURI"
- "encodeURIComponent" "require"))
-
-; Constructor
-;------------
-(new_expression
- constructor: (identifier) @constructor)
-
-; Decorators
-;----------
-(decorator
- "@" @attribute
- (identifier) @attribute)
-
-(decorator
- "@" @attribute
- (call_expression
- (identifier) @attribute))
-
-(decorator
- "@" @attribute
- (member_expression
- (property_identifier) @attribute))
-
-(decorator
- "@" @attribute
- (call_expression
- (member_expression
- (property_identifier) @attribute)))
-
-; Literals
-;---------
-[
- (this)
- (super)
-] @variable.builtin
-
-((identifier) @variable.builtin
- (#eq? @variable.builtin "self"))
-
-[
- (true)
- (false)
-] @boolean
-
-[
- (null)
- (undefined)
-] @constant.builtin
-
-[
- (comment)
- (html_comment)
-] @comment @spell
-
-((comment) @comment.documentation
- (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
-
-(hash_bang_line) @keyword.directive
-
-((string_fragment) @keyword.directive
- (#eq? @keyword.directive "use strict"))
-
-(string) @string
-
-(template_string) @string
-
-(escape_sequence) @string.escape
-
-(regex_pattern) @string.regexp
-
-(regex_flags) @character.special
-
-(regex
- "/" @punctuation.bracket) ; Regex delimiters
-
-(number) @number
-
-((identifier) @number
- (#any-of? @number "NaN" "Infinity"))
-
-; Punctuation
-;------------
-[
- ";"
- "."
- ","
- ":"
-] @punctuation.delimiter
-
-[
- "--"
- "-"
- "-="
- "&&"
- "+"
- "++"
- "+="
- "&="
- "/="
- "**="
- "<<="
- "<"
- "<="
- "<<"
- "="
- "=="
- "==="
- "!="
- "!=="
- "=>"
- ">"
- ">="
- ">>"
- "||"
- "%"
- "%="
- "*"
- "**"
- ">>>"
- "&"
- "|"
- "^"
- "??"
- "*="
- ">>="
- ">>>="
- "^="
- "|="
- "&&="
- "||="
- "??="
- "..."
-] @operator
-
-(binary_expression
- "/" @operator)
-
-(ternary_expression
- [
- "?"
- ":"
- ] @keyword.conditional.ternary)
-
-(unary_expression
- [
- "!"
- "~"
- "-"
- "+"
- ] @operator)
-
-(unary_expression
- [
- "delete"
- "void"
- ] @keyword.operator)
-
-[
- "("
- ")"
- "["
- "]"
- "{"
- "}"
-] @punctuation.bracket
-
-(template_substitution
- [
- "${"
- "}"
- ] @punctuation.special) @none
-
-; Imports
-;----------
-(namespace_import
- "*" @character.special
- (identifier) @module)
-
-(namespace_export
- "*" @character.special
- (identifier) @module)
-
-(export_statement
- "*" @character.special)
-
-; Keywords
-;----------
-[
- "if"
- "else"
- "switch"
- "case"
-] @keyword.conditional
-
-[
- "import"
- "from"
- "as"
- "export"
-] @keyword.import
-
-[
- "for"
- "of"
- "do"
- "while"
- "continue"
-] @keyword.repeat
-
-[
- "break"
- "const"
- "debugger"
- "extends"
- "get"
- "let"
- "set"
- "static"
- "target"
- "var"
- "with"
-] @keyword
-
-"class" @keyword.type
-
-[
- "async"
- "await"
-] @keyword.coroutine
-
-[
- "return"
- "yield"
-] @keyword.return
-
-"function" @keyword.function
-
-[
- "new"
- "delete"
- "in"
- "instanceof"
- "typeof"
-] @keyword.operator
-
-[
- "throw"
- "try"
- "catch"
- "finally"
-] @keyword.exception
-
-(export_statement
- "default" @keyword)
-
-(switch_default
- "default" @keyword.conditional)
diff --git a/queries/ecma/indents.scm b/queries/ecma/indents.scm
deleted file mode 100644
index d56741670..000000000
--- a/queries/ecma/indents.scm
+++ /dev/null
@@ -1,82 +0,0 @@
-[
- (arguments)
- (array)
- (binary_expression)
- (class_body)
- (export_clause)
- (formal_parameters)
- (named_imports)
- (object)
- (object_pattern)
- (parenthesized_expression)
- (return_statement)
- (statement_block)
- (switch_case)
- (switch_default)
- (switch_statement)
- (template_substitution)
- (ternary_expression)
-] @indent.begin
-
-(arguments
- (call_expression) @indent.begin)
-
-(binary_expression
- (call_expression) @indent.begin)
-
-(expression_statement
- (call_expression) @indent.begin)
-
-(arrow_function
- body: (_) @_body
- (#not-kind-eq? @_body "statement_block")) @indent.begin
-
-(assignment_expression
- right: (_) @_right
- (#not-kind-eq? @_right "arrow_function" "function")) @indent.begin
-
-(variable_declarator
- value: (_) @_value
- (#not-kind-eq? @_value "arrow_function" "call_expression" "function")) @indent.begin
-
-(arguments
- ")" @indent.end)
-
-(object
- "}" @indent.end)
-
-(statement_block
- "}" @indent.end)
-
-[
- (arguments
- (object))
- ")"
- "}"
- "]"
-] @indent.branch
-
-(statement_block
- "{" @indent.branch)
-
-((parenthesized_expression
- "("
- (_)
- ")" @indent.end) @_outer
- (#not-has-parent? @_outer if_statement))
-
-[
- "}"
- "]"
-] @indent.end
-
-(template_string) @indent.ignore
-
-[
- (comment)
- (ERROR)
-] @indent.auto
-
-(if_statement
- consequence: (_) @indent.dedent
- (#not-kind-eq? @indent.dedent statement_block)) @indent.begin
diff --git a/queries/ecma/injections.scm b/queries/ecma/injections.scm
deleted file mode 100644
index 04abafcde..000000000
--- a/queries/ecma/injections.scm
+++ /dev/null
@@ -1,203 +0,0 @@
-(((comment) @_jsdoc_comment
- (#lua-match? @_jsdoc_comment "^/[*][*][^*].*[*]/$")) @injection.content
- (#set! injection.language "jsdoc"))
-
-((comment) @injection.content
- (#set! injection.language "comment"))
-
-; html(`...`), html`...`, sql(`...`), etc.
-(call_expression
- function: (identifier) @injection.language
- arguments: [
- (arguments
- (template_string) @injection.content)
- (template_string) @injection.content
- ]
- (#lua-match? @injection.language "^[a-zA-Z][a-zA-Z0-9]*$")
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- ; Languages excluded from auto-injection due to special rules
- ; - svg uses the html parser
- ; - css uses the styled parser
- (#not-any-of? @injection.language "svg" "css"))
-
-; svg`...` or svg(`...`)
-(call_expression
- function: (identifier) @_name
- (#eq? @_name "svg")
- arguments: [
- (arguments
- (template_string) @injection.content)
- (template_string) @injection.content
- ]
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "html"))
-
-; Vercel PostgreSQL
-; foo.sql`...` or foo.sql(`...`)
-(call_expression
- function: (member_expression
- property: (property_identifier) @injection.language)
- arguments: [
- (arguments
- (template_string) @injection.content)
- (template_string) @injection.content
- ]
- (#eq? @injection.language "sql")
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children))
-
-(call_expression
- function: (identifier) @_name
- (#eq? @_name "gql")
- arguments: (template_string) @injection.content
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "graphql"))
-
-(call_expression
- function: (identifier) @_name
- (#eq? @_name "hbs")
- arguments: (template_string) @injection.content
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "glimmer"))
-
-; css`<css>`, keyframes`<css>`
-(call_expression
- function: (identifier) @_name
- (#any-of? @_name "css" "keyframes")
- arguments: (template_string) @injection.content
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "styled"))
-
-; styled.div`<css>`
-(call_expression
- function: (member_expression
- object: (identifier) @_name
- (#eq? @_name "styled"))
- arguments: ((template_string) @injection.content
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "styled")))
-
-; styled(Component)`<css>`
-(call_expression
- function: (call_expression
- function: (identifier) @_name
- (#eq? @_name "styled"))
- arguments: ((template_string) @injection.content
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "styled")))
-
-; styled.div.attrs({ prop: "foo" })`<css>`
-(call_expression
- function: (call_expression
- function: (member_expression
- object: (member_expression
- object: (identifier) @_name
- (#eq? @_name "styled"))))
- arguments: ((template_string) @injection.content
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "styled")))
-
-; styled(Component).attrs({ prop: "foo" })`<css>`
-(call_expression
- function: (call_expression
- function: (member_expression
- object: (call_expression
- function: (identifier) @_name
- (#eq? @_name "styled"))))
- arguments: ((template_string) @injection.content
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "styled")))
-
-((regex_pattern) @injection.content
- (#set! injection.language "regex"))
-
-; ((comment) @_gql_comment
-; (#eq? @_gql_comment "/* GraphQL */")
-; (template_string) @injection.content
-; (#set! injection.language "graphql"))
-((template_string) @injection.content
- (#lua-match? @injection.content "^`#graphql")
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "graphql"))
-
-; el.innerHTML = `<html>`
-(assignment_expression
- left: (member_expression
- property: (property_identifier) @_prop
- (#any-of? @_prop "outerHTML" "innerHTML"))
- right: (template_string) @injection.content
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "html"))
-
-; el.innerHTML = '<html>'
-(assignment_expression
- left: (member_expression
- property: (property_identifier) @_prop
- (#any-of? @_prop "outerHTML" "innerHTML"))
- right: (string
- (string_fragment) @injection.content)
- (#set! injection.language "html"))
-
-;---- Angular injections -----
-; @Component({
-; template: `<html>`
-; })
-(decorator
- (call_expression
- function: ((identifier) @_name
- (#eq? @_name "Component"))
- arguments: (arguments
- (object
- (pair
- key: ((property_identifier) @_prop
- (#eq? @_prop "template"))
- value: ((template_string) @injection.content
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "angular")))))))
-
-; @Component({
-; styles: [`<css>`]
-; })
-(decorator
- (call_expression
- function: ((identifier) @_name
- (#eq? @_name "Component"))
- arguments: (arguments
- (object
- (pair
- key: ((property_identifier) @_prop
- (#eq? @_prop "styles"))
- value: (array
- ((template_string) @injection.content
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.include-children)
- (#set! injection.language "css"))))))))
-
-; @Component({
-; styles: `<css>`
-; })
-(decorator
- (call_expression
- function: ((identifier) @_name
- (#eq? @_name "Component"))
- arguments: (arguments
- (object
- (pair
- key: ((property_identifier) @_prop
- (#eq? @_prop "styles"))
- value: ((template_string) @injection.content
- (#set! injection.include-children)
- (#offset! @injection.content 0 1 0 -1)
- (#set! injection.language "css")))))))
diff --git a/queries/ecma/locals.scm b/queries/ecma/locals.scm
deleted file mode 100644
index 24ea7c0a8..000000000
--- a/queries/ecma/locals.scm
+++ /dev/null
@@ -1,42 +0,0 @@
-; Scopes
-;-------
-(statement_block) @local.scope
-
-(function_expression) @local.scope
-
-(arrow_function) @local.scope
-
-(function_declaration) @local.scope
-
-(method_definition) @local.scope
-
-(for_statement) @local.scope
-
-(for_in_statement) @local.scope
-
-(catch_clause) @local.scope
-
-; Definitions
-;------------
-(variable_declarator
- name: (identifier) @local.definition.var)
-
-(import_specifier
- (identifier) @local.definition.import)
-
-(namespace_import
- (identifier) @local.definition.import)
-
-(function_declaration
- (identifier) @local.definition.function
- (#set! definition.var.scope parent))
-
-(method_definition
- (property_identifier) @local.definition.function
- (#set! definition.var.scope parent))
-
-; References
-;------------
-(identifier) @local.reference
-
-(shorthand_property_identifier) @local.reference