]> git.ipfire.org Git - thirdparty/vim.git/commit
runtime(python): support 'type's soft keyword form
authorJon Parise <jon@indelible.org>
Sun, 24 Aug 2025 10:31:08 +0000 (12:31 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 24 Aug 2025 10:31:08 +0000 (12:31 +0200)
commit99964e2ea704465f25207c519fefb2bb6d6931bb
tree88fdaf018561fb17a302926f0ae9b23e4f073269
parent46652092a3756ef9c2d5a04f2712165778d90ad7
runtime(python): support 'type's soft keyword form

`type` became a soft keyword in Python 3.12. In that form, it is a
statement that declares a type alias:

    # type_stmt ::= 'type' identifier [type_params] "=" expression
    type Point = tuple[float, float]

To implement support for this, this change does three things:

1. adds a `pythonType` group (linked to `Type`)
2. matches `type` followed by an identifier as `pythonStatement`
3. continues to match `type` in other forms as `pythonBuiltin`

Ref:
- https://docs.python.org/3/reference/lexical_analysis.html#soft-keywords
- https://docs.python.org/3/reference/simple_stmts.html#the-type-statement

closes: #18090

Signed-off-by: Jon Parise <jon@indelible.org>
Signed-off-by: Zvezdan Petkovic <zpetkovic@acm.org>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/syntax/python.vim