25973
|
1 " Vim syntax file
|
|
2 " Language: TOML
|
|
3 " Homepage: https://github.com/cespare/vim-toml
|
|
4 " Maintainer: Aman Verma
|
|
5 " Previous Maintainer: Caleb Spare <cespare@gmail.com>
|
|
6 " Last Change: Oct 8, 2021
|
|
7
|
|
8 if exists('b:current_syntax')
|
|
9 finish
|
|
10 endif
|
|
11
|
|
12 syn match tomlEscape /\\[btnfr"/\\]/ display contained
|
|
13 syn match tomlEscape /\\u\x\{4}/ contained
|
|
14 syn match tomlEscape /\\U\x\{8}/ contained
|
|
15 syn match tomlLineEscape /\\$/ contained
|
|
16
|
|
17 " Basic strings
|
|
18 syn region tomlString oneline start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=tomlEscape
|
|
19 " Multi-line basic strings
|
|
20 syn region tomlString start=/"""/ end=/"""/ contains=tomlEscape,tomlLineEscape
|
|
21 " Literal strings
|
|
22 syn region tomlString oneline start=/'/ end=/'/
|
|
23 " Multi-line literal strings
|
|
24 syn region tomlString start=/'''/ end=/'''/
|
|
25
|
|
26 syn match tomlInteger /[+-]\=\<[1-9]\(_\=\d\)*\>/ display
|
|
27 syn match tomlInteger /[+-]\=\<0\>/ display
|
|
28 syn match tomlInteger /[+-]\=\<0x[[:xdigit:]]\(_\=[[:xdigit:]]\)*\>/ display
|
|
29 syn match tomlInteger /[+-]\=\<0o[0-7]\(_\=[0-7]\)*\>/ display
|
|
30 syn match tomlInteger /[+-]\=\<0b[01]\(_\=[01]\)*\>/ display
|
|
31 syn match tomlInteger /[+-]\=\<\(inf\|nan\)\>/ display
|
|
32
|
|
33 syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\.\d\+\>/ display
|
|
34 syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\(\.\d\(_\=\d\)*\)\=[eE][+-]\=\d\(_\=\d\)*\>/ display
|
|
35
|
|
36 syn match tomlBoolean /\<\%(true\|false\)\>/ display
|
|
37
|
|
38 " https://tools.ietf.org/html/rfc3339
|
|
39 syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}/ display
|
|
40 syn match tomlDate /\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?/ display
|
|
41 syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}[T ]\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?\%(Z\|[+-]\d\{2\}:\d\{2\}\)\?/ display
|
|
42
|
|
43 syn match tomlDotInKey /\v[^.]+\zs\./ contained display
|
|
44 syn match tomlKey /\v(^|[{,])\s*\zs[[:alnum:]._-]+\ze\s*\=/ contains=tomlDotInKey display
|
|
45 syn region tomlKeyDq oneline start=/\v(^|[{,])\s*\zs"/ end=/"\ze\s*=/ contains=tomlEscape
|
|
46 syn region tomlKeySq oneline start=/\v(^|[{,])\s*\zs'/ end=/'\ze\s*=/
|
|
47
|
|
48 syn region tomlTable oneline start=/^\s*\[[^\[]/ end=/\]/ contains=tomlKey,tomlKeyDq,tomlKeySq,tomlDotInKey
|
|
49
|
|
50 syn region tomlTableArray oneline start=/^\s*\[\[/ end=/\]\]/ contains=tomlKey,tomlKeyDq,tomlKeySq,tomlDotInKey
|
|
51
|
|
52 syn region tomlKeyValueArray start=/=\s*\[\zs/ end=/\]/ contains=@tomlValue
|
|
53
|
|
54 syn region tomlArray start=/\[/ end=/\]/ contains=@tomlValue contained
|
|
55
|
|
56 syn cluster tomlValue contains=tomlArray,tomlString,tomlInteger,tomlFloat,tomlBoolean,tomlDate,tomlComment
|
|
57
|
|
58 syn keyword tomlTodo TODO FIXME XXX BUG contained
|
|
59
|
|
60 syn match tomlComment /#.*/ contains=@Spell,tomlTodo
|
|
61
|
|
62 hi def link tomlComment Comment
|
|
63 hi def link tomlTodo Todo
|
|
64 hi def link tomlTableArray Title
|
|
65 hi def link tomlTable Title
|
|
66 hi def link tomlDotInKey Normal
|
|
67 hi def link tomlKeySq Identifier
|
|
68 hi def link tomlKeyDq Identifier
|
|
69 hi def link tomlKey Identifier
|
|
70 hi def link tomlDate Constant
|
|
71 hi def link tomlBoolean Boolean
|
|
72 hi def link tomlFloat Float
|
|
73 hi def link tomlInteger Number
|
|
74 hi def link tomlString String
|
|
75 hi def link tomlLineEscape SpecialChar
|
|
76 hi def link tomlEscape SpecialChar
|
|
77
|
|
78 syn sync minlines=500
|
|
79 let b:current_syntax = 'toml'
|
|
80
|
|
81 " vim: et sw=2 sts=2
|