File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ if s:Enabled('g:python_highlight_all')
3939 call s: EnableByDefault (' g:python_print_as_function' )
4040 call s: EnableByDefault (' g:python_highlight_class_vars' )
4141 call s: EnableByDefault (' g:python_highlight_operators' )
42+ call s: EnableByDefault (' g:python_highlight_type_annotations' )
4243endif
4344
4445"
@@ -54,6 +55,25 @@ if s:Enabled('g:python_highlight_builtin_objs')
5455 syn keyword pythonBuiltinObj __loader__ __spec__ __path__ __cached__
5556endif
5657
58+
59+ if s: Enabled (' g:python_highlight_type_annotations' )
60+ " These are derived from the lists found in python typing.py
61+ " Super-special typing primitives.
62+ syntax match pythonBuiltinType ' \v <%(Any|Callable|ClassVar|Generic|Optional|Tuple|Type|TypeVar|Union)>'
63+
64+ " ABCs (from collections.abc).
65+ syntax match pythonBuiltinType ' \v <%(AbstractSet|ByteString|Container|ContextManager|Hashable|ItemsView|Iterable|Iterator|KeysView|Mapping|MappingView|MutableMapping|MutableSequence|MutableSet|Sequence|Sized|ValuesView|Awaitable|AsyncIterator|AsyncIterable|Coroutine|Collection|AsyncGenerator|AsyncContextManager)>'
66+
67+ " Structural checks, a.k.a. protocols.
68+ syntax match pythonBuiltinType ' \v <%(Reversible|SupportsAbs|SupportsBytes|SupportsComplex|SupportsFloat|SupportsInt|SupportsRound)>'
69+
70+ " Concrete collection types.
71+ syntax match pythonBuiltinType ' \v <%(Counter|Deque|Dict|DefaultDict|List|Set|FrozenSet|NamedTuple|Generator)>'
72+
73+ " One-off things.
74+ syntax match pythonBuiltinType ' \v <%(AnyStr|cast|get_type_hints|NewType|no_type_check|no_type_check_decorator|NoReturn|overload|Text|TYPE_CHECKING)>'
75+ endif
76+
5777"
5878" Builtin functions
5979"
You can’t perform that action at this time.
0 commit comments