2024-01-06 15:05:50 +09:00
|
|
|
; From tree-sitter-python licensed under MIT License
|
2020-05-16 19:24:27 +02:00
|
|
|
; Copyright (c) 2016 Max Brunsfeld
|
2020-09-12 20:57:01 +02:00
|
|
|
; Variables
|
|
|
|
|
(identifier) @variable
|
|
|
|
|
|
2021-11-01 22:35:31 +01:00
|
|
|
; Reset highlighting in f-string interpolations
|
2020-10-02 16:41:07 +02:00
|
|
|
(interpolation) @none
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Identifier naming conventions
|
2020-05-27 22:23:34 +02:00
|
|
|
((identifier) @type
|
2024-01-06 15:05:50 +09:00
|
|
|
(#lua-match? @type "^[A-Z].*[a-z]"))
|
|
|
|
|
|
2020-05-16 19:24:27 +02:00
|
|
|
((identifier) @constant
|
2024-01-06 15:05:50 +09:00
|
|
|
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2020-06-21 17:00:17 +02:00
|
|
|
((identifier) @constant.builtin
|
2024-01-06 15:05:50 +09:00
|
|
|
(#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$"))
|
2020-06-21 17:00:17 +02:00
|
|
|
|
2020-08-16 19:25:06 -05:00
|
|
|
((identifier) @constant.builtin
|
2024-01-05 03:19:54 +09:00
|
|
|
; format-ignore
|
|
|
|
|
(#any-of? @constant.builtin
|
|
|
|
|
; https://docs.python.org/3/library/constants.html
|
|
|
|
|
"NotImplemented" "Ellipsis"
|
|
|
|
|
"quit" "exit" "copyright" "credits" "license"))
|
2020-08-16 19:25:06 -05:00
|
|
|
|
2023-08-16 17:53:03 -04:00
|
|
|
"_" @constant.builtin ; match wildcard
|
|
|
|
|
|
2020-07-22 16:24:39 +02:00
|
|
|
((attribute
|
2024-01-06 15:05:50 +09:00
|
|
|
attribute: (identifier) @variable.member)
|
|
|
|
|
(#lua-match? @variable.member "^[%l_].*$"))
|
2020-07-22 16:24:39 +02:00
|
|
|
|
2022-11-21 15:06:35 +02:00
|
|
|
((assignment
|
|
|
|
|
left: (identifier) @type.definition
|
2024-01-06 15:05:50 +09:00
|
|
|
(type
|
|
|
|
|
(identifier) @_annotation))
|
|
|
|
|
(#eq? @_annotation "TypeAlias"))
|
2022-11-21 15:06:35 +02:00
|
|
|
|
|
|
|
|
((assignment
|
|
|
|
|
left: (identifier) @type.definition
|
2024-01-06 15:05:50 +09:00
|
|
|
right:
|
|
|
|
|
(call
|
|
|
|
|
function: (identifier) @_func))
|
|
|
|
|
(#any-of? @_func "TypeVar" "NewType"))
|
2020-08-16 19:25:06 -05:00
|
|
|
|
2020-05-16 19:24:27 +02:00
|
|
|
; Function calls
|
2020-06-02 15:59:13 +02:00
|
|
|
(call
|
2022-07-24 19:18:11 -03:00
|
|
|
function: (identifier) @function.call)
|
2020-05-16 19:24:27 +02:00
|
|
|
|
|
|
|
|
(call
|
2024-01-06 15:05:50 +09:00
|
|
|
function:
|
|
|
|
|
(attribute
|
|
|
|
|
attribute: (identifier) @function.method.call))
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2020-06-02 15:59:13 +02:00
|
|
|
((call
|
2024-01-06 15:05:50 +09:00
|
|
|
function: (identifier) @constructor)
|
|
|
|
|
(#lua-match? @constructor "^%u"))
|
2020-05-16 19:24:27 +02:00
|
|
|
|
|
|
|
|
((call
|
2024-01-06 15:05:50 +09:00
|
|
|
function:
|
|
|
|
|
(attribute
|
|
|
|
|
attribute: (identifier) @constructor))
|
|
|
|
|
(#lua-match? @constructor "^%u"))
|
2022-11-21 15:06:35 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Decorators
|
|
|
|
|
((decorator
|
|
|
|
|
"@" @attribute)
|
|
|
|
|
(#set! "priority" 101))
|
2022-11-21 15:06:35 +02:00
|
|
|
|
|
|
|
|
(decorator
|
|
|
|
|
(identifier) @attribute)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2022-11-21 15:06:35 +02:00
|
|
|
(decorator
|
|
|
|
|
(attribute
|
|
|
|
|
attribute: (identifier) @attribute))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2022-11-21 15:06:35 +02:00
|
|
|
(decorator
|
2024-01-06 15:05:50 +09:00
|
|
|
(call
|
|
|
|
|
(identifier) @attribute))
|
|
|
|
|
|
2022-11-21 15:06:35 +02:00
|
|
|
(decorator
|
2024-01-06 15:05:50 +09:00
|
|
|
(call
|
|
|
|
|
(attribute
|
|
|
|
|
attribute: (identifier) @attribute)))
|
2022-11-21 15:06:35 +02:00
|
|
|
|
|
|
|
|
((decorator
|
|
|
|
|
(identifier) @attribute.builtin)
|
2024-01-06 15:05:50 +09:00
|
|
|
(#any-of? @attribute.builtin "classmethod" "property"))
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Builtin functions
|
2020-05-16 19:24:27 +02:00
|
|
|
((call
|
|
|
|
|
function: (identifier) @function.builtin)
|
2024-01-06 15:05:50 +09:00
|
|
|
(#any-of? @function.builtin "abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" "classmethod" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input" "int" "isinstance" "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview" "min" "next" "object" "oct" "open" "ord" "pow" "print" "property" "range" "repr" "reversed" "round" "set" "setattr" "slice" "sorted" "staticmethod" "str" "sum" "super" "tuple" "type" "vars" "zip" "__import__"))
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Function definitions
|
2020-05-16 19:24:27 +02:00
|
|
|
(function_definition
|
|
|
|
|
name: (identifier) @function)
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(type
|
|
|
|
|
(identifier) @type)
|
|
|
|
|
|
2020-07-09 09:36:05 +02:00
|
|
|
(type
|
|
|
|
|
(subscript
|
|
|
|
|
(identifier) @type)) ; type subscript: Tuple[int]
|
2020-06-02 15:59:13 +02:00
|
|
|
|
|
|
|
|
((call
|
2020-09-07 18:14:54 +02:00
|
|
|
function: (identifier) @_isinstance
|
2024-01-06 15:05:50 +09:00
|
|
|
arguments:
|
|
|
|
|
(argument_list
|
|
|
|
|
(_)
|
|
|
|
|
(identifier) @type))
|
|
|
|
|
(#eq? @_isinstance "isinstance"))
|
2020-05-27 22:23:34 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Normal parameters
|
2020-05-16 19:24:27 +02:00
|
|
|
(parameters
|
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
|
|
|
(identifier) @variable.parameter)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
; Lambda parameters
|
2020-07-22 16:24:17 +02:00
|
|
|
(lambda_parameters
|
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
|
|
|
(identifier) @variable.parameter)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-07-22 16:24:17 +02:00
|
|
|
(lambda_parameters
|
2020-11-03 18:50:26 +01:00
|
|
|
(tuple_pattern
|
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
|
|
|
(identifier) @variable.parameter))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-05-27 22:23:34 +02:00
|
|
|
; Default parameters
|
|
|
|
|
(keyword_argument
|
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
|
|
|
name: (identifier) @variable.parameter)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-05-27 22:23:34 +02:00
|
|
|
; Naming parameters on call-site
|
|
|
|
|
(default_parameter
|
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
|
|
|
name: (identifier) @variable.parameter)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-07-08 17:35:12 +02:00
|
|
|
(typed_parameter
|
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
|
|
|
(identifier) @variable.parameter)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-07-08 17:35:12 +02:00
|
|
|
(typed_default_parameter
|
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
|
|
|
name: (identifier) @variable.parameter)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-05-27 22:23:34 +02:00
|
|
|
; Variadic parameters *args, **kwargs
|
|
|
|
|
(parameters
|
2024-01-20 03:21:57 +11:00
|
|
|
(list_splat_pattern ; *args
|
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
|
|
|
(identifier) @variable.parameter))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2020-05-27 22:23:34 +02:00
|
|
|
(parameters
|
2024-01-20 03:21:57 +11:00
|
|
|
(dictionary_splat_pattern ; **kwargs
|
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
|
|
|
(identifier) @variable.parameter))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2024-01-20 03:21:57 +11:00
|
|
|
; Typed variadic parameters
|
|
|
|
|
(parameters
|
|
|
|
|
(typed_parameter
|
|
|
|
|
(list_splat_pattern ; *args: type
|
|
|
|
|
(identifier) @variable.parameter)))
|
|
|
|
|
|
|
|
|
|
(parameters
|
|
|
|
|
(typed_parameter
|
|
|
|
|
(dictionary_splat_pattern ; *kwargs: type
|
|
|
|
|
(identifier) @variable.parameter)))
|
|
|
|
|
|
|
|
|
|
; Lambda parameters
|
2023-12-14 11:37:34 +02:00
|
|
|
(lambda_parameters
|
|
|
|
|
(list_splat_pattern
|
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
|
|
|
(identifier) @variable.parameter))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2023-12-14 11:37:34 +02:00
|
|
|
(lambda_parameters
|
|
|
|
|
(dictionary_splat_pattern
|
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
|
|
|
(identifier) @variable.parameter))
|
2020-05-27 22:23:34 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Literals
|
|
|
|
|
(none) @constant.builtin
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
(true)
|
|
|
|
|
(false)
|
|
|
|
|
] @boolean
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2020-09-12 20:57:01 +02:00
|
|
|
((identifier) @variable.builtin
|
2024-01-06 15:05:50 +09:00
|
|
|
(#eq? @variable.builtin "self"))
|
|
|
|
|
|
2022-06-11 18:58:46 -07:00
|
|
|
((identifier) @variable.builtin
|
2024-01-06 15:05:50 +09:00
|
|
|
(#eq? @variable.builtin "cls"))
|
2020-05-16 19:24:27 +02:00
|
|
|
|
|
|
|
|
(integer) @number
|
2024-01-06 15:05:50 +09: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
|
|
|
(float) @number.float
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2022-09-26 10:19:02 +01:00
|
|
|
(comment) @comment @spell
|
2022-09-18 20:15:23 +03:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
((module
|
|
|
|
|
.
|
|
|
|
|
(comment) @keyword.directive)
|
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
|
|
|
(#lua-match? @keyword.directive "^#!/"))
|
2022-09-18 20:15:23 +03:00
|
|
|
|
2020-05-16 19:24:27 +02:00
|
|
|
(string) @string
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2023-08-16 03:05:59 -04:00
|
|
|
[
|
|
|
|
|
(escape_sequence)
|
|
|
|
|
(escape_interpolation)
|
|
|
|
|
] @string.escape
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2022-09-06 11:56:27 +01:00
|
|
|
; doc-strings
|
2024-01-06 15:05:50 +09:00
|
|
|
(module
|
|
|
|
|
.
|
|
|
|
|
(expression_statement
|
|
|
|
|
(string) @string.documentation @spell))
|
2023-03-01 12:26:26 -05:00
|
|
|
|
|
|
|
|
(class_definition
|
|
|
|
|
body:
|
|
|
|
|
(block
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(expression_statement
|
|
|
|
|
(string) @string.documentation @spell)))
|
2023-03-01 12:26:26 -05:00
|
|
|
|
|
|
|
|
(function_definition
|
|
|
|
|
body:
|
|
|
|
|
(block
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(expression_statement
|
|
|
|
|
(string) @string.documentation @spell)))
|
2022-09-06 11:56:27 +01:00
|
|
|
|
2020-05-16 19:24:27 +02:00
|
|
|
; Tokens
|
2020-06-21 16:32:25 +02:00
|
|
|
[
|
|
|
|
|
"-"
|
|
|
|
|
"-="
|
2020-06-24 16:42:55 +02:00
|
|
|
":="
|
2020-06-21 16:32:25 +02:00
|
|
|
"!="
|
|
|
|
|
"*"
|
|
|
|
|
"**"
|
|
|
|
|
"**="
|
|
|
|
|
"*="
|
|
|
|
|
"/"
|
|
|
|
|
"//"
|
|
|
|
|
"//="
|
|
|
|
|
"/="
|
|
|
|
|
"&"
|
2020-08-20 11:00:11 +02:00
|
|
|
"&="
|
2020-06-21 16:32:25 +02:00
|
|
|
"%"
|
|
|
|
|
"%="
|
|
|
|
|
"^"
|
2020-08-20 11:00:11 +02:00
|
|
|
"^="
|
2020-06-21 16:32:25 +02:00
|
|
|
"+"
|
|
|
|
|
"+="
|
|
|
|
|
"<"
|
|
|
|
|
"<<"
|
2020-08-20 11:00:11 +02:00
|
|
|
"<<="
|
2020-06-21 16:32:25 +02:00
|
|
|
"<="
|
|
|
|
|
"<>"
|
|
|
|
|
"="
|
|
|
|
|
"=="
|
|
|
|
|
">"
|
|
|
|
|
">="
|
|
|
|
|
">>"
|
2020-08-20 11:00:11 +02:00
|
|
|
">>="
|
|
|
|
|
"@"
|
|
|
|
|
"@="
|
2020-06-21 16:32:25 +02:00
|
|
|
"|"
|
2020-08-20 11:00:11 +02:00
|
|
|
"|="
|
2020-06-21 16:32:25 +02:00
|
|
|
"~"
|
2020-09-13 15:08:11 +02:00
|
|
|
"->"
|
|
|
|
|
] @operator
|
|
|
|
|
|
|
|
|
|
; Keywords
|
|
|
|
|
[
|
2020-06-21 16:32:25 +02:00
|
|
|
"and"
|
|
|
|
|
"in"
|
|
|
|
|
"is"
|
|
|
|
|
"not"
|
|
|
|
|
"or"
|
2023-03-03 11:37:21 +08:00
|
|
|
"is not"
|
|
|
|
|
"not in"
|
2020-09-13 15:08:11 +02:00
|
|
|
"del"
|
|
|
|
|
] @keyword.operator
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2021-06-17 13:33:53 -05:00
|
|
|
[
|
|
|
|
|
"def"
|
|
|
|
|
"lambda"
|
|
|
|
|
] @keyword.function
|
|
|
|
|
|
2020-06-21 16:32:25 +02:00
|
|
|
[
|
|
|
|
|
"assert"
|
|
|
|
|
"class"
|
|
|
|
|
"exec"
|
|
|
|
|
"global"
|
|
|
|
|
"nonlocal"
|
|
|
|
|
"pass"
|
|
|
|
|
"print"
|
|
|
|
|
"with"
|
2020-08-16 19:25:06 -05:00
|
|
|
"as"
|
2023-08-16 17:53:03 -04:00
|
|
|
"type"
|
2020-06-21 16:32:25 +02:00
|
|
|
] @keyword
|
|
|
|
|
|
2023-02-24 06:37:45 -05:00
|
|
|
[
|
|
|
|
|
"async"
|
|
|
|
|
"await"
|
|
|
|
|
] @keyword.coroutine
|
|
|
|
|
|
2021-07-04 19:55:59 +03:00
|
|
|
[
|
|
|
|
|
"return"
|
|
|
|
|
"yield"
|
2021-07-04 20:24:25 +03:00
|
|
|
] @keyword.return
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
(yield
|
|
|
|
|
"from" @keyword.return)
|
2022-04-01 16:50:57 +02:00
|
|
|
|
2022-11-21 15:06:35 +02:00
|
|
|
(future_import_statement
|
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
|
|
|
"from" @keyword.import
|
2022-11-21 15:06:35 +02:00
|
|
|
"__future__" @constant.builtin)
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
(import_from_statement
|
|
|
|
|
"from" @keyword.import)
|
|
|
|
|
|
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
|
|
|
"import" @keyword.import
|
2021-07-04 19:55:59 +03:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(aliased_import
|
|
|
|
|
"as" @keyword.import)
|
2020-06-21 16:32:25 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"if"
|
|
|
|
|
"elif"
|
|
|
|
|
"else"
|
|
|
|
|
"match"
|
|
|
|
|
"case"
|
|
|
|
|
] @keyword.conditional
|
2020-06-21 16:32:25 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"for"
|
|
|
|
|
"while"
|
|
|
|
|
"break"
|
|
|
|
|
"continue"
|
|
|
|
|
] @keyword.repeat
|
2020-06-21 16:32:25 +02:00
|
|
|
|
2022-03-22 12:36:35 +01:00
|
|
|
[
|
|
|
|
|
"try"
|
|
|
|
|
"except"
|
2022-10-24 23:24:02 +02:00
|
|
|
"except*"
|
2022-03-22 12:36:35 +01:00
|
|
|
"raise"
|
|
|
|
|
"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
|
2022-03-22 12:36:35 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(raise_statement
|
|
|
|
|
"from" @keyword.exception)
|
2022-04-30 20:10:55 -05:00
|
|
|
|
2022-03-22 12:36:35 +01:00
|
|
|
(try_statement
|
|
|
|
|
(else_clause
|
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
|
|
|
"else" @keyword.exception))
|
2022-03-22 12:36:35 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"("
|
|
|
|
|
")"
|
|
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
] @punctuation.bracket
|
2020-06-02 15:59:13 +02:00
|
|
|
|
|
|
|
|
(interpolation
|
|
|
|
|
"{" @punctuation.special
|
2021-01-06 02:11:28 +01:00
|
|
|
"}" @punctuation.special)
|
2020-05-16 19:24:27 +02:00
|
|
|
|
2023-04-24 00:30:18 -04:00
|
|
|
(type_conversion) @function.macro
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
","
|
|
|
|
|
"."
|
|
|
|
|
":"
|
|
|
|
|
";"
|
|
|
|
|
(ellipsis)
|
|
|
|
|
] @punctuation.delimiter
|
|
|
|
|
|
|
|
|
|
; Class definitions
|
|
|
|
|
(class_definition
|
|
|
|
|
name: (identifier) @type)
|
2021-07-11 15:06:52 -05:00
|
|
|
|
2020-05-16 19:24:27 +02:00
|
|
|
(class_definition
|
2024-01-06 15:05:50 +09:00
|
|
|
body:
|
|
|
|
|
(block
|
|
|
|
|
(function_definition
|
|
|
|
|
name: (identifier) @function.method)))
|
2020-08-16 11:44:20 -05:00
|
|
|
|
2020-05-27 22:23:34 +02:00
|
|
|
(class_definition
|
2024-01-06 15:05:50 +09:00
|
|
|
superclasses:
|
|
|
|
|
(argument_list
|
|
|
|
|
(identifier) @type))
|
2020-05-16 19:24:27 +02:00
|
|
|
|
|
|
|
|
((class_definition
|
2024-01-06 15:05:50 +09:00
|
|
|
body:
|
|
|
|
|
(block
|
|
|
|
|
(expression_statement
|
|
|
|
|
(assignment
|
|
|
|
|
left: (identifier) @variable.member))))
|
|
|
|
|
(#lua-match? @variable.member "^%l.*$"))
|
|
|
|
|
|
2020-11-28 22:25:27 +01:00
|
|
|
((class_definition
|
2024-01-06 15:05:50 +09:00
|
|
|
body:
|
|
|
|
|
(block
|
|
|
|
|
(expression_statement
|
|
|
|
|
(assignment
|
|
|
|
|
left:
|
|
|
|
|
(_
|
|
|
|
|
(identifier) @variable.member)))))
|
|
|
|
|
(#lua-match? @variable.member "^%l.*$"))
|
2020-08-16 11:44:20 -05:00
|
|
|
|
|
|
|
|
((class_definition
|
|
|
|
|
(block
|
|
|
|
|
(function_definition
|
|
|
|
|
name: (identifier) @constructor)))
|
2024-01-06 15:05:50 +09:00
|
|
|
(#any-of? @constructor "__new__" "__init__"))
|
2020-08-16 11:44:20 -05:00
|
|
|
|
2023-04-24 00:38:31 -04:00
|
|
|
((identifier) @type.builtin
|
2024-01-05 03:19:54 +09:00
|
|
|
; format-ignore
|
|
|
|
|
(#any-of? @type.builtin
|
|
|
|
|
; https://docs.python.org/3/library/exceptions.html
|
|
|
|
|
"BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError" "AttributeError"
|
|
|
|
|
"EOFError" "FloatingPointError" "GeneratorExit" "ImportError" "ModuleNotFoundError" "IndexError" "KeyError"
|
|
|
|
|
"KeyboardInterrupt" "MemoryError" "NameError" "NotImplementedError" "OSError" "OverflowError" "RecursionError"
|
|
|
|
|
"ReferenceError" "RuntimeError" "StopIteration" "StopAsyncIteration" "SyntaxError" "IndentationError" "TabError"
|
|
|
|
|
"SystemError" "SystemExit" "TypeError" "UnboundLocalError" "UnicodeError" "UnicodeEncodeError" "UnicodeDecodeError"
|
|
|
|
|
"UnicodeTranslateError" "ValueError" "ZeroDivisionError" "EnvironmentError" "IOError" "WindowsError"
|
|
|
|
|
"BlockingIOError" "ChildProcessError" "ConnectionError" "BrokenPipeError" "ConnectionAbortedError"
|
|
|
|
|
"ConnectionRefusedError" "ConnectionResetError" "FileExistsError" "FileNotFoundError" "InterruptedError"
|
|
|
|
|
"IsADirectoryError" "NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "Warning"
|
|
|
|
|
"UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning"
|
|
|
|
|
"FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning"
|
|
|
|
|
; https://docs.python.org/3/library/stdtypes.html
|
|
|
|
|
"bool" "int" "float" "complex" "list" "tuple" "range" "str"
|
|
|
|
|
"bytes" "bytearray" "memoryview" "set" "frozenset" "dict" "type" "object"))
|
2023-11-20 08:26:18 -08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Regex from the `re` module
|
2023-11-20 08:26:18 -08:00
|
|
|
(call
|
2024-01-06 15:05:50 +09:00
|
|
|
function:
|
|
|
|
|
(attribute
|
|
|
|
|
object: (identifier) @_re)
|
|
|
|
|
arguments:
|
|
|
|
|
(argument_list
|
|
|
|
|
.
|
|
|
|
|
(string
|
|
|
|
|
(string_content) @string.regexp))
|
2023-11-20 08:26:18 -08:00
|
|
|
(#eq? @_re "re"))
|