Skip to content

Commit 095560e

Browse files
author
MattDMo
committed
Should address the major stuff in #17
1 parent 5722209 commit 095560e

File tree

1 file changed

+40
-16
lines changed

1 file changed

+40
-16
lines changed

PythonImproved-Unicode.YAML-tmLanguage

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,13 @@ patterns:
250250

251251
- comment: a decorator may be a function call which returns a decorator.
252252
name: meta.function.decorator.python
253-
begin: ^\s*(?=@\s*[\p{Alpha}_][\p{Alnum}_]*(?:\.[\p{Alpha}_][\p{Alnum}_]*)*\s*\()
254-
end: (\))
253+
begin: ^\s*(?=@\s*[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*\s*\()
254+
end: (?<=\))
255255
endCaptures:
256256
'1': {name: punctuation.definition.arguments.end.python}
257257
patterns:
258258
- contentName: entity.name.function.decorator.python
259-
begin: (?=(@)\s*[\p{Alpha}_][\p{Alnum}_]*(?:\.[\p{Alpha}_][\p{Alnum}_]*)*\s*\()
259+
begin: (?=(@)\s*[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*\s*\()
260260
beginCaptures:
261261
'1': {name: punctuation.definition.decorator.python}
262262
end: (?=\s*\()
@@ -266,17 +266,19 @@ patterns:
266266
begin: (\()
267267
beginCaptures:
268268
'1': {name: punctuation.definition.arguments.begin.python}
269-
end: (?=\))
269+
end: (?=(\)))
270+
endCaptures:
271+
'1': {name: punctuation.definition.arguments.end.python}
270272
patterns:
271273
- include: '#keyword_arguments'
272274
- include: $self
273275

274276
- name: meta.function.decorator.python
275277
contentName: entity.name.function.decorator.python
276-
begin: ^\s*(?=@\s*[\p{Alpha}_][\p{Alnum}_]*(?:\.[\p{Alpha}_][\p{Alnum}_]*)*)
278+
begin: ^\s*(?=@\s*[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*)
277279
end: (?=\s|$\n?|#)
278280
patterns:
279-
- begin: (?=(@)\s*[\p{Alpha}_][\p{Alnum}_]*(\.[\p{Alpha}_][\p{Alnum}_]*)*)
281+
- begin: (?=(@)\s*[\p{Alpha}_][\p{Alnum}_]*(\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*)
280282
beginCaptures:
281283
'1': {name: punctuation.definition.decorator.python}
282284
end: (?=\s|$\n?|#)
@@ -312,9 +314,10 @@ patterns:
312314
- include: '#generic_object_names'
313315

314316
- name: meta.function-call.python
315-
begin: (?:\.)?([\p{Alpha}_][\p{Alnum}_]*)\s*(?=\()
317+
begin: (?:\.)?([\p{Alpha}_][\p{Alnum}_]*)\s*(?=(\())
316318
beginCaptures:
317319
'1': {name: meta.function-call.generic.python}
320+
'2': {name: punctuation.definition.arguments.begin.python}
318321
end: (\))
319322
endCaptures:
320323
'1': {name: punctuation.definition.arguments.end.python}
@@ -327,28 +330,44 @@ patterns:
327330
begin: (\()
328331
beginCaptures:
329332
'1': {name: punctuation.definition.arguments.begin.python}
330-
end: (?=\))
333+
end: (?=(\)))
334+
endCaptures:
335+
'1': {name: punctuation.definition.arguments.end.python}
331336
patterns:
332337
- include: '#keyword_arguments'
333338
- include: $self
339+
- begin: \G
340+
end: (?=\()
341+
patterns:
342+
- include: '#dotted_name'
343+
344+
- comment: Py2 print statement that should only be matched after function calls
345+
name: keyword.other.print.python
346+
match: \b(print)(?=\s)(?!\s*([.,]|$))
334347

335348
- name: meta.item-access.python
336-
begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\.[\p{Alpha}_][\p{Alnum}_]*)*\s*\[)
349+
begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*\s*\[)
337350
end: (\])
338351
endCaptures:
339352
'1': {name: punctuation.definition.arguments.end.python}
340353
patterns:
341-
- begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\.[\p{Alpha}_][\p{Alnum}_]*)*\s*\[)
354+
- begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*\s*\[)
342355
end: (?=\s*\[)
343356
patterns:
344357
- include: '#dotted_name'
345358
- contentName: meta.item-access.arguments.python
346359
begin: (\[)
347360
beginCaptures:
348361
'1': {name: punctuation.definition.arguments.begin.python}
349-
end: (?=\])
362+
end: (?=(\]))
363+
endCaptures:
364+
'1': {name: punctuation.definition.arguments.end.python}
350365
patterns:
351366
- include: $self
367+
- begin: \G
368+
end: (?=\[)
369+
patterns:
370+
- include: '#dotted_name'
352371

353372
- name: meta.item-access.python
354373
contentName: meta.item-access.arguments.python
@@ -482,14 +501,15 @@ repository:
482501
builtin_functions:
483502
patterns:
484503
- name: meta.function-call.python
485-
begin: (?<!\.)(__import__|abs|all|any|ascii|basestring|bin|bool|bytearray|bytes|callable|chr|classmethod|cmp|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\s*(?=\()
504+
begin: (?<!\.)(__import__|abs|all|any|ascii|basestring|bin|bool|bytearray|bytes|callable|chr|classmethod|cmp|compile|complex|delattr|dict|dir|divmod|enumerate|eval|exec|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|print|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\s*(?=(\())
486505
beginCaptures:
487506
'1': {name: support.function.builtin.python}
507+
'2': {name: punctuation.definition.arguments.begin.python}
488508
end: (\))
489509
endCaptures:
490510
'1': {name: punctuation.definition.arguments.end.python}
491511
patterns:
492-
- begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\.[\p{Alpha}_][\p{Alnum}_]*)*\s*\()
512+
- begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*\s*\()
493513
end: (?=\s*\()
494514
patterns:
495515
- include: '#dotted_name'
@@ -558,10 +578,13 @@ repository:
558578
- include: '#string_quoted_single'
559579

560580
dotted_name:
561-
begin: (?=[\p{Alpha}_][\p{Alnum}_]*(?:\.[\p{Alpha}_][\p{Alnum}_]*)*)
562-
end: (?![\p{Alnum}_\.])
581+
begin: (?x)(?=(?:\.(?!\s+import)\s*)?[\p{Alpha}_][\p{Alnum}_]*(?:\s*\.\s*[\p{Alpha}_][\p{Alnum}_]*)*)
582+
end: (?x)(?![\p{Alnum}_\.\s])|(?=(?<!\.)\s+[^.])|$
583+
contentName: meta.dotted-name.python
563584
patterns:
564585
- begin: (\.)(?=[\p{Alpha}_][\p{Alnum}_]*)
586+
beginCaptures:
587+
'1': {name: meta.dot.python}
565588
end: (?![\p{Alnum}_])
566589
patterns:
567590
- include: '#magic_function_names'
@@ -593,7 +616,7 @@ repository:
593616

594617
errors_warnings_exceptions:
595618
name: support.type.exception.python
596-
match: (?x)\b((Arithmetic|Assertion|Attribute|Buffer|BlockingIO|BrokenPipe|ChildProcess|(Connection(Aborted|Refused|Reset)?)|EOF|Environment|FileExists|FileNotFound|FloatingPoint|IO|Import|Indentation|Index|Interrupted|IsADirectory|NotADirectory|Permission|ProcessLookup|Timeout|Key|Lookup|Memory|Name|NotImplemented|OS|Overflow|Reference|Runtime|Recursion|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|Resource)?Warning|SystemExit|Stop(Async)?Iteration|NotImplemented|KeyboardInterrupt|GeneratorExit|([\p{Alpha}_][\p{Alnum}_]*)?Exception)\b
619+
match: (?x)\b((Arithmetic|Assertion|Attribute|Buffer|BlockingIO|BrokenPipe|ChildProcess|(Connection(Aborted|Refused|Reset)?)|EOF|Environment|FileExists|FileNotFound|FloatingPoint|IO|Import|Indentation|Index|Interrupted|IsADirectory|NotADirectory|Permission|ProcessLookup|Timeout|Key|Lookup|Memory|Name|NotImplemented|OS|Overflow|Reference|Runtime|Recursion|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|Resource)?Warning|SystemExit|Stop(Async)?Iteration|NotImplemented|KeyboardInterrupt|GeneratorExit|([\.\p{Alpha}_][\p{Alnum}_]*)?Exception)\b
597620

598621
escaped_char:
599622
match: (\\x[\h]{2})|(\\[0-7]{3})|(\\\n)|(\\\\)|(\\\")|(\\')|(\\a)|(\\b)|(\\f)|(\\n)|(\\r)|(\\t)|(\\v)
@@ -629,6 +652,7 @@ repository:
629652
- include: '#generic_names'
630653

631654
generic_names:
655+
name: meta.identifier.python
632656
match: '[\p{Alpha}_][\p{Alnum}_]*'
633657

634658
generic_object_names:

0 commit comments

Comments
 (0)