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