diff --git a/runtime/queries/_typescript/highlights.scm b/runtime/queries/_typescript/highlights.scm index a83b43475..f9a672667 100644 --- a/runtime/queries/_typescript/highlights.scm +++ b/runtime/queries/_typescript/highlights.scm @@ -107,6 +107,8 @@ ; Types ; ----- +(type_parameter + name: (type_identifier) @type.parameter) (type_identifier) @type (predefined_type) @type.builtin diff --git a/runtime/queries/_typescript/locals.scm b/runtime/queries/_typescript/locals.scm index fe13f21d3..041ad59d1 100644 --- a/runtime/queries/_typescript/locals.scm +++ b/runtime/queries/_typescript/locals.scm @@ -1,6 +1,18 @@ +; Scopes +;------- + +[ + (type_alias_declaration) + (class_declaration) + (interface_declaration) +] @local.scope + ; Definitions ;------------ +(type_parameter + name: (type_identifier) @local.definition) + ; Javascript and Typescript Treesitter grammars deviate when defining the ; tree structure for parameters, so we need to address them in each specific ; language instead of ecma. @@ -14,3 +26,8 @@ ; (i?: t = 1) // Invalid but still posible to hihglight. (optional_parameter (identifier) @local.definition) + +; References +;----------- + +(type_identifier) @local.reference diff --git a/runtime/queries/go/highlights.scm b/runtime/queries/go/highlights.scm index b45a11bee..fba2df99e 100644 --- a/runtime/queries/go/highlights.scm +++ b/runtime/queries/go/highlights.scm @@ -11,6 +11,18 @@ function: (selector_expression field: (field_identifier) @function.method)) + +; Types + +(type_parameter_list + (parameter_declaration + name: (identifier) @type.parameter)) + +((type_identifier) @type.builtin + (match? @type.builtin "^(any|bool|byte|comparable|complex128|complex64|error|float32|float64|int|int16|int32|int64|int8|rune|string|uint|uint16|uint32|uint64|uint8|uintptr)$")) + +(type_identifier) @type + ; Function definitions (function_declaration @@ -30,10 +42,6 @@ (parameter_declaration (identifier) @variable.parameter) (variadic_parameter_declaration (identifier) @variable.parameter) -((type_identifier) @type.builtin - (match? @type.builtin "^(any|bool|byte|comparable|complex128|complex64|error|float32|float64|int|int16|int32|int64|int8|rune|string|uint|uint16|uint32|uint64|uint8|uintptr)$")) - -(type_identifier) @type (type_spec name: (type_identifier) @constructor) (field_identifier) @variable.other.member diff --git a/runtime/queries/go/locals.scm b/runtime/queries/go/locals.scm index aae562571..14a6f3e43 100644 --- a/runtime/queries/go/locals.scm +++ b/runtime/queries/go/locals.scm @@ -1,9 +1,17 @@ ; Scopes -(block) @local.scope +[ + (function_declaration) + (type_declaration) + (block) +] @local.scope ; Definitions +(type_parameter_list + (parameter_declaration + name: (identifier) @local.definition)) + (parameter_declaration (identifier) @local.definition) (variadic_parameter_declaration (identifier) @local.definition) @@ -27,4 +35,4 @@ (identifier) @local.reference (field_identifier) @local.reference - +(type_identifier) @local.reference diff --git a/runtime/queries/haskell/highlights.scm b/runtime/queries/haskell/highlights.scm index 18c57c930..3d416de8d 100644 --- a/runtime/queries/haskell/highlights.scm +++ b/runtime/queries/haskell/highlights.scm @@ -124,7 +124,7 @@ ;; Types (type) @type -(type_variable) @type +(type_variable) @type.parameter (constructor) @constructor diff --git a/runtime/queries/kotlin/highlights.scm b/runtime/queries/kotlin/highlights.scm index 208a673f3..5b19f849e 100644 --- a/runtime/queries/kotlin/highlights.scm +++ b/runtime/queries/kotlin/highlights.scm @@ -244,7 +244,10 @@ . (identifier)) @namespace ((type_identifier) @type.builtin - (#match? @function.builtin "^(Byte|Short|Int|Long|UByte|UShort|UInt|ULong|Float|Double|Boolean|Char|String|Array|ByteArray|ShortArray|IntArray|LongArray|UByteArray|UShortArray|UIntArray|ULongArray|FloatArray|DoubleArray|BooleanArray|CharArray|Map|Set|List|EmptyMap|EmptySet|EmptyList|MutableMap|MutableSet|MutableList)$")) + (#match? @type.builtin "^(Byte|Short|Int|Long|UByte|UShort|UInt|ULong|Float|Double|Boolean|Char|String|Array|ByteArray|ShortArray|IntArray|LongArray|UByteArray|UShortArray|UIntArray|ULongArray|FloatArray|DoubleArray|BooleanArray|CharArray|Map|Set|List|EmptyMap|EmptySet|EmptyList|MutableMap|MutableSet|MutableList)$")) + +(type_parameter + (type_identifier) @type.parameter) (type_identifier) @type diff --git a/runtime/queries/kotlin/locals.scm b/runtime/queries/kotlin/locals.scm new file mode 100644 index 000000000..752ed995e --- /dev/null +++ b/runtime/queries/kotlin/locals.scm @@ -0,0 +1,15 @@ +; Scopes + +[ + (class_declaration) + (function_declaration) +] @local.scope + +; Definitions + +(type_parameter + (type_identifier) @local.definition) + +; References + +(type_identifier) @local.reference diff --git a/runtime/queries/ocaml/highlights.scm b/runtime/queries/ocaml/highlights.scm index a08b12670..9d3bf4c8b 100644 --- a/runtime/queries/ocaml/highlights.scm +++ b/runtime/queries/ocaml/highlights.scm @@ -8,6 +8,8 @@ [(class_name) (class_type_name) (type_constructor)] @type +(type_variable) @type.parameter + [(constructor_name) (tag)] @constructor ; Functions