Clean up/harmonize scopes…

…to conform better to the documentation I just wrote at

https://gist.github.com/savetheclocktower/c9607b97477d4817911e4f2f8db89679#file-scope-taxonomy-md.
This commit is contained in:
Andrew Dupont 2023-03-31 00:02:30 -07:00
parent 033f5c6498
commit d9347d6c57
12 changed files with 416 additions and 139 deletions

View File

@ -174,11 +174,11 @@
; The "foo" in `thing->troz->foo(...)`.
(call_expression
(field_expression
field: (field_identifier) @support.function.other.c)
field: (field_identifier) @support.other.function.c)
(#set! final true))
(call_expression
(identifier) @support.function.other.c
(identifier) @support.other.function.c
(#set! final true))
; NUMBERS
@ -295,12 +295,28 @@
"," @punctuation.separator.comma.c
"->" @punctuation.separator.pointer-access.c
"{" @punctuation.definition.begin.brace.curly.c
"}" @punctuation.definition.end.brace.curly.c
"(" @punctuation.definition.begin.brace.round.c
")" @punctuation.definition.end.brace.round.c
"[" @punctuation.definition.begin.brace.square.c
"]" @punctuation.definition.end.brace.square.c
(parameter_list
"(" @punctuation.definition.parameters.begin.bracket.round.c
")" @punctuation.definition.parameters.end.bracket.round.c
(#set! final true))
(parenthesized_expression
"(" @punctuation.definition.expression.begin.bracket.round.c
")" @punctuation.definition.expression.end.bracket.round.c
(#set! final true))
(if_statement
condition: (parenthesized_expression
"(" @punctuation.definition.expression.begin.bracket.round.c
")" @punctuation.definition.expression.end.bracket.round.c
(#set! final true)))
"{" @punctuation.definition.block.begin.bracket.curly.c
"}" @punctuation.definition.block.end.bracket.curly.c
"(" @punctuation.definition.begin.bracket.round.c
")" @punctuation.definition.end.bracket.round.c
"[" @punctuation.definition.array.begin.bracket.square.c
"]" @punctuation.definition.array.end.bracket.square.c
; TODO:
;

View File

@ -118,11 +118,11 @@
; The "foo" in `thing->troz->foo(...)`.
(call_expression
(field_expression
field: (field_identifier) @support.function.other.cpp)
field: (field_identifier) @support.other.function.cpp)
(#set! final true))
(call_expression
(identifier) @support.function.other.cpp
(identifier) @support.other.function.cpp
(#set! final true))
@ -355,17 +355,33 @@
; PUNCTUATION
; ===========
";" @punctuation.terminator.statement.cpp
";" @punctuation.terminator.statement.c
"," @punctuation.separator.comma.cpp
"->" @punctuation.separator.pointer-access.cpp
"," @punctuation.separator.comma.c
"->" @punctuation.separator.pointer-access.c
"{" @punctuation.definition.begin.brace.curly.cpp
"}" @punctuation.definition.end.brace.curly.cpp
"(" @punctuation.definition.begin.brace.round.cpp
")" @punctuation.definition.end.brace.round.cpp
"[" @punctuation.definition.begin.brace.square.cpp
"]" @punctuation.definition.end.brace.square.cpp
(parameter_list
"(" @punctuation.definition.parameters.begin.bracket.round.c
")" @punctuation.definition.parameters.end.bracket.round.c
(#set! final true))
(parenthesized_expression
"(" @punctuation.definition.expression.begin.bracket.round.c
")" @punctuation.definition.expression.end.bracket.round.c
(#set! final true))
(if_statement
condition: (condition_clause
"(" @punctuation.definition.expression.begin.bracket.round.c
")" @punctuation.definition.expression.end.bracket.round.c
(#set! final true)))
"{" @punctuation.definition.block.begin.bracket.curly.c
"}" @punctuation.definition.block.end.bracket.curly.c
"(" @punctuation.definition.begin.bracket.round.c
")" @punctuation.definition.end.bracket.round.c
"[" @punctuation.definition.array.begin.bracket.square.c
"]" @punctuation.definition.array.end.bracket.square.c
; TODO:
;
@ -373,12 +389,3 @@
; present if this wasn't converted from a TextMate grammar, so I'm leaving
; them out for now.
;
; (
; (compound_statement) @invalid.illegal
; )
(compound_statement
(compound_statement) @invalid.illegal
)

View File

@ -30,7 +30,12 @@
; TYPES
; =====
(type_identifier) @storage.type._TYPE_.go
(type_declaration
(type_spec
name: (type_identifier) @entity.name.type.go)
(#set! final true))
(type_identifier) @storage.other.type.go
[
"func"
@ -38,6 +43,22 @@
"package"
] @keyword._TYPE_.go
"type" @storage.type.go
[
"struct"
] @storage.type._TYPE_.go
(struct_type
(field_declaration_list
(field_declaration
(field_identifier) @entity.other.attribute-name.go)))
(keyed_element
(field_identifier) @entity.other.attribute-name.go
.
":" @punctuation.separator.key-value.go)
[
"break"
"case"
@ -56,6 +77,7 @@
"switch"
] @keyword.control._TYPE_.go
(function_declaration (identifier) @entity.name.function.go)
(call_expression
@ -64,25 +86,25 @@
(#set! final true))
(call_expression
(identifier) @support.function.other.go)
(identifier) @support.other.function.go)
(call_expression
(selector_expression
field: (field_identifier) @support.function.other.go))
field: (field_identifier) @support.other.function.go))
; OBJECTS
; =======
(selector_expression
operand: (selector_expression
operand: (identifier) @support.object.other.go
field: (field_identifier) @support.object.other.go))
operand: (identifier) @support.other.object.go
field: (field_identifier) @support.other.object.go))
; TODO: If we do this, then we have to do chaining (`a.b.c.Close()`) and that
; won't be fun.
(selector_expression
operand: (identifier) @support.object.other.go)
operand: (identifier) @support.other.object.go)
; PACKAGES
; ========
@ -232,12 +254,23 @@
"," @punctuation.separator.comma.go
":" @punctuation.separator.colon.go
"{" @punctuation.definition.begin.brace.curly.go
"}" @punctuation.definition.end.brace.curly.go
"(" @punctuation.definition.begin.brace.round.go
")" @punctuation.definition.end.brace.round.go
"[" @punctuation.definition.begin.brace.square.go
"]" @punctuation.definition.end.brace.square.go
(parameter_list
"(" @punctuation.definition.parameters.begin.bracket.round.go
")" @punctuation.definition.parameters.end.bracket.round.go
(#set! final true))
(composite_literal
body: (literal_value
"{" @punctuation.definition.struct.begin.bracket.curly.go
"}" @punctuation.definition.struct.end.bracket.curly.go
(#set! final true)))
"{" @punctuation.definition.begin.bracket.curly.go
"}" @punctuation.definition.end.bracket.curly.go
"(" @punctuation.definition.group.begin.bracket.round.go
")" @punctuation.definition.group.end.bracket.round.go
"[" @punctuation.definition.begin.bracket.square.go
"]" @punctuation.definition.end.bracket.square.go
; META
; ====

View File

@ -104,7 +104,7 @@
; =====
(object_creation_expression (type_identifier)
@support.class.other.java
@support.other.class.java
(#set! final true))
; WORKAROUND: This matches often when the user is typing, so we shouldn't
@ -182,20 +182,20 @@
(throws "throws" @storage.modifier.throws.java)
(method_invocation (identifier)
@support.function.other.java)
@support.other.function.java)
(field_access (identifier) @constant.other.java
(#match? @constant.other.java "^[A-Z][A-Z0-9_\\$]+$")
(#set! final true))
(field_access
object: (identifier) @support.class.other.java
(#match? @support.class.other.java "^[A-Z]")
object: (identifier) @support.other.class.java
(#match? @support.other.class.java "^[A-Z]")
(#set! final true))
(field_access
field: (identifier) @support.class.other.java
(#match? @support.class.other.java "^[A-Z]")
field: (identifier) @support.other.class.java
(#match? @support.other.class.java "^[A-Z]")
(#set! final true))
@ -374,15 +374,32 @@
"," @punctuation.separator.comma.java
"->" @punctuation.separator.lambda.java
"{" @punctuation.definition.begin.brace.curly.java
"}" @punctuation.definition.end.brace.curly.java
"(" @punctuation.definition.begin.brace.round.java
")" @punctuation.definition.end.brace.round.java
"[" @punctuation.definition.begin.brace.square.java
"]" @punctuation.definition.end.brace.square.java
(if_statement
condition: (parenthesized_expression
"(" @punctuation.definition.expression.begin.bracket.round.java
")" @punctuation.definition.expression.end.bracket.round.java
(#set! final true)))
(type_arguments "<" @punctuation.definition.begin.brace.angle.java)
(type_arguments ">" @punctuation.definition.end.brace.angle.java)
(formal_parameters
"(" @punctuation.definition.parameters.begin.bracket.round.java
")" @punctuation.definition.parameters.end.bracket.round.java
(#set! final true))
(type_parameters "<" @punctuation.definition.begin.brace.angle.java)
(type_parameters ">" @punctuation.definition.end.brace.angle.java)
(argument_list
"(" @punctuation.definition.arguments.begin.bracket.round.java
")" @punctuation.definition.arguments.end.bracket.round.java
(#set! final true))
"{" @punctuation.definition.block.begin.bracket.curly.java
"}" @punctuation.definition.block.end.bracket.curly.java
"(" @punctuation.definition.expression.begin.bracket.round.java
")" @punctuation.definition.expression.end.bracket.round.java
"[" @punctuation.definition.array.begin.bracket.square.java
"]" @punctuation.definition.array.end.bracket.square.java
(type_arguments "<" @punctuation.definition.type.begin.bracket.angle.java)
(type_arguments ">" @punctuation.definition.type.end.bracket.angle.java)
(type_parameters "<" @punctuation.definition.type.begin.bracket.angle.java)
(type_parameters ">" @punctuation.definition.type.end.bracket.angle.java)

View File

@ -196,14 +196,12 @@
; Generator function definitions:
; the "foo" in `function* foo () {`
(generator_function_declaration
name: (identifier) @entity.name.function.generator.definition.js
)
name: (identifier) @entity.name.function.generator.definition.js)
; Method definitions:
; the "foo" in `foo () {` (inside a class body)
(method_definition
name: (property_identifier) @entity.name.function.method.definition.js
)
name: (property_identifier) @entity.name.function.method.definition.js)
; Function property assignment:
; The "foo" in `thing.foo = (arg) => {}`
@ -239,19 +237,118 @@
(generator_function "*" @storage.modifier.generator.js)
(generator_function_declaration "*" @storage.modifier.generator.js)
(method_definition "*" @storage.modifier.generator.js)
; FUNCTION CALLS
; ==============
; SUPPORT
; =======
; An invocation of any function.
; Array methods.
(member_expression
object: (identifier) @support.object.builtin.js
(#eq? @support.object.builtin.js "Array")
property: (property_identifier) @support.function.builtin.js
(#match? @support.function.builtin.js "^(from|isArray|of)$")
(#set! final true))
; Date methods.
(member_expression
object: (identifier) @support.object.builtin.js
(#eq? @support.object.builtin.js "Date")
property: (property_identifier) @support.function.builtin.js
(#match? @support.function.builtin.js "^(now|parse|UTC)$")
(#set! final true))
; JSON methods.
(member_expression
object: (identifier) @support.object.builtin.js
(#eq? @support.object.builtin.js "JSON")
property: (property_identifier) @support.function.builtin.js
(#match? @support.function.builtin.js "^(parse|stringify)$")
(#set! final true))
; Math methods.
(member_expression
object: (identifier) @support.object.builtin.js
(#eq? @support.object.builtin.js "Math")
property: (property_identifier) @support.function.builtin.js
(#match? @support.function.builtin.js "^(abs|acos|acosh|asin|asinh|atan|atanh|atan2|cbrt|ceil|clz32|cos|cosh|exp|expm1|floor|fround|hypot|imul|log|log1p|log10|log2|max|min|pow|random|round|sign|sin|sinh|sqrt|tan|tanh|trunc)$")
(#set! final true))
; Object methods.
(member_expression
object: (identifier) @support.object.builtin.js
(#eq? @support.object.builtin.js "Object")
property: (property_identifier) @support.function.builtin.js
(#match? @support.function.builtin.js "^(assign|create|defineProperty|defineProperties|entries|freeze|fromEntries|getOwnPropertyDescriptor|getOwnPropertyDescriptors|getOwnPropertyNames|getOwnPropertySymbols|getPrototypeOf|is|isExtensible|isFrozen|isSealed|keys|preventExtensions|seal|setPrototypeOf|values)$")
(#set! final true))
; Reflect methods.
(member_expression
object: (identifier) @support.object.builtin.js
(#eq? @support.object.builtin.js "Reflect")
property: (property_identifier) @support.function.builtin.js
(#match? @support.function.builtin.js "^(apply|construct|defineProperty|deleteProperty|get|getOwnPropertyDescriptor|getPrototypeOf|has|isExtensible|ownKeys|preventExtensions|set|setPrototypeOf)$")
(#set! final true))
; Intl.X instantiations.
(new_expression
constructor: (member_expression
object: (identifier) @support.object.builtin.js
(#eq? @support.object.builtin.js "Intl")
property: (property_identifier) @support.class.builtin.js
(#match? @support.class.builtin.js "^(Collator|DateTimeFormat|DisplayNames|ListFormat|Locale|NumberFormat|PluralRules|Segmenter)$"))
(#set! final true))
; Built-in class instantiations.
(new_expression
constructor: (identifier) @support.class.instance.js
(#match? @support.class.instance.js "^(AggregateError|Array|ArrayBuffer|BigInt64Array|BigUint64Array|Boolean|DataView|Date|Error|EvalError|FinalizationRegistry|Float32Array|Float64Array|Function|ImageCapture|Int8Array|Int16Array|Int32Array|Map|Number|Object|Promise|RangeError|ReferenceError|RegExp|Set|String|SyntaxError|TypeError|Uint8Array|Uint8ClampedArray|Uint16Array|Uint32Array|URIError|URL|WeakMap|WeakRef|WeakSet|XMLHttpRequest)$")
(#set! final true))
; Built-in constructors that can be invoked without `new`.
(call_expression
function: (identifier) @support.function.other.js)
(identifier) @support.function.builtin.js
(#match? @support.function.builtin.js "^(AggregateError|Array|ArrayBuffer|Boolean|BigInt|Error|EvalError|Function|Number|Object|Proxy|RangeError|String|Symbol|SyntaxError|URIError)$")
(#set! final true))
; An invocation of any method.
; Built-in functions.
(call_expression
(identifier) @support.function.builtin.js
(#match? @support.function.builtin.js "^(decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt)$"))
; Deprecated built-in functions.
(call_expression
(identifier) @invalid.deprecated.function.js
(#match? @invalid.deprecated.function.js "^(escape|unescape)$")
(#set! final true))
; Built-in DOM classes.
((identifier) @support.class.builtin.js
(#match? @support.class.builtin.js "^(Document|Element|HTMLElement|HTMLDocument|HTML(Select|BR|HR|LI|Div|Map|Mod|Pre|Area|Base|Body|Data|Font|Form|Head|Html|Link|Menu|Meta|Slot|Span|Time|Audio|DList|Embed|Image|Input|Label|Media|Meter|OList|Param|Quote|Style|Table|Title|Track|UList|Video|Anchor|Button|Canvas|Dialog|IFrame|Legend|Object|Option|Output|Script|Source|Content|Details|Heading|Marquee|Picture|Unknown|DataList|FieldSet|FrameSet|MenuItem|OptGroup|Progress|TableCol|TableRow|Template|TextArea|Paragraph|TableCell|Options|TableCaption|TableSection|FormControls))$")
(#set! final true))
; Deprecated built-in DOM classes.
((identifier) @invalid.deprecated.class.js
(#match? @invalid.deprecated.class.js "^(HTMLShadowElement)$")
(#set! final true))
; Built-in DOM methods on `document`.
(call_expression
function: (member_expression
property: (property_identifier) @support.function.other.method.js))
object: (identifier) @support.object.builtin.js
(#eq? @support.object.builtin.js "document")
property: (property_identifier) @support.function.method.builtin.js
(#match? @support.function.method.builtin.js "^(adoptNode|append|caretPositionFromPoint|caretRangeFromPoint|createAttribute(?:NS)?|createCDATASection|createComment|createDocumentFragment|createElement(?:NS)?|createEvent|createNodeIterator|createProcessingInstruction|createRange|createTextNode|createTreeWalker|elementFromPoint|elementsFromPoint|exitFullscreen|exitPictureInPicture|exitPointerLock|getAnimations|getElementById|getElementsByClassName|getElementsByTagName(?:NS)?|getSelection|hasStorageAccess|importNode|prepend|querySelector|querySelectorAll|releaseCapture|replaceChildren|requestStorageAccess|createExpression|createNSResolver|evaluate|getElementsByName|hasFocus|write|writeln|open|close)$")
(#set! final true)))
; Built-in DOM methods on nodes. These will show up as builtins on _any_ class, but
; they're distinctive enough that we're OK with that possibility.
(call_expression
function: (member_expression
property: (property_identifier) @support.function.method.builtin.js
(#match? @support.function.method.builtin.js "^(addEventListener|appendChild|cloneNode|compareDocumentPosition|contains|getElementsByClassName|getElementsByTagName(?:NS)?|getRootNode|hasChildNodes|insertBefore|isDefaultNamespace|isEqualNode|isSameNode|lookupPrefix|lookupNamespaceURI|normalize|querySelector|querySelectorAll|removeChild|replaceChild|removeEventListener)$")
(#set! final true)))
; OBJECTS
@ -259,12 +356,12 @@
; The "foo" in `foo.bar`.
(member_expression
object: (identifier) @support.object.other.js)
object: (identifier) @support.other.object.js)
; The "bar" in `foo.bar.baz`.
(member_expression
object: (member_expression
property: (property_identifier) @support.object.other.js))
property: (property_identifier) @support.other.property.js))
; The "foo" in `{ foo: true }`.
(pair
@ -276,6 +373,18 @@
(shorthand_property_identifier) @entity.other.attribute-name.shorthand.js)
; FUNCTION CALLS
; ==============
; An invocation of any function.
(call_expression
function: (identifier) @support.other.function.js)
; An invocation of any method.
(call_expression
function: (member_expression
property: (property_identifier) @support.other.function.method.js))
; CLASSES
; =======
@ -292,12 +401,9 @@
"extends" @storage.modifier.extends.js
(identifier) @entity.other.inherited-class.js)
; The interior of a class body (useful for snippets and commands).
(class_body) @meta.class.body
; The "Foo" in `new Foo()`.
(new_expression
constructor: (_) @support.class.instance.js)
constructor: (identifier) @support.other.class.instance.js)
; A class getter:
; the "get" in `get foo () {...`
@ -494,7 +600,7 @@
; The "Foo" in `<Foo />`.
(jsx_self_closing_element
name: (identifier) @entity.name.tag.js
) @meta.tag.js.jsx
) @meta.tag.js
; The "Foo" in `<Foo>`.
(jsx_opening_element
@ -508,10 +614,10 @@
; The "bar" in `<Foo bar={true} />`.
(jsx_attribute
(property_identifier) @entity.other.attribute-name.js.jsx)
(property_identifier) @entity.other.attribute-name.js)
; All JSX expressions/interpolations within braces.
(jsx_expression) @meta.embedded.js.jsx
(jsx_expression) @meta.embedded.js
(jsx_opening_element
"<" @punctuation.definition.tag.begin.js
@ -522,7 +628,7 @@
">" @punctuation.definition.tag.end.js)
(jsx_self_closing_element
"<" @punctuation.definition.tag.begin.js.jsx
"<" @punctuation.definition.tag.begin.js
(#set! final true))
((jsx_self_closing_element
@ -608,17 +714,73 @@
; PUNCTUATION
; ===========
"{" @punctuation.definition.begin.brace.curly.js
"}" @punctuation.definition.end.brace.curly.js
"(" @punctuation.definition.begin.brace.round.js
")" @punctuation.definition.end.brace.round.js
"[" @punctuation.definition.begin.brace.square.js
"]" @punctuation.definition.end.brace.square.js
(formal_parameters
"(" @punctuation.definition.parameters.begin.bracket.round.js
")"@punctuation.definition.parameters.end.bracket.round.js
(#set! final true))
(object
"{" @punctuation.definition.object.begin.bracket.curly.js
"}" @punctuation.definition.object.end.bracket.curly.js
(#set! final true))
(arguments
"(" @punctuation.definition.arguments.begin.bracket.round.js
")" @punctuation.definition.arguments.end.bracket.round.js
(#set! final true))
(computed_property_name
"[" @punctuation.definition.computed-property.begin.bracket.square.js
"]" @punctuation.definition.computed-property.end.bracket.square.js
(#set! final true))
(subscript_expression
"[" @punctuation.definition.subscript.begin.bracket.square.js
"]" @punctuation.definition.subscript.end.bracket.square.js
(#set! final true))
(array
"[" @punctuation.definition.array.begin.bracket.square.js
"]" @punctuation.definition.array.end.bracket.square.js
(#set! final true))
(array_pattern
"[" @punctuation.definition.array.begin.bracket.square.js
"]" @punctuation.definition.array.end.bracket.square.js
(#set! final true))
"{" @punctuation.definition.block.begin.bracket.curly.js
"}" @punctuation.definition.block.end.bracket.curly.js
"(" @punctuation.definition.begin.bracket.round.js
")" @punctuation.definition.end.bracket.round.js
"[" @punctuation.definition.begin.bracket.square.js
"]" @punctuation.definition.end.bracket.square.js
(array
"," @punctuation.separator.array.comma.js
(#set! final true))
(array_pattern
"," @punctuation.separator.array.comma.js
(#set! final true))
(pair
":" @punctuation.separator.key-value.colon.js
(#set! final true))
";" @punctuation.terminator.statement.js
"," @punctuation.separator.comma.js
":" @punctuation.separator.colon.js
; META
; ====
(statement_block) @meta.block.js
; The interior of a class body (useful for snippets and commands).
(class_body) @meta.block.class.js
(formal_parameters) @meta.parameters.js
; MISC
; ====

View File

@ -26,13 +26,21 @@
; PUNCTUATION
; ===========
"{" @punctuation.definition.begin.brace.curly.json
"}" @punctuation.definition.end.brace.curly.json
"[" @punctuation.definition.begin.brace.square.json
"]" @punctuation.definition.end.brace.square.json
"{" @punctuation.definition.object.begin.bracket.curly.json
"}" @punctuation.definition.object.end.bracket.curly.json
"[" @punctuation.definition.array.begin.bracket.square.json
"]" @punctuation.definition.array.end.bracket.square.json
(object
"," @punctuation.separator.object.comma.json
(#set! final true))
(array
"," @punctuation.separator.array.comma.json
(#set! final true))
"," @punctuation.separator.comma.json
":" @punctuation.separator.colon.json
":" @punctuation.separator.key-value.colon.json
; ERROR HANDLING
; ==============

View File

@ -40,7 +40,8 @@
; Function calls
; --------------
(decorator) @keyword.other.special-method.decorator.python
(decorator) @support.other.function.decorator.python
; (decorator) @keyword.other.special-method.decorator.python
(call
function: (identifier) @support.function.builtin.python
@ -48,10 +49,10 @@
(call
function: (attribute
attribute: (identifier) @support.function.other.python))
attribute: (identifier) @support.other.function.python))
(call
function: (identifier) @support.function.other.python)
function: (identifier) @support.other.function.python)
; Function definitions
@ -62,7 +63,7 @@
(#match? @entity.name.function.magic.python "^__(?:abs|add|and|bool|bytes|call|cmp|coerce|complex|contains|del|delattr|delete|delitem|delslice|dir|div|divmod|enter|eq|exit|float|floordiv|format|ge|get|getattr|getattribute|getitem|getslice|gt|hash|hex|iadd|iand|idiv|ifloordiv|ilshift|imatmul|imod|imul|index|init|instancecheck|int|invert|ior|ipow|irshift|isub|iter|itruediv|ixor|le|len|length_hint|long|lshift|lt|matmul|missing|mod|mul|ne|neg|next|new|nonzero|oct|or|pos|pow|radd|rand|rdiv|rdivmod|repr|reversed|rfloordiv|rlshift|rmatmul|rmod|rmul|ror|round|rpow|rrshift|rshift|rsub|rtruediv|rxor|set|setattr|setitem|setslice|str|sub|subclasscheck|truediv|unicode|xor)__$"))
(attribute
attribute: (identifier) @entity.other.attribute-name.python)
attribute: (identifier) @support.other.attribute-name.python)
(function_definition
name: (identifier) @entity.name.function.python)
@ -92,8 +93,8 @@
; STRINGS
; =======
((string) @string.quoted.double.block.python
(#match? @string.quoted.double.block.python "^\"\"\""))
((string) @string.quoted.triple.block.python
(#match? @string.quoted.triple.block.python "^\"\"\""))
(string
_ @punctuation.definition.string.begin.python
@ -116,6 +117,15 @@
"}" @punctuation.section.embedded.end.python) @meta.embedded.interpolation.python
; SUPPORT
; =======
((identifier) @support.type.exception.python
(#match? @support.type.exception.python "^(BaseException|Exception|TypeError|StopAsyncIteration|StopIteration|ImportError|ModuleNotFoundError|OSError|ConnectionError|BrokenPipeError|ConnectionAbortedError|ConnectionRefusedError|ConnectionResetError|BlockingIOError|ChildProcessError|FileExistsError|FileNotFoundError|IsADirectoryError|NotADirectoryError|InterruptedError|PermissionError|ProcessLookupError|TimeoutError|EOFError|RuntimeError|RecursionError|NotImplementedError|NameError|UnboundLocalError|AttributeError|SyntaxError|IndentationError|TabError|LookupError|IndexError|KeyError|ValueError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|AssertionError|ArithmeticError|FloatingPointError|OverflowError|ZeroDivisionError|SystemError|ReferenceError|BufferError|MemoryError|Warning|UserWarning|DeprecationWarning|PendingDeprecationWarning|SyntaxWarning|RuntimeWarning|FutureWarning|ImportWarning|UnicodeWarning|BytesWarning|ResourceWarning|GeneratorExit|SystemExit|KeyboardInterrupt)$")
(#set! final true))
; CONSTANTS
; =========
@ -176,6 +186,10 @@
"match"
] @keyword.control._TYPE_.python
[
"raise"
] @keyword.control._TYPE_.python
; VARIABLES
; =========
@ -187,8 +201,7 @@
(default_parameter
(identifier) @variable.parameter.function.python))
(
(identifier) @variable.language.self.python
((identifier) @variable.language.self.python
(#eq? @variable.language.self.python "self")
(#set! final true))
@ -262,6 +275,33 @@
; PUNCTUATION
; ===========
; (attribute ".") @punctuation.separator.property.period.python
(function_definition
":" @punctuation.definition.function.begin.python)
":" @punctuation.definition.function.colon.python
(#set! final true))
(parameters
"(" @punctuation.definition.parameters.begin.bracket.round.python
")" @punctuation.definition.parameters.end.bracket.round.python
(#set! final true))
(parameters
"," @punctuation.separator.parameters.comma.python
(#set! final true))
(tuple
"(" @punctuation.definition.tuple.begin.bracket.round.python
")" @punctuation.definition.tuple.end.bracket.round.python
(#set! final true))
(tuple
"," @punctuation.separator.tuple.comma.python
(#set! final true))
(dictionary
"{" @punctuation.definition.dictionary.begin.bracket.curly.python
"}" @punctuation.definition.dictionary.end.bracket.curly.python
(#set! final true))
(dictionary
"," @punctuation.separator.dictionary.comma.python
(#set! final true))

View File

@ -1,3 +1,6 @@
(dictionary
":" @_IGNORE_
(#set! final true))
":" @indent

View File

@ -32,36 +32,36 @@
; -----------
; Wrap the "foo" and "!" of `foo!()`.
((macro_invocation) @support.function.other.rust
((macro_invocation) @support.other.function.rust
(#set! endAt firstChild.nextSibling.endPosition))
(call_expression
function: (identifier) @support.function.other.rust)
function: (identifier) @support.other.function.rust)
(call_expression
(scoped_identifier
name: (_) @support.function.other.rust))
name: (_) @support.other.function.rust))
(call_expression
function: (field_expression
field: (field_identifier) @support.function.other.method.rust))
field: (field_identifier) @support.other.function.method.rust))
(call_expression
function: (scoped_identifier
"::"
name: (identifier) @support.function.other.rust))
name: (identifier) @support.other.function.rust))
(generic_function
function: (identifier) @support.function.other.generic.rust)
function: (identifier) @support.other.function.generic.rust)
(generic_function
function: (scoped_identifier
name: (identifier) @support.function.other.generic.rust))
name: (identifier) @support.other.function.generic.rust))
(generic_function
function: (field_expression
field: (field_identifier) @support.function.other.method.rust))
field: (field_identifier) @support.other.function.method.rust))
; TYPES
; ======
@ -248,12 +248,12 @@
; PUNCTUATION
; ===========
"{" @punctuation.definition.begin.brace.curly.rust
"}" @punctuation.definition.end.brace.curly.rust
"(" @punctuation.definition.begin.brace.round.rust
")" @punctuation.definition.end.brace.round.rust
"[" @punctuation.definition.begin.brace.square.rust
"]" @punctuation.definition.end.brace.square.rust
"{" @punctuation.definition.begin.bracket.curly.rust
"}" @punctuation.definition.end.bracket.curly.rust
"(" @punctuation.definition.begin.bracket.round.rust
")" @punctuation.definition.end.bracket.round.rust
"[" @punctuation.definition.begin.bracket.square.rust
"]" @punctuation.definition.end.bracket.square.rust
":" @punctuation.separator.colon.rust

View File

@ -146,12 +146,12 @@
; The "foo" in `foo.bar`.
(member_expression
object: (identifier) @support.object.other.ts.tsx)
object: (identifier) @support.other.object.ts.tsx)
; The "bar" in `foo.bar.baz`.
(member_expression
object: (member_expression
property: (property_identifier) @support.object.other.ts.tsx))
property: (property_identifier) @support.other.object.ts.tsx))
(property_signature
@ -165,7 +165,7 @@
(call_expression
function: (member_expression
property: (property_identifier) @support.function.method.other.ts.tsx))
property: (property_identifier) @support.other.function.method.ts.tsx))
; VARIABLES
; =========
@ -338,12 +338,12 @@
; PUNCTUATION
; ===========
"{" @punctuation.definition.begin.brace.curly.ts.tsx
"}" @punctuation.definition.end.brace.curly.ts.tsx
"(" @punctuation.definition.begin.brace.round.ts.tsx
")" @punctuation.definition.end.brace.round.ts.tsx
"[" @punctuation.definition.begin.brace.square.ts.tsx
"]" @punctuation.definition.end.brace.square.ts.tsx
"{" @punctuation.definition.begin.bracket.curly.ts.tsx
"}" @punctuation.definition.end.bracket.curly.ts.tsx
"(" @punctuation.definition.begin.bracket.round.ts.tsx
")" @punctuation.definition.end.bracket.round.ts.tsx
"[" @punctuation.definition.begin.bracket.square.ts.tsx
"]" @punctuation.definition.end.bracket.square.ts.tsx
";" @punctuation.terminator.statement.ts.tsx
"," @punctuation.separator.comma.ts.tsx

View File

@ -146,12 +146,12 @@
; The "foo" in `foo.bar`.
(member_expression
object: (identifier) @support.object.other.ts)
object: (identifier) @support.other.object.ts)
; The "bar" in `foo.bar.baz`.
(member_expression
object: (member_expression
property: (property_identifier) @support.object.other.ts))
property: (property_identifier) @support.other.object.ts))
(property_signature
@ -165,7 +165,7 @@
(call_expression
function: (member_expression
property: (property_identifier) @support.function.method.other.ts))
property: (property_identifier) @support.other.function.method.ts))
; VARIABLES
; =========
@ -338,12 +338,12 @@
; PUNCTUATION
; ===========
"{" @punctuation.definition.begin.brace.curly.ts
"}" @punctuation.definition.end.brace.curly.ts
"(" @punctuation.definition.begin.brace.round.ts
")" @punctuation.definition.end.brace.round.ts
"[" @punctuation.definition.begin.brace.square.ts
"]" @punctuation.definition.end.brace.square.ts
"{" @punctuation.definition.begin.bracket.curly.ts
"}" @punctuation.definition.end.bracket.curly.ts
"(" @punctuation.definition.begin.bracket.round.ts
")" @punctuation.definition.end.bracket.round.ts
"[" @punctuation.definition.begin.bracket.square.ts
"]" @punctuation.definition.end.bracket.square.ts
";" @punctuation.terminator.statement.ts
"," @punctuation.separator.comma.ts

View File

@ -119,16 +119,7 @@ const COMMENT_MATCHER = matcherForSelector('comment');
const MAX_RANGE = new Range(Point.ZERO, Point.INFINITY).freeze();
const VAR_ID = 257;
// const conversions = new Map([
// ['function.method.builtin', 'keyword.other.special-method'],
// ['number', 'constant.numeric'],
// // 'punctuation.special':
// // 'punctuation.bracket':
// // 'string':
// // 'embedded':
// // 'punctuation.bracket':
// ['string.special.regex', 'string.regexp']
// ])
class WASMTreeSitterLanguageMode {
constructor({ buffer, grammar, config, grammars }) {
this.lastId = 259;