Skip to content

Commit 7abc9ea

Browse files
committed
Ticket #4933: improve TOML syntax highlighting
* Fix broken comments handling. * Support escapes in basic (double-quoted) strings. * Highlight literal (single-quoted) strings. * Support multi-line strings. * Make tables (sections) easily distinguishable from comments. * Make highlighting of inline tables consistent. * Unify colors with other syntax files like YAML / C / Shell. Signed-off-by: Sergey Naumov <sknaumov@gmail.com>
1 parent ba57be3 commit 7abc9ea

1 file changed

Lines changed: 47 additions & 15 deletions

File tree

misc/syntax/toml.syntax

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,54 @@
11
# TOML: Tom's Obvious Minimal Language
2+
#
3+
# Specification: https://toml.io/en/v1.1.0
24

3-
context default white
5+
define table yellow
6+
define key cyan
7+
define equal white
8+
define brace brightcyan
9+
define bool cyan
10+
define number cyan
11+
define string green
12+
define escape brightgreen
13+
define comment brown
414

5-
# groups
6-
context [ \n brown
7-
keyword [ yellow
8-
keyword ] yellow
15+
context default
16+
keyword linestart \[\t\s\][[*]] table
17+
keyword linestart \[\t\s\][*] table
918

10-
# assignment
11-
context exclusive = \n write
12-
keyword "*" brightgreen
13-
keyword whole false brightcyan
14-
keyword whole true brightcyan
15-
keyword \{0123456789\} brightcyan
19+
keyword = equal
20+
keyword [ brace
21+
keyword ] brace
22+
keyword { brace
23+
keyword } brace
1624

17-
# comments
18-
context # \n brown
25+
keyword linestart \[\t\s\]\{0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-\}\[0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-.\] key
26+
27+
keyword whole true bool
28+
keyword whole false bool
29+
30+
keyword whole inf number
31+
keyword whole nan number
32+
33+
keyword whole 0\{box\}\{0123456789ABCDEFabcdef\}\[0123456789ABCDEFabcdef_\] number
34+
keyword whole \{0123456789\}\[0123456789_\]\{eE\}\[0123456789_\] number
35+
keyword whole \{0123456789\}\[0123456789_\] number
36+
37+
context # \n comment
1938
spellcheck
2039

21-
# other strings
22-
context " " brightgreen
40+
context """ """ string
41+
keyword \\" escape
42+
keyword \\\\ escape
43+
keyword \\\{uU\}\[0123456789\] escape
44+
keyword \\\{bfnrt\} escape
45+
46+
context ''' ''' string
47+
48+
context " " string
49+
keyword \\" escape
50+
keyword \\\\ escape
51+
keyword \\\{uU\}\[0123456789\] escape
52+
keyword \\\{bfnrt\} escape
53+
54+
context ' ' string

0 commit comments

Comments
 (0)