%YAML 1.2
---
name: TOML
file_extensions:
- toml
scope: source.toml
contexts:
main:
- match: '#.*$'
scope: comment.line.number-sign.toml
- match: '^\s*(\[\[)([^\]]*?)(\]\])'
captures:
1: punctuation.definition.table.array.toml
2: entity.name.table.array.toml
3: punctuation.definition.table.array.toml
- match: '^\s*(\[)([^\]]*?)(\])'
captures:
1: punctuation.definition.table.toml
2: entity.name.table.toml
3: punctuation.definition.table.toml
- match: '([A-Za-z0-9_-]+)\s*(=)'
captures:
1: variable.other.key.toml
2: keyword.operator.assignment.toml
push: value
- match: '([A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)+)\s*(=)'
captures:
1: variable.other.key.toml
2: keyword.operator.assignment.toml
push: value
- match: '("[^"]*")\s*(=)'
captures:
1: variable.other.key.toml
2: keyword.operator.assignment.toml
push: value
value:
- match: '$'
pop: true
- match: '#.*$'
scope: comment.line.number-sign.toml
pop: true
- match: '"""'
scope: punctuation.definition.string.begin.toml
push: string_multiline_basic
- match: "'''"
scope: punctuation.definition.string.begin.toml
push: string_multiline_literal
- match: '"'
scope: punctuation.definition.string.begin.toml
push: string_basic
- match: "'"
scope: punctuation.definition.string.begin.toml
push: string_literal
- match: '\b(true|false)\b'
scope: constant.language.boolean.toml
pop: true
- match: '\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?'
scope: constant.other.datetime.toml
pop: true
- match: '\d{4}-\d{2}-\d{2}'
scope: constant.other.date.toml
pop: true
- match: '[+-]?(?:\d+\.\d*|\d*\.\d+)(?:[eE][+-]?\d+)?'
scope: constant.numeric.float.toml
pop: true
- match: '[+-]?(?:inf|nan)\b'
scope: constant.numeric.float.toml
pop: true
- match: '0x[0-9a-fA-F_]+'
scope: constant.numeric.hex.toml
pop: true
- match: '0o[0-7_]+'
scope: constant.numeric.octal.toml
pop: true
- match: '0b[01_]+'
scope: constant.numeric.binary.toml
pop: true
- match: '[+-]?\d[\d_]*'
scope: constant.numeric.integer.toml
pop: true
- match: '\{'
scope: punctuation.definition.inline-table.begin.toml
- match: '\}'
scope: punctuation.definition.inline-table.end.toml
pop: true
- match: '\['
scope: punctuation.definition.array.begin.toml
- match: '\]'
scope: punctuation.definition.array.end.toml
pop: true
string_basic:
- meta_scope: string.quoted.double.toml
- match: '\\[btnfr"\\]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}'
scope: constant.character.escape.toml
- match: '"'
scope: punctuation.definition.string.end.toml
pop: true
string_literal:
- meta_scope: string.quoted.single.toml
- match: "'"
scope: punctuation.definition.string.end.toml
pop: true
string_multiline_basic:
- meta_scope: string.quoted.double.block.toml
- match: '\\[btnfr"\\]|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8}'
scope: constant.character.escape.toml
- match: '"""'
scope: punctuation.definition.string.end.toml
pop: true
string_multiline_literal:
- meta_scope: string.quoted.single.block.toml
- match: "'''"
scope: punctuation.definition.string.end.toml
pop: true