krz/orgo
Lightning fast org-mode static site generator.
clone: git clone https://gitbay.org/krz/orgo.git
v0.22.0: syntaxes/TOML.sublime-syntax · raw
1%YAML 1.2
2---
3# TOML, for syntect. Not one of the definitions syntect bundles, and the first thing a
4# config-heavy site needs — every orgo.toml example in the documentation is one.
5#
6# Scope names are the standard TextMate ones, so any syntect theme colours this without
7# knowing it exists.
8name: TOML
9file_extensions: [toml, tml]
10scope: source.toml
11
12contexts:
13 main:
14 - include: comments
15 - include: tables
16 - include: keys
17 - include: values
18
19 comments:
20 - match: '#'
21 scope: punctuation.definition.comment.toml
22 push:
23 - meta_scope: comment.line.number-sign.toml
24 - match: $\n?
25 pop: true
26
27 tables:
28 # [[array.of.tables]] before [table], so the doubled bracket wins.
29 - match: '^\s*(\[\[)([^\]]*)(\]\])'
30 captures:
31 1: punctuation.definition.table.array.toml
32 2: entity.name.section.toml
33 3: punctuation.definition.table.array.toml
34 - match: '^\s*(\[)([^\]]*)(\])'
35 captures:
36 1: punctuation.definition.table.toml
37 2: entity.name.section.toml
38 3: punctuation.definition.table.toml
39
40 keys:
41 - match: '([A-Za-z0-9_\-]+|"[^"]*"|''[^'']*'')\s*(=)'
42 captures:
43 1: variable.other.key.toml
44 2: keyword.operator.assignment.toml
45
46 values:
47 - include: strings
48 - match: '\b(true|false)\b'
49 scope: constant.language.toml
50 # Dates and times before numbers, or the year is read as an integer.
51 - match: '\b\d{4}-\d{2}-\d{2}([Tt ]\d{2}:\d{2}:\d{2}(\.\d+)?([Zz]|[+\-]\d{2}:\d{2})?)?'
52 scope: constant.numeric.date.toml
53 - match: '\b\d{2}:\d{2}:\d{2}(\.\d+)?'
54 scope: constant.numeric.time.toml
55 - match: '\b0x[0-9A-Fa-f_]+\b'
56 scope: constant.numeric.hex.toml
57 - match: '\b0o[0-7_]+\b'
58 scope: constant.numeric.oct.toml
59 - match: '\b0b[01_]+\b'
60 scope: constant.numeric.bin.toml
61 - match: '[+\-]?\b\d[\d_]*(\.[\d_]+)?([eE][+\-]?\d+)?\b'
62 scope: constant.numeric.toml
63 - match: '\b(inf|nan)\b'
64 scope: constant.numeric.toml
65
66 strings:
67 # Multi-line forms first: """ would otherwise match as an empty "" plus a stray ".
68 - match: '"""'
69 scope: punctuation.definition.string.begin.toml
70 push:
71 - meta_scope: string.quoted.double.block.toml
72 - match: '"""'
73 scope: punctuation.definition.string.end.toml
74 pop: true
75 - include: escapes
76 - match: "'''"
77 scope: punctuation.definition.string.begin.toml
78 push:
79 - meta_scope: string.quoted.single.block.toml
80 - match: "'''"
81 scope: punctuation.definition.string.end.toml
82 pop: true
83 - match: '"'
84 scope: punctuation.definition.string.begin.toml
85 push:
86 - meta_scope: string.quoted.double.toml
87 - match: '"'
88 scope: punctuation.definition.string.end.toml
89 pop: true
90 - match: $\n?
91 pop: true
92 - include: escapes
93 - match: "'"
94 scope: punctuation.definition.string.begin.toml
95 push:
96 - meta_scope: string.quoted.single.toml
97 - match: "'"
98 scope: punctuation.definition.string.end.toml
99 pop: true
100 - match: $\n?
101 pop: true
102
103 escapes:
104 - match: '\\(u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}|[btnfr"\\/]|\s*\n)'
105 scope: constant.character.escape.toml