Skip to content

Instantly share code, notes, and snippets.

@arthurdarcet
Created March 4, 2016 10:17
Show Gist options
  • Save arthurdarcet/8cb28b0ee52f08c7f11e to your computer and use it in GitHub Desktop.
Save arthurdarcet/8cb28b0ee52f08c7f11e to your computer and use it in GitHub Desktop.
Python syntax for Sublime text with PEP492 support (async/await)
%YAML 1.2
---
name: Python
file_extensions:
- py
- rpy
- pyw
- cpy
- SConstruct
- Sconstruct
- sconstruct
- SConscript
- gyp
- gypi
first_line_match: ^#!/.*\bpython\d?\b
scope: source.python
variables:
sql_indicator: \s*(?:SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER)\b
contexts:
main:
- match: "#"
captures:
0: punctuation.definition.comment.python
push:
- meta_scope: comment.line.number-sign.python
- match: \n
pop: true
- match: \b(?i:(0x\h*)L)
scope: constant.numeric.integer.long.hexadecimal.python
- match: \b(?i:(0x\h*))
scope: constant.numeric.integer.hexadecimal.python
- match: '\b(?i:(0[0-7]+)L)'
scope: constant.numeric.integer.long.octal.python
- match: '\b(0[0-7]+)'
scope: constant.numeric.integer.octal.python
- match: '\b(?i:(((\d+(\.(?=[^a-zA-Z_])\d*)?|(?<=[^0-9a-zA-Z_])\.\d+)(e[\-\+]?\d+)?))J)'
scope: constant.numeric.complex.python
- match: '\b(?i:(\d+\.\d*(e[\-\+]?\d+)?))(?=[^a-zA-Z_])'
scope: constant.numeric.float.python
- match: '(?<=[^0-9a-zA-Z_])(?i:(\.\d+(e[\-\+]?\d+)?))'
scope: constant.numeric.float.python
- match: '\b(?i:(\d+e[\-\+]?\d+))'
scope: constant.numeric.float.python
- match: '\b(?i:([1-9]+[0-9]*|0)L)'
scope: constant.numeric.integer.long.decimal.python
- match: '\b([1-9]+[0-9]*|0)'
scope: constant.numeric.integer.decimal.python
- match: \b(global)\b
captures:
1: storage.modifier.global.python
- match: \b(nonlocal)\b
captures:
1: storage.modifier.nonlocal.python
- match: \b(?:(import)|(from))\b
captures:
1: keyword.control.import.python
2: keyword.control.import.from.python
- match: \b(elif|else|except|finally|for|if|try|while|with|async with|await|break|continue|pass|raise|return|yield)\b
comment: keywords that delimit flow blocks or alter flow from within a block
scope: keyword.control.flow.python
- match: \b(and|in|is|not|or)\b
comment: keyword operators that evaluate to True or False
scope: keyword.operator.logical.python
- match: \b(as|assert|del|exec|print)\b
comment: keywords that haven't fit into other groups (yet).
captures:
1: keyword.other.python
- match: <>
scope: invalid.deprecated.operator.python
- match: <\=|>\=|\=\=|<|>|\!\=
scope: keyword.operator.comparison.python
- match: \+\=|-\=|\*\=|/\=|//\=|%\=|&\=|\|\=|\^\=|>>\=|<<\=|\*\*\=
scope: keyword.operator.assignment.augmented.python
- match: \+|\-|\*|\*\*|/|//|%|<<|>>|&|\||\^|~
scope: keyword.operator.arithmetic.python
- match: \=
scope: keyword.operator.assignment.python
- match: '^\s*(class)\s+(?=[a-zA-Z_][a-zA-Z_0-9]*\s*\:)'
captures:
1: storage.type.class.python
push:
- meta_scope: meta.class.old-style.python
- meta_content_scope: entity.name.type.class.python
- match: \s*(:)
captures:
1: punctuation.section.class.begin.python
pop: true
- include: entity_name_class
- match: '^\s*(class)\s+(?=[a-zA-Z_][a-zA-Z_0-9]*\s*\()'
captures:
1: storage.type.class.python
push:
- meta_scope: meta.class.python
- match: (\))\s*(?:(\:)|(.*$\n?))
captures:
1: punctuation.definition.inheritance.end.python
2: punctuation.section.class.begin.python
3: invalid.illegal.missing-section-begin.python
pop: true
- match: "(?=[A-Za-z_][A-Za-z0-9_]*)"
push:
- meta_content_scope: entity.name.type.class.python
- match: "(?![A-Za-z0-9_])"
pop: true
- include: entity_name_class
- match: (\()
captures:
1: punctuation.definition.inheritance.begin.python
push:
- meta_content_scope: meta.class.inheritance.python
- match: (?=\)|:)
pop: true
- match: (?<=\(|,)\s*
push:
- meta_content_scope: entity.other.inherited-class.python
- match: \s*(?:(,)|(?=\)))
captures:
1: punctuation.separator.inheritance.python
pop: true
- include: main
- match: '^\s*(class)\s+(?=[a-zA-Z_][a-zA-Z_0-9])'
captures:
1: storage.type.class.python
push:
- meta_scope: meta.class.python
- match: (\()|(\s*$\n?|#.*$\n?)
captures:
1: punctuation.definition.inheritance.begin.python
2: invalid.illegal.missing-inheritance.python
pop: true
- match: "(?=[A-Za-z_][A-Za-z0-9_]*)"
push:
- meta_content_scope: entity.name.type.class.python
- match: "(?![A-Za-z0-9_])"
pop: true
- include: entity_name_function
- match: '^\s*(async def|def)\s+(?=[A-Za-z_][A-Za-z0-9_]*\s*\()'
captures:
1: storage.type.function.python
push:
- meta_scope: meta.function.python
- match: (\))\s*(?:(\:)|(.*$\n?))
captures:
1: punctuation.definition.parameters.end.python
2: punctuation.section.function.begin.python
3: invalid.illegal.missing-section-begin.python
pop: true
- match: "(?=[A-Za-z_][A-Za-z0-9_]*)"
push:
- meta_content_scope: entity.name.function.python
- match: "(?![A-Za-z0-9_])"
pop: true
- include: entity_name_function
- match: (\()
captures:
1: punctuation.definition.parameters.begin.python
push:
- meta_content_scope: meta.function.parameters.python
- match: (?=\)\s*\:)
pop: true
- include: keyword_arguments
- match: "#"
captures:
0: punctuation.definition.comment.python
push:
- meta_scope: comment.line.number-sign.python
- match: \n
pop: true
- match: '\b([a-zA-Z_][a-zA-Z_0-9]*)\s*(?:(,)|(?=[\n\)]))'
captures:
1: variable.parameter.function.python
2: punctuation.separator.parameters.python
- match: '^\s*(async def|def)\s+(?=[A-Za-z_][A-Za-z0-9_]*)'
captures:
1: storage.type.function.python
push:
- meta_scope: meta.function.python
- match: (\()|\s*($\n?|#.*$\n?)
captures:
1: punctuation.definition.parameters.begin.python
2: invalid.illegal.missing-parameters.python
pop: true
- match: "(?=[A-Za-z_][A-Za-z0-9_]*)"
push:
- meta_content_scope: entity.name.function.python
- match: "(?![A-Za-z0-9_])"
pop: true
- include: entity_name_function
- match: (lambda)(?=\s+)
captures:
1: storage.type.function.inline.python
push:
- meta_scope: meta.function.inline.python
- match: (\:)
captures:
1: punctuation.definition.parameters.end.python
2: punctuation.section.function.begin.python
3: invalid.illegal.missing-section-begin.python
pop: true
- match: \s+
push:
- meta_content_scope: meta.function.inline.parameters.python
- match: (?=\:)
pop: true
- include: keyword_arguments
- match: '\b([a-zA-Z_][a-zA-Z_0-9]*)\s*(?:(,)|(?=[\n\)\:]))'
captures:
1: variable.parameter.function.python
2: punctuation.separator.parameters.python
- match: '^\s*(?=@\s*[A-Za-z_][A-Za-z0-9_]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*\s*\()'
comment: a decorator may be a function call which returns a decorator.
push:
- meta_scope: meta.function.decorator.python
- match: (\))
captures:
1: punctuation.definition.arguments.end.python
pop: true
- match: '(?=(@)\s*[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*\s*\()'
captures:
1: punctuation.definition.decorator.python
push:
- meta_content_scope: entity.name.function.decorator.python
- match: (?=\s*\()
pop: true
- include: dotted_name
- match: (\()
captures:
1: punctuation.definition.arguments.begin.python
push:
- meta_content_scope: meta.function.decorator.arguments.python
- match: (?=\))
pop: true
- include: keyword_arguments
- include: main
- match: '^\s*(?=@\s*[A-Za-z_][A-Za-z0-9_]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*)'
push:
- meta_scope: meta.function.decorator.python
- meta_content_scope: entity.name.function.decorator.python
- match: (?=\s|$\n?|#)
pop: true
- match: '(?=(@)\s*[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*)'
captures:
1: punctuation.definition.decorator.python
push:
- match: (?=\s|$\n?|#)
pop: true
- include: dotted_name
- match: '(?<=\)|\])\s*(\()'
captures:
1: punctuation.definition.arguments.begin.python
push:
- meta_scope: meta.function-call.python
- meta_content_scope: meta.function-call.arguments.python
- match: (\))
captures:
1: punctuation.definition.arguments.end.python
pop: true
- include: keyword_arguments
- include: main
- match: '(?=[A-Za-z_][A-Za-z0-9_]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*\s*\()'
push:
- meta_scope: meta.function-call.python
- match: (\))
captures:
1: punctuation.definition.arguments.end.python
pop: true
- match: '(?=[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*\s*\()'
push:
- match: (?=\s*\()
pop: true
- include: dotted_name
- match: (\()
captures:
1: punctuation.definition.arguments.begin.python
push:
- meta_content_scope: meta.function-call.arguments.python
- match: (?=\))
pop: true
- include: keyword_arguments
- include: main
- match: '(?=[A-Za-z_][A-Za-z0-9_]*(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*\s*\[)'
push:
- meta_scope: meta.item-access.python
- match: '(\])'
captures:
1: punctuation.definition.arguments.end.python
pop: true
- match: '(?=[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*\s*\[)'
push:
- match: '(?=\s*\[)'
pop: true
- include: dotted_name
- match: '(\[)'
captures:
1: punctuation.definition.arguments.begin.python
push:
- meta_content_scope: meta.item-access.arguments.python
- match: '(?=\])'
pop: true
- include: main
- match: '(?<=\)|\])\s*(\[)'
captures:
1: punctuation.definition.arguments.begin.python
push:
- meta_scope: meta.item-access.python
- meta_content_scope: meta.item-access.arguments.python
- match: '(\])'
captures:
1: punctuation.definition.arguments.end.python
pop: true
- include: main
- match: \b(async def|def|lambda)\b
captures:
1: storage.type.function.python
- match: \b(class)\b
captures:
1: storage.type.class.python
- include: line_continuation
- include: language_variables
- match: \b(None|True|False|Ellipsis|NotImplemented)\b
scope: constant.language.python
- include: string_quoted_single
- include: string_quoted_double
- include: dotted_name
- match: (\()
push:
- match: (\))
pop: true
- include: main
- match: \)
scope: invalid.illegal.stray.brace.round.python
- match: '(\[)(\s*(\]))\b'
captures:
1: punctuation.definition.list.begin.python
2: meta.empty-list.python
3: punctuation.definition.list.end.python
- match: '(\[)'
captures:
1: punctuation.definition.list.begin.python
push:
- meta_scope: meta.structure.list.python
- match: '(\])'
captures:
1: punctuation.definition.list.end.python
pop: true
- match: '(?<=\[|\,)\s*(?![\],])'
push:
- meta_content_scope: meta.structure.list.item.python
- match: '\s*(?:(,)|(?=\]))'
captures:
1: punctuation.separator.list.python
pop: true
- include: main
- match: (\()(\s*(\)))
scope: meta.structure.tuple.python
captures:
1: punctuation.definition.tuple.begin.python
2: meta.empty-tuple.python
3: punctuation.definition.tuple.end.python
- match: '(\{)(\s*(\}))'
scope: meta.structure.dictionary.python
captures:
1: punctuation.definition.dictionary.begin.python
2: meta.empty-dictionary.python
3: punctuation.definition.dictionary.end.python
- match: '(\{)'
captures:
1: punctuation.definition.dictionary.begin.python
push:
- meta_scope: meta.structure.dictionary.python
- match: '(\})'
captures:
1: punctuation.definition.dictionary.end.python
pop: true
- match: '(?<=\{|\,|^)\s*(?![\},])'
push:
- meta_content_scope: meta.structure.dictionary.key.python
- match: '\s*(?:(?=\})|(\:))'
captures:
1: punctuation.separator.valuepair.dictionary.python
pop: true
- include: main
- match: (?<=\:|^)\s*
push:
- meta_content_scope: meta.structure.dictionary.value.python
- match: '\s*(?:(?=\})|(,))'
captures:
1: punctuation.separator.dictionary.python
pop: true
- include: main
builtin_exceptions:
- match: |-
(?x)\b(
(
Arithmetic|Assertion|Attribute|BlockingIO|BrokenPipe|Buffer|ChildProcess|
Connection(Aborted|Refused|Reset)?|EOF|Environment|FileExists|
FileNotFound|FloatingPoint|Interrupted|IO|IsADirectoryError|
Import|Indentation|Index|Key|Lookup|Memory|Name|NotADirectory|
NotImplemented|OS|Overflow|Permission|ProcessLookup|Reference|
Runtime|Standard|Syntax|System|Tab|Timeout|Type|UnboundLocal|
Unicode(Encode|Decode|Translate)?|Value|VMS|Windows|ZeroDivision
)Error|
((Pending)?Deprecation|Runtime|Syntax|User|Future|Import|Unicode|Bytes)?Warning|
(Base)?Exception|
SystemExit|StopIteration|NotImplemented|KeyboardInterrupt|GeneratorExit
)\b
scope: support.type.exception.python
builtin_functions:
- match: |-
(?x)\b(
__import__|all|abs|any|apply|ascii|bin|callable|chr|classmethod|cmp|coerce|
compile|delattr|dir|divmod|enumerate|eval|execfile|filter|format|getattr|
globals|hasattr|hash|help|hex|id|input|intern|isinstance|issubclass|iter|
len|locals|map|max|min|next|oct|open|ord|pow|print|property|range|
raw_input|reduce|reload|repr|reversed|round|setattr|sorted|staticmethod|
sum|super|type|unichr|vars|zip
)\b
scope: support.function.builtin.python
builtin_types:
- match: |-
(?x)\b(
basestring|bool|buffer|bytearray|bytes|complex|dict|float|frozenset|int|
list|long|memoryview|object|range|set|slice|str|tuple|unicode|xrange
)\b
scope: support.type.python
constant_placeholder:
- match: '(?i:(%(\([a-z_]+\))?#?0?\-?[ ]?\+?([0-9]*|\*)(\.([0-9]*|\*))?[hL]?[a-z%])|(\{([!\[\].:\w ]+)?\}))'
scope: constant.other.placeholder.python
docstrings:
- match: '^\s*(?=[uU]?[rR]?""")'
push:
- meta_scope: comment.block.python
- match: (?<=""")
pop: true
- include: string_quoted_double
- match: '^\s*(?=[uU]?[rR]?'''''')'
push:
- meta_scope: comment.block.python
- match: (?<=''')
pop: true
- include: string_quoted_single
dotted_name:
- match: '(?=[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*)'
push:
- match: '(?![A-Za-z0-9_\.])'
pop: true
- match: '(\.)(?=[A-Za-z_][A-Za-z0-9_]*)'
push:
- match: "(?![A-Za-z0-9_])"
pop: true
- include: magic_function_names
- include: magic_variable_names
- include: illegal_names
- include: generic_names
- match: '(?<!\.)(?=[A-Za-z_][A-Za-z0-9_]*)'
push:
- match: "(?![A-Za-z0-9_])"
pop: true
- include: builtin_functions
- include: builtin_types
- include: builtin_exceptions
- include: illegal_names
- include: magic_function_names
- include: magic_variable_names
- include: language_variables
- include: generic_names
entity_name_class:
- include: illegal_names
- include: generic_names
entity_name_function:
- include: magic_function_names
- include: illegal_names
- include: generic_names
escaped_char:
- match: '(\\x[0-9A-F]{2})|(\\[0-7]{3})|(\\\n)|(\\\\)|(\\\")|(\\'')|(\\a)|(\\b)|(\\f)|(\\n)|(\\r)|(\\t)|(\\v)'
captures:
1: constant.character.escape.hex.python
2: constant.character.escape.octal.python
3: constant.character.escape.newline.python
4: constant.character.escape.backlash.python
5: constant.character.escape.double-quote.python
6: constant.character.escape.single-quote.python
7: constant.character.escape.bell.python
8: constant.character.escape.backspace.python
9: constant.character.escape.formfeed.python
10: constant.character.escape.linefeed.python
11: constant.character.escape.return.python
12: constant.character.escape.tab.python
13: constant.character.escape.vertical-tab.python
escaped_unicode_char:
- match: '(\\U[0-9A-Fa-f]{8})|(\\u[0-9A-Fa-f]{4})|(\\N\{[a-zA-Z ]+\})'
captures:
1: constant.character.escape.unicode.16-bit-hex.python
2: constant.character.escape.unicode.32-bit-hex.python
3: constant.character.escape.unicode.name.python
function_name:
- include: magic_function_names
- include: magic_variable_names
- include: builtin_exceptions
- include: builtin_functions
- include: builtin_types
- include: generic_names
generic_names:
- match: "[A-Za-z_][A-Za-z0-9_]*"
illegal_names:
- match: \b(and|as|assert|break|class|continue|async|await|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|with|yield)\b
scope: invalid.illegal.name.python
keyword_arguments:
- match: '\b([a-zA-Z_][a-zA-Z_0-9]*)\s*(=)(?!=)'
captures:
1: variable.parameter.function.python
2: keyword.operator.assignment.python
push:
- match: '\s*(?:(,)|(?=$\n?|[\)\:]))'
captures:
1: punctuation.separator.parameters.python
pop: true
- include: main
language_variables:
- match: \b(self|cls)\b
scope: variable.language.python
line_continuation:
- match: (\\)(.*)$\n?
captures:
1: punctuation.separator.continuation.line.python
2: invalid.illegal.unexpected-text.python
magic_function_names:
- match: |-
(?x)\b(__(?:
abs|add|and|call|cmp|coerce|complex|contains|del|delattr|
delete|delitem|delslice|div|divmod|enter|eq|exit|float|
floordiv|ge|get|getattr|getattribute|getitem|getslice|gt|
hash|hex|iadd|iand|idiv|ifloordiv|ilshift|imod|imul|init|
int|invert|ior|ipow|irshift|isub|iter|itruediv|ixor|le|len|
long|lshift|lt|mod|mul|ne|neg|new|nonzero|oct|or|pos|pow|
radd|rand|rdiv|rdivmod|repr|rfloordiv|rlshift|rmod|rmul|ror|
rpow|rrshift|rshift|rsub|rtruediv|rxor|set|setattr|setitem|
setslice|str|sub|truediv|unicode|xor
)__)\b
comment: these methods have magic interpretation by python and are generally called indirectly through syntactic constructs
scope: support.function.magic.python
magic_variable_names:
- match: \b__(all|bases|class|debug|dict|doc|file|members|metaclass|methods|name|slots|weakref)__\b
comment: magic variables which a class/module may have.
scope: support.variable.magic.python
string_quoted_double:
- match: '([uU]?r)(""")'
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
-
- meta_scope: string.quoted.double.block.raw-regex.python
- match: '"""'
captures:
0: punctuation.definition.string.end.python
pop: true
- "Regular Expressions (Python).sublime-syntax"
with_prototype:
- match: '(?=""")'
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: '([uU]?r)(")'
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
-
- meta_scope: string.quoted.double.single-line.raw-regex.python
- match: (")|(\n)
captures:
1: punctuation.definition.string.end.python
2: invalid.illegal.unclosed-string.python
pop: true
- "Regular Expressions (Python).sublime-syntax"
with_prototype:
- match: '(?="|\n)'
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: '([uU]?R)(""")'
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.double.block.raw.python
- match: '"""'
captures:
0: punctuation.definition.string.end.python
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: '([uU]?)(""")'
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.double.block.python
- match: '"""'
captures:
0: punctuation.definition.string.end.python
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: '([uU]?R)(")'
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.double.single-line.raw.python
- match: (")|(\n)
captures:
1: punctuation.definition.string.end.python
2: invalid.illegal.unclosed-string.python
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: '([uU]?)(")'
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.double.single-line.python
- match: (")|(\n)
captures:
1: punctuation.definition.string.end.python
2: invalid.illegal.unclosed-string.python
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: (""")(?={{sql_indicator}})
captures:
1: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.double.block.sql.python
- match: '"""'
captures:
0: punctuation.definition.string.end.python
pop: true
- include: constant_placeholder
- include: escaped_char
- include: 'scope:source.sql'
- match: (")(?={{sql_indicator}})
captures:
1: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.double.single-line.sql.python
- match: (")|(\n)
captures:
1: punctuation.definition.string.end.python
2: invalid.illegal.unclosed-string.python
pop: true
- include: constant_placeholder
- include: escaped_char
- include: 'scope:source.sql'
- match: (""")
captures:
1: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.double.block.python
- match: '"""'
captures:
0: punctuation.definition.string.end.python
pop: true
- include: constant_placeholder
- include: escaped_char
- match: (")
captures:
1: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.double.single-line.python
- match: (")|(\n)
captures:
1: punctuation.definition.string.end.python
2: invalid.illegal.unclosed-string.python
pop: true
- include: constant_placeholder
- include: escaped_char
string_quoted_single:
- match: "([uU]?r)(''')"
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
-
- meta_scope: string.quoted.single.block.raw-regex.python
- match: "'''"
captures:
0: punctuation.definition.string.end.python
pop: true
- "Regular Expressions (Python).sublime-syntax"
with_prototype:
- match: "(?=''')"
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: '([uU]?r)('')'
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
-
- meta_scope: string.quoted.single.single-line.raw-regex.python
- match: (')|(\n)
captures:
1: punctuation.definition.string.end.python
2: invalid.illegal.unclosed-string.python
pop: true
- "Regular Expressions (Python).sublime-syntax"
with_prototype:
- match: "(?='|\n)"
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: "([uU]?R)(''')"
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.single.block.raw.python
- match: "'''"
captures:
0: punctuation.definition.string.end.python
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: "([uU]?)(''')"
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.single.block.python
- match: "'''"
captures:
0: punctuation.definition.string.end.python
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: "([uU]?R)(')"
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.single.single-line.raw.python
- match: (')|(\n)
captures:
1: punctuation.definition.string.end.python
2: invalid.illegal.unclosed-string.python
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: "([uU]?)(')"
captures:
1: storage.type.string.python
2: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.single.single-line.python
- match: (')|(\n)
captures:
1: punctuation.definition.string.end.python
2: invalid.illegal.unclosed-string.python
pop: true
- include: constant_placeholder
- include: escaped_unicode_char
- include: escaped_char
- match: (''')(?={{sql_indicator}})
captures:
1: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.single.block.python
- match: "'''"
captures:
0: punctuation.definition.string.end.python
pop: true
- include: constant_placeholder
- include: escaped_char
- include: 'scope:source.sql'
- match: (')(?={{sql_indicator}})
captures:
1: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.single.single-line.python
- match: (')|(\n)
captures:
1: punctuation.definition.string.end.python
2: invalid.illegal.unclosed-string.python
pop: true
- include: constant_placeholder
- include: escaped_char
- include: 'scope:source.sql'
- match: (''')
captures:
1: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.single.block.python
- match: "'''"
captures:
0: punctuation.definition.string.end.python
pop: true
- include: constant_placeholder
- include: escaped_char
- match: (')
captures:
1: punctuation.definition.string.begin.python
push:
- meta_scope: string.quoted.single.single-line.python
- match: (')|(\n)
captures:
1: punctuation.definition.string.end.python
2: invalid.illegal.unclosed-string.python
pop: true
- include: constant_placeholder
- include: escaped_char
strings:
- include: string_quoted_double
- include: string_quoted_single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment