2024-01-06 15:05:50 +09:00
|
|
|
; Identifiers
|
2022-01-06 02:19:09 +03:00
|
|
|
(simple_identifier) @variable
|
|
|
|
|
|
|
|
|
|
; `it` keyword inside lambdas
|
|
|
|
|
; FIXME: This will highlight the keyword outside of lambdas since tree-sitter
|
|
|
|
|
; does not allow us to check for arbitrary nestation
|
|
|
|
|
((simple_identifier) @variable.builtin
|
2024-01-06 15:05:50 +09:00
|
|
|
(#eq? @variable.builtin "it"))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
; `field` keyword inside property getter/setter
|
|
|
|
|
; FIXME: This will highlight the keyword outside of getters and setters
|
|
|
|
|
; since tree-sitter does not allow us to check for arbitrary nestation
|
|
|
|
|
((simple_identifier) @variable.builtin
|
2024-01-06 15:05:50 +09:00
|
|
|
(#eq? @variable.builtin "field"))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
2023-11-08 15:00:36 +02:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"this"
|
|
|
|
|
"super"
|
|
|
|
|
"this@"
|
|
|
|
|
"super@"
|
2023-11-08 15:00:36 +02:00
|
|
|
] @variable.builtin
|
2022-01-06 02:19:09 +03:00
|
|
|
|
2023-11-08 15:00:36 +02:00
|
|
|
; NOTE: for consistency with "super@"
|
2024-01-06 15:05:50 +09:00
|
|
|
(super_expression
|
|
|
|
|
"@" @variable.builtin)
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(class_parameter
|
2024-01-10 18:05:37 +02:00
|
|
|
(simple_identifier) @variable.member)
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(class_body
|
2024-01-06 15:05:50 +09:00
|
|
|
(property_declaration
|
|
|
|
|
(variable_declaration
|
2024-01-10 18:05:37 +02:00
|
|
|
(simple_identifier) @variable.member)))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
; id_1.id_2.id_3: `id_2` and `id_3` are assumed as object properties
|
|
|
|
|
(_
|
2024-01-06 15:05:50 +09:00
|
|
|
(navigation_suffix
|
2024-01-10 18:05:37 +02:00
|
|
|
(simple_identifier) @variable.member))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
; SCREAMING CASE identifiers are assumed to be constants
|
|
|
|
|
((simple_identifier) @constant
|
2024-01-06 15:05:50 +09:00
|
|
|
(#lua-match? @constant "^[A-Z][A-Z0-9_]*$"))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(_
|
2024-01-06 15:05:50 +09:00
|
|
|
(navigation_suffix
|
|
|
|
|
(simple_identifier) @constant
|
|
|
|
|
(#lua-match? @constant "^[A-Z][A-Z0-9_]*$")))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(enum_entry
|
2024-01-06 15:05:50 +09:00
|
|
|
(simple_identifier) @constant)
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(type_identifier) @type
|
|
|
|
|
|
2023-02-22 13:59:27 +01:00
|
|
|
; '?' operator, replacement for Java @Nullable
|
2023-02-22 17:36:07 +01:00
|
|
|
(nullable_type) @punctuation.special
|
2023-02-22 13:59:27 +01:00
|
|
|
|
2022-11-18 17:24:45 +02:00
|
|
|
(type_alias
|
2024-01-06 15:05:50 +09:00
|
|
|
(type_identifier) @type.definition)
|
2022-11-18 17:24:45 +02:00
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
((type_identifier) @type.builtin
|
2024-01-06 15:05:50 +09:00
|
|
|
(#any-of? @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"))
|
|
|
|
|
|
|
|
|
|
(package_header
|
|
|
|
|
"package" @keyword
|
|
|
|
|
.
|
|
|
|
|
(identifier
|
|
|
|
|
(simple_identifier) @module))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(import_header
|
2024-01-06 15:05:50 +09:00
|
|
|
"import" @keyword.import)
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
; The last `simple_identifier` in a `import_header` will always either be a function
|
|
|
|
|
; or a type. Classes can appear anywhere in the import path, unlike functions
|
|
|
|
|
(import_header
|
2024-01-06 15:05:50 +09:00
|
|
|
(identifier
|
|
|
|
|
(simple_identifier) @type @_import)
|
|
|
|
|
(import_alias
|
|
|
|
|
(type_identifier) @type.definition)?
|
|
|
|
|
(#lua-match? @_import "^[A-Z]"))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(import_header
|
2024-01-06 15:05:50 +09:00
|
|
|
(identifier
|
|
|
|
|
(simple_identifier) @function @_import .)
|
|
|
|
|
(import_alias
|
|
|
|
|
(type_identifier) @function)?
|
|
|
|
|
(#lua-match? @_import "^[a-z]"))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(label) @label
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Function definitions
|
2022-01-06 02:19:09 +03:00
|
|
|
(function_declaration
|
2024-01-06 15:05:50 +09:00
|
|
|
(simple_identifier) @function)
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(getter
|
2024-01-06 15:05:50 +09:00
|
|
|
("get") @function.builtin)
|
|
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
(setter
|
2024-01-06 15:05:50 +09:00
|
|
|
("set") @function.builtin)
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(primary_constructor) @constructor
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
(secondary_constructor
|
2024-01-06 15:05:50 +09:00
|
|
|
("constructor") @constructor)
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(constructor_invocation
|
2024-01-06 15:05:50 +09:00
|
|
|
(user_type
|
|
|
|
|
(type_identifier) @constructor))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(anonymous_initializer
|
2024-01-06 15:05:50 +09:00
|
|
|
("init") @constructor)
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(parameter
|
2024-01-06 15:05:50 +09:00
|
|
|
(simple_identifier) @variable.parameter)
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(parameter_with_optional_type
|
2024-01-06 15:05:50 +09:00
|
|
|
(simple_identifier) @variable.parameter)
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
; lambda parameters
|
|
|
|
|
(lambda_literal
|
2024-01-06 15:05:50 +09:00
|
|
|
(lambda_parameters
|
|
|
|
|
(variable_declaration
|
|
|
|
|
(simple_identifier) @variable.parameter)))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Function calls
|
2022-01-06 02:19:09 +03:00
|
|
|
; function()
|
|
|
|
|
(call_expression
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(simple_identifier) @function.call)
|
2023-02-11 22:02:13 +02:00
|
|
|
|
|
|
|
|
; ::function
|
|
|
|
|
(callable_reference
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(simple_identifier) @function.call)
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
; object.function() or object.property.function()
|
|
|
|
|
(call_expression
|
2024-01-06 15:05:50 +09:00
|
|
|
(navigation_expression
|
|
|
|
|
(navigation_suffix
|
|
|
|
|
(simple_identifier) @function.call) .))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
|
|
|
|
(call_expression
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(simple_identifier) @function.builtin
|
|
|
|
|
(#any-of? @function.builtin "arrayOf" "arrayOfNulls" "byteArrayOf" "shortArrayOf" "intArrayOf" "longArrayOf" "ubyteArrayOf" "ushortArrayOf" "uintArrayOf" "ulongArrayOf" "floatArrayOf" "doubleArrayOf" "booleanArrayOf" "charArrayOf" "emptyArray" "mapOf" "setOf" "listOf" "emptyMap" "emptySet" "emptyList" "mutableMapOf" "mutableSetOf" "mutableListOf" "print" "println" "error" "TODO" "run" "runCatching" "repeat" "lazy" "lazyOf" "enumValues" "enumValueOf" "assert" "check" "checkNotNull" "require" "requireNotNull" "with" "suspend" "synchronized"))
|
2022-01-06 02:19:09 +03:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Literals
|
2023-03-26 14:45:50 -04:00
|
|
|
[
|
|
|
|
|
(line_comment)
|
|
|
|
|
(multiline_comment)
|
|
|
|
|
] @comment @spell
|
2022-09-18 20:15:23 +03:00
|
|
|
|
2023-03-26 14:45:50 -04:00
|
|
|
((multiline_comment) @comment.documentation
|
2023-03-02 08:06:35 -05:00
|
|
|
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
2020-12-02 21:27:25 +01:00
|
|
|
|
feat!: align standard captures with upstream
Problem: Sharing highlight queries with upstream tree-sitter and
Helix is difficult.
Solution: Where reasonable, use capture names in tree-sitter's standard
list or Helix's Atom-style hierarchy.
Specifically:
* tree-sitter "standard capture names"
(https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72):
- `@parameter` -> `@variable.parameter`
- `@field` -> `@variable.member`
- `@namespace` -> `@module`
- `@float` -> `@number.float`
- `@symbol` -> `@string.special.symbol`
- `@string.regex` -> `@string.regexp`
- `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below)
- `@text.title` -> `@markup.heading`
- `@text.literal` -> `@markup.raw`
- `@text.reference` -> `@markup.link`
- `@text.uri` -> `@markup.link.url` (in markup links)
- `@string.special` -> `@markup.link.label` (non-url links)
- `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`)
* Helix captures
(https://docs.helix-editor.com/master/themes.html#syntax-highlighting):
- `@method` -> `@function.method`
- `@method.call` -> `@function.method.call`
- `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}`
- `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}`
- `@text.uri` -> `@string.special.url` (outside markup)
- `@preproc` -> `@keyword.directive`
- `@define` -> `@keyword.directive`(`.define`?)
- `@storageclass` -> `@keyword.storage`
- `@conditional` -> `@keyword.conditional`
- `@debug` -> `@keyword.debug`
- `@exception` -> `@keyword.exception`
- `@include` -> `@keyword.import`
- `@repeat` -> `@keyword.repeat`
* cleanup
- remove some redundant `@conceal` (but still allow it for conceal-only patterns)
- remove obsolete `@error` (syntax linting is out of scope for this repo)
- sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
|
|
|
(shebang_line) @keyword.directive
|
2022-09-26 10:19:02 +01:00
|
|
|
|
feat!: align standard captures with upstream
Problem: Sharing highlight queries with upstream tree-sitter and
Helix is difficult.
Solution: Where reasonable, use capture names in tree-sitter's standard
list or Helix's Atom-style hierarchy.
Specifically:
* tree-sitter "standard capture names"
(https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72):
- `@parameter` -> `@variable.parameter`
- `@field` -> `@variable.member`
- `@namespace` -> `@module`
- `@float` -> `@number.float`
- `@symbol` -> `@string.special.symbol`
- `@string.regex` -> `@string.regexp`
- `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below)
- `@text.title` -> `@markup.heading`
- `@text.literal` -> `@markup.raw`
- `@text.reference` -> `@markup.link`
- `@text.uri` -> `@markup.link.url` (in markup links)
- `@string.special` -> `@markup.link.label` (non-url links)
- `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`)
* Helix captures
(https://docs.helix-editor.com/master/themes.html#syntax-highlighting):
- `@method` -> `@function.method`
- `@method.call` -> `@function.method.call`
- `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}`
- `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}`
- `@text.uri` -> `@string.special.url` (outside markup)
- `@preproc` -> `@keyword.directive`
- `@define` -> `@keyword.directive`(`.define`?)
- `@storageclass` -> `@keyword.storage`
- `@conditional` -> `@keyword.conditional`
- `@debug` -> `@keyword.debug`
- `@exception` -> `@keyword.exception`
- `@include` -> `@keyword.import`
- `@repeat` -> `@keyword.repeat`
* cleanup
- remove some redundant `@conceal` (but still allow it for conceal-only patterns)
- remove obsolete `@error` (syntax linting is out of scope for this repo)
- sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
|
|
|
(real_literal) @number.float
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-12-02 21:27:25 +01:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
(integer_literal)
|
|
|
|
|
(long_literal)
|
|
|
|
|
(hex_literal)
|
|
|
|
|
(bin_literal)
|
|
|
|
|
(unsigned_literal)
|
2022-01-06 02:19:09 +03:00
|
|
|
] @number
|
2020-11-30 22:58:52 +01:00
|
|
|
|
2021-08-16 22:00:07 -04:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"null"
|
|
|
|
|
; should be highlighted the same as booleans
|
|
|
|
|
(boolean_literal)
|
2022-01-06 02:19:09 +03:00
|
|
|
] @boolean
|
|
|
|
|
|
|
|
|
|
(character_literal) @character
|
2020-11-30 22:58:52 +01:00
|
|
|
|
2023-03-26 14:45:50 -04:00
|
|
|
(string_literal) @string
|
2020-12-06 01:24:29 +01:00
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
; NOTE: Escapes not allowed in multi-line strings
|
2024-01-06 15:05:50 +09:00
|
|
|
(character_literal
|
|
|
|
|
(character_escape_seq) @string.escape)
|
2020-11-30 22:58:52 +01:00
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
; There are 3 ways to define a regex
|
|
|
|
|
; - "[abc]?".toRegex()
|
|
|
|
|
(call_expression
|
2024-01-06 15:05:50 +09:00
|
|
|
(navigation_expression
|
|
|
|
|
((string_literal) @string.regexp)
|
|
|
|
|
(navigation_suffix
|
|
|
|
|
((simple_identifier) @_function
|
|
|
|
|
(#eq? @_function "toRegex")))))
|
2020-11-30 22:58:52 +01:00
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
; - Regex("[abc]?")
|
|
|
|
|
(call_expression
|
2024-01-06 15:05:50 +09:00
|
|
|
((simple_identifier) @_function
|
|
|
|
|
(#eq? @_function "Regex"))
|
|
|
|
|
(call_suffix
|
|
|
|
|
(value_arguments
|
|
|
|
|
(value_argument
|
|
|
|
|
(string_literal) @string.regexp))))
|
2021-09-17 18:50:45 -03:00
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
; - Regex.fromLiteral("[abc]?")
|
|
|
|
|
(call_expression
|
2024-01-06 15:05:50 +09:00
|
|
|
(navigation_expression
|
|
|
|
|
((simple_identifier) @_class
|
|
|
|
|
(#eq? @_class "Regex"))
|
|
|
|
|
(navigation_suffix
|
|
|
|
|
((simple_identifier) @_function
|
|
|
|
|
(#eq? @_function "fromLiteral"))))
|
|
|
|
|
(call_suffix
|
|
|
|
|
(value_arguments
|
|
|
|
|
(value_argument
|
|
|
|
|
(string_literal) @string.regexp))))
|
|
|
|
|
|
|
|
|
|
; Keywords
|
|
|
|
|
(type_alias
|
|
|
|
|
"typealias" @keyword)
|
2022-09-18 20:17:23 +03:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(companion_object
|
|
|
|
|
"companion" @keyword)
|
2022-09-18 20:17:23 +03:00
|
|
|
|
2020-12-02 21:27:25 +01:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
(class_modifier)
|
|
|
|
|
(member_modifier)
|
|
|
|
|
(function_modifier)
|
|
|
|
|
(property_modifier)
|
|
|
|
|
(platform_modifier)
|
|
|
|
|
(variance_modifier)
|
|
|
|
|
(parameter_modifier)
|
|
|
|
|
(visibility_modifier)
|
|
|
|
|
(reification_modifier)
|
|
|
|
|
(inheritance_modifier)
|
2022-11-18 17:24:45 +02:00
|
|
|
] @type.qualifier
|
2020-12-02 21:27:25 +01:00
|
|
|
|
2020-11-30 22:58:52 +01:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"val"
|
|
|
|
|
"var"
|
|
|
|
|
"enum"
|
|
|
|
|
"class"
|
|
|
|
|
"object"
|
|
|
|
|
"interface"
|
|
|
|
|
; "typeof" ; NOTE: It is reserved for future use
|
2022-01-06 02:19:09 +03:00
|
|
|
] @keyword
|
|
|
|
|
|
2023-02-24 06:37:45 -05:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"return"
|
|
|
|
|
"return@"
|
2023-11-08 15:00:36 +02:00
|
|
|
] @keyword.return
|
2023-02-24 06:37:45 -05:00
|
|
|
|
2023-11-08 15:00:36 +02:00
|
|
|
"suspend" @keyword.coroutine
|
2022-01-06 02:19:09 +03:00
|
|
|
|
2023-11-08 15:00:36 +02:00
|
|
|
"fun" @keyword.function
|
2020-11-30 22:58:52 +01:00
|
|
|
|
2020-12-02 21:27:25 +01:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"if"
|
|
|
|
|
"else"
|
|
|
|
|
"when"
|
feat!: align standard captures with upstream
Problem: Sharing highlight queries with upstream tree-sitter and
Helix is difficult.
Solution: Where reasonable, use capture names in tree-sitter's standard
list or Helix's Atom-style hierarchy.
Specifically:
* tree-sitter "standard capture names"
(https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72):
- `@parameter` -> `@variable.parameter`
- `@field` -> `@variable.member`
- `@namespace` -> `@module`
- `@float` -> `@number.float`
- `@symbol` -> `@string.special.symbol`
- `@string.regex` -> `@string.regexp`
- `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below)
- `@text.title` -> `@markup.heading`
- `@text.literal` -> `@markup.raw`
- `@text.reference` -> `@markup.link`
- `@text.uri` -> `@markup.link.url` (in markup links)
- `@string.special` -> `@markup.link.label` (non-url links)
- `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`)
* Helix captures
(https://docs.helix-editor.com/master/themes.html#syntax-highlighting):
- `@method` -> `@function.method`
- `@method.call` -> `@function.method.call`
- `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}`
- `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}`
- `@text.uri` -> `@string.special.url` (outside markup)
- `@preproc` -> `@keyword.directive`
- `@define` -> `@keyword.directive`(`.define`?)
- `@storageclass` -> `@keyword.storage`
- `@conditional` -> `@keyword.conditional`
- `@debug` -> `@keyword.debug`
- `@exception` -> `@keyword.exception`
- `@include` -> `@keyword.import`
- `@repeat` -> `@keyword.repeat`
* cleanup
- remove some redundant `@conceal` (but still allow it for conceal-only patterns)
- remove obsolete `@error` (syntax linting is out of scope for this repo)
- sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
|
|
|
] @keyword.conditional
|
2021-08-16 22:00:07 -04:00
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"for"
|
|
|
|
|
"do"
|
|
|
|
|
"while"
|
|
|
|
|
"continue"
|
|
|
|
|
"continue@"
|
|
|
|
|
"break"
|
|
|
|
|
"break@"
|
feat!: align standard captures with upstream
Problem: Sharing highlight queries with upstream tree-sitter and
Helix is difficult.
Solution: Where reasonable, use capture names in tree-sitter's standard
list or Helix's Atom-style hierarchy.
Specifically:
* tree-sitter "standard capture names"
(https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72):
- `@parameter` -> `@variable.parameter`
- `@field` -> `@variable.member`
- `@namespace` -> `@module`
- `@float` -> `@number.float`
- `@symbol` -> `@string.special.symbol`
- `@string.regex` -> `@string.regexp`
- `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below)
- `@text.title` -> `@markup.heading`
- `@text.literal` -> `@markup.raw`
- `@text.reference` -> `@markup.link`
- `@text.uri` -> `@markup.link.url` (in markup links)
- `@string.special` -> `@markup.link.label` (non-url links)
- `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`)
* Helix captures
(https://docs.helix-editor.com/master/themes.html#syntax-highlighting):
- `@method` -> `@function.method`
- `@method.call` -> `@function.method.call`
- `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}`
- `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}`
- `@text.uri` -> `@string.special.url` (outside markup)
- `@preproc` -> `@keyword.directive`
- `@define` -> `@keyword.directive`(`.define`?)
- `@storageclass` -> `@keyword.storage`
- `@conditional` -> `@keyword.conditional`
- `@debug` -> `@keyword.debug`
- `@exception` -> `@keyword.exception`
- `@include` -> `@keyword.import`
- `@repeat` -> `@keyword.repeat`
* cleanup
- remove some redundant `@conceal` (but still allow it for conceal-only patterns)
- remove obsolete `@error` (syntax linting is out of scope for this repo)
- sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
|
|
|
] @keyword.repeat
|
2021-08-16 22:00:07 -04:00
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"try"
|
|
|
|
|
"catch"
|
|
|
|
|
"throw"
|
|
|
|
|
"finally"
|
feat!: align standard captures with upstream
Problem: Sharing highlight queries with upstream tree-sitter and
Helix is difficult.
Solution: Where reasonable, use capture names in tree-sitter's standard
list or Helix's Atom-style hierarchy.
Specifically:
* tree-sitter "standard capture names"
(https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72):
- `@parameter` -> `@variable.parameter`
- `@field` -> `@variable.member`
- `@namespace` -> `@module`
- `@float` -> `@number.float`
- `@symbol` -> `@string.special.symbol`
- `@string.regex` -> `@string.regexp`
- `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below)
- `@text.title` -> `@markup.heading`
- `@text.literal` -> `@markup.raw`
- `@text.reference` -> `@markup.link`
- `@text.uri` -> `@markup.link.url` (in markup links)
- `@string.special` -> `@markup.link.label` (non-url links)
- `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`)
* Helix captures
(https://docs.helix-editor.com/master/themes.html#syntax-highlighting):
- `@method` -> `@function.method`
- `@method.call` -> `@function.method.call`
- `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}`
- `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}`
- `@text.uri` -> `@string.special.url` (outside markup)
- `@preproc` -> `@keyword.directive`
- `@define` -> `@keyword.directive`(`.define`?)
- `@storageclass` -> `@keyword.storage`
- `@conditional` -> `@keyword.conditional`
- `@debug` -> `@keyword.debug`
- `@exception` -> `@keyword.exception`
- `@include` -> `@keyword.import`
- `@repeat` -> `@keyword.repeat`
* cleanup
- remove some redundant `@conceal` (but still allow it for conceal-only patterns)
- remove obsolete `@error` (syntax linting is out of scope for this repo)
- sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
|
|
|
] @keyword.exception
|
2021-08-16 22:00:07 -04:00
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
(annotation
|
2024-01-06 15:05:50 +09:00
|
|
|
"@" @attribute
|
|
|
|
|
(use_site_target)? @attribute)
|
|
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
(annotation
|
2024-01-06 15:05:50 +09:00
|
|
|
(user_type
|
|
|
|
|
(type_identifier) @attribute))
|
|
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
(annotation
|
2024-01-06 15:05:50 +09:00
|
|
|
(constructor_invocation
|
|
|
|
|
(user_type
|
|
|
|
|
(type_identifier) @attribute)))
|
2021-08-16 22:00:07 -04:00
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
(file_annotation
|
2024-01-06 15:05:50 +09:00
|
|
|
"@" @attribute
|
|
|
|
|
"file" @attribute
|
|
|
|
|
":" @attribute)
|
|
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
(file_annotation
|
2024-01-06 15:05:50 +09:00
|
|
|
(user_type
|
|
|
|
|
(type_identifier) @attribute))
|
2021-08-16 22:00:07 -04:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(file_annotation
|
|
|
|
|
(constructor_invocation
|
|
|
|
|
(user_type
|
|
|
|
|
(type_identifier) @attribute)))
|
2021-08-16 22:00:07 -04:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Operators & Punctuation
|
2022-01-06 02:19:09 +03:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"!"
|
|
|
|
|
"!="
|
|
|
|
|
"!=="
|
|
|
|
|
"="
|
|
|
|
|
"=="
|
|
|
|
|
"==="
|
|
|
|
|
">"
|
|
|
|
|
">="
|
|
|
|
|
"<"
|
|
|
|
|
"<="
|
|
|
|
|
"||"
|
|
|
|
|
"&&"
|
|
|
|
|
"+"
|
|
|
|
|
"++"
|
|
|
|
|
"+="
|
|
|
|
|
"-"
|
|
|
|
|
"--"
|
|
|
|
|
"-="
|
|
|
|
|
"*"
|
|
|
|
|
"*="
|
|
|
|
|
"/"
|
|
|
|
|
"/="
|
|
|
|
|
"%"
|
|
|
|
|
"%="
|
|
|
|
|
"?."
|
|
|
|
|
"?:"
|
|
|
|
|
"!!"
|
|
|
|
|
"is"
|
|
|
|
|
"!is"
|
|
|
|
|
"in"
|
|
|
|
|
"!in"
|
|
|
|
|
"as"
|
|
|
|
|
"as?"
|
|
|
|
|
".."
|
|
|
|
|
"->"
|
2022-01-06 02:19:09 +03:00
|
|
|
] @operator
|
2020-12-02 21:27:25 +01:00
|
|
|
|
2021-08-16 22:00:07 -04:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"("
|
|
|
|
|
")"
|
|
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
2022-01-06 02:19:09 +03:00
|
|
|
] @punctuation.bracket
|
|
|
|
|
|
|
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"."
|
|
|
|
|
","
|
|
|
|
|
";"
|
|
|
|
|
":"
|
|
|
|
|
"::"
|
2022-01-06 02:19:09 +03:00
|
|
|
] @punctuation.delimiter
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(super_expression
|
|
|
|
|
[
|
|
|
|
|
"<"
|
|
|
|
|
">"
|
|
|
|
|
] @punctuation.delimiter)
|
|
|
|
|
|
|
|
|
|
(type_arguments
|
|
|
|
|
[
|
|
|
|
|
"<"
|
|
|
|
|
">"
|
|
|
|
|
] @punctuation.delimiter)
|
|
|
|
|
|
|
|
|
|
(type_parameters
|
|
|
|
|
[
|
|
|
|
|
"<"
|
|
|
|
|
">"
|
|
|
|
|
] @punctuation.delimiter)
|
2023-11-08 15:00:36 +02:00
|
|
|
|
2022-01-06 02:19:09 +03:00
|
|
|
; NOTE: `interpolated_identifier`s can be highlighted in any way
|
2023-03-26 14:45:50 -04:00
|
|
|
(string_literal
|
2024-01-06 15:05:50 +09:00
|
|
|
"$" @punctuation.special
|
|
|
|
|
(interpolated_identifier) @none @variable)
|
|
|
|
|
|
2023-03-26 14:45:50 -04:00
|
|
|
(string_literal
|
2024-01-06 15:05:50 +09:00
|
|
|
"${" @punctuation.special
|
|
|
|
|
(interpolated_expression) @none
|
|
|
|
|
"}" @punctuation.special)
|