@@ -77,15 +77,11 @@ patterns:
7777 match : \b(None|True|False|Ellipsis|NotImplemented)\b
7878
7979- name : storage.modifier.declaration.python
80- match : \b(global|nonlocal|async )\b
80+ match : \b(global|nonlocal)\b
8181
8282- name : keyword.control.import.python
8383 match : \b(?:(import|from|as))\b
8484
85- - comment : keywords that delimit flow blocks or alter flow from within a block
86- name : keyword.control.flow.python
87- match : \b(await|break|continue|elif|else|except|finally|for|if|pass|raise|return|try|while|with|yield)\b
88-
8985- comment : keyword operators that evaluate to True or False
9086 name : keyword.operator.logical.python
9187 match : \b(and|in|is|not|or)\b
@@ -168,7 +164,7 @@ patterns:
168164 - include : ' #entity_name_function'
169165
170166- name : meta.function.python
171- begin : \s*(def)\s+(?=[\p{Alpha}_][\p{Alnum}_]*\s*\()
167+ begin : \s*((?:async\s+)? def)\s+(?=[\p{Alpha}_][\p{Alnum}_]*\s*\()
172168 beginCaptures :
173169 ' 1 ' : {name: storage.type.function.python}
174170 end : (\:)
@@ -203,7 +199,7 @@ patterns:
203199 - include : $self
204200
205201- name : meta.function.python
206- begin : \s*(def)\s+(?=[\p{Alpha}_][\p{Alnum}_]*)
202+ begin : \s*((?:async\s+)? def)\s+(?=[\p{Alpha}_][\p{Alnum}_]*)
207203 beginCaptures :
208204 ' 1 ' : {name: storage.type.function.python}
209205 end : (\()|\s*($\n?|#.*$\n?)
@@ -217,6 +213,26 @@ patterns:
217213 patterns :
218214 - include : ' #entity_name_function'
219215
216+ - match : \b(((?:async\s+)?def)|lambda)\b
217+ captures :
218+ ' 1 ' : {name: storage.type.function.python}
219+
220+ -
221+ comment : |
222+ Keywords that delimit flow blocks or alter flow from within a
223+ block.
224+
225+ This block should be matched *after* meta.function.python to
226+ let 'async def' be matched *first*.
227+
228+ name : keyword.control.flow.python
229+ match : |
230+ (?x) \b(
231+ async | await | break | continue | elif | else | except | finally | for |
232+ if | pass | raise | return | try | while | with |
233+ (yield(?:\s+from)?)
234+ )\b
235+
220236 - name : meta.function.inline.python
221237 begin : (lambda)(?=\s+|:)
222238 beginCaptures :
@@ -350,10 +366,6 @@ patterns:
350366 patterns :
351367 - include : $self
352368
353- - match : \b(def|lambda)\b
354- captures :
355- ' 1 ' : {name: storage.type.function.python}
356-
357369- match : \b(class)\b
358370 captures :
359371 ' 1 ' : {name: storage.type.class.python}
@@ -474,7 +486,30 @@ repository:
474486
475487 builtin_exceptions :
476488 name : support.type.exception.python
477- match : \b((Arithmetic|Assertion|Attribute|Buffer|EOF|Environment|FloatingPoint|IO|Import|Indentation|Index|Key|Lookup|Memory|Name|NotImplemented|OS|Overflow|Reference|Runtime|Standard|Syntax|System|Tab|Type|UnboundLocal|Unicode(Encode|Decode|Translate)?|Value|VMS|Windows|ZeroDivision|([\p{Alpha}_][\p{Alnum}_]*))?Error|((Pending)?Deprecation|Runtime|Syntax|User|Future|Import|Unicode|Bytes)?Warning|SystemExit|Stop(Async)?Iteration|NotImplemented|KeyboardInterrupt|GeneratorExit|([\p{Alpha}_][\p{Alnum}_]*)?Exception)\b
489+ match : |
490+ (?x) \b(
491+ (
492+ Arithmetic | Assertion | Attribute | Buffer | BlockingIO |
493+ BrokenPipe | ChildProcess |
494+ (Connection (Aborted | Refused | Reset)?) |
495+ EOF | Environment | FileExists | FileNotFound |
496+ FloatingPoint | IO | Import | Indentation | Index | Interrupted |
497+ IsADirectory | NotADirectory | Permission | ProcessLookup |
498+ Timeout |
499+ Key | Lookup | Memory | Name | NotImplemented | OS | Overflow |
500+ Reference | Runtime | Recursion | Standard | Syntax | System |
501+ Tab | Type | UnboundLocal | Unicode(Encode|Decode|Translate)? |
502+ Value | VMS | Windows | ZeroDivision
503+ )? Error
504+ |
505+ ((Pending)?Deprecation | Runtime | Syntax | User | Future | Import |
506+ Unicode | Bytes | Resource
507+ )? Warning
508+ |
509+ SystemExit | Stop(Async)?Iteration | NotImplemented |
510+ KeyboardInterrupt |
511+ GeneratorExit | Exception
512+ )\b
478513
479514 builtin_functions :
480515 patterns :
@@ -629,7 +664,7 @@ repository:
629664
630665 illegal_names :
631666 name : invalid.illegal.name.python
632- match : \b(and|as|assert|async| await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b
667+ match : \b(and|as|assert|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b
633668
634669 keyword_arguments :
635670 begin : \b([\p{Alpha}_][\p{Alnum}_]*)\s*(=)(?!=)
@@ -1036,6 +1071,6 @@ repository:
10361071author :
Matt Morrison @MattDMo [email protected] 10371072bundleUUID : 0F24FCF1-6543-4CC6-8B33-2EAED401FE3A
10381073firstLineMatch : ^#!/.*\bpython[0-9.-]*\b
1039- foldingStartMarker : ^\s*(def|class)\s+([.\p{Alnum}_ <]+)\s*(\((.*)\))?\s*:|\{\s*$|\(\s*$|\[\s*$|^\s*"""(?=.)(?!.*""")
1074+ foldingStartMarker : ^\s*(((?:async\s+)? def) |class)\s+([.\p{Alnum}_ <]+)\s*(\((.*)\))?\s*:|\{\s*$|\(\s*$|\[\s*$|^\s*"""(?=.)(?!.*""")
10401075foldingStopMarker : ^\s*$|^\s*\}|^\s*\]|^\s*\)|^\s*"""\s*$
10411076keyEquivalent : ^~P
0 commit comments