2019-03-04 03:28:35 -05:00
|
|
|
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'toml') != -1
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2014-04-14 19:16:56 -04:00
|
|
|
" Language: TOML
|
|
|
|
" Maintainer: Caleb Spare <cespare@gmail.com>
|
2015-12-06 05:31:38 -05:00
|
|
|
" URL: https://github.com/cespare/vim-toml
|
2014-04-14 19:16:56 -04:00
|
|
|
" LICENSE: MIT
|
|
|
|
|
|
|
|
if exists("b:current_syntax")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2014-11-10 20:37:21 -05:00
|
|
|
syn match tomlEscape /\\[btnfr"/\\]/ display contained
|
|
|
|
syn match tomlEscape /\\u\x\{4}/ contained
|
|
|
|
syn match tomlEscape /\\U\x\{8}/ contained
|
2014-04-14 19:16:56 -04:00
|
|
|
hi def link tomlEscape SpecialChar
|
|
|
|
|
2014-11-10 20:37:21 -05:00
|
|
|
syn match tomlLineEscape /\\$/ contained
|
|
|
|
hi def link tomlLineEscape SpecialChar
|
|
|
|
|
|
|
|
" Basic strings
|
|
|
|
syn region tomlString oneline start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=tomlEscape
|
|
|
|
" Multi-line basic strings
|
|
|
|
syn region tomlString start=/"""/ end=/"""/ contains=tomlEscape,tomlLineEscape
|
|
|
|
" Literal strings
|
|
|
|
syn region tomlString oneline start=/'/ end=/'/
|
|
|
|
" Multi-line literal strings
|
|
|
|
syn region tomlString start=/'''/ end=/'''/
|
2014-04-14 19:16:56 -04:00
|
|
|
hi def link tomlString String
|
|
|
|
|
2018-10-08 13:00:59 -04:00
|
|
|
syn match tomlInteger /[+-]\=\<[1-9]\(_\=\d\)*\>/ display
|
|
|
|
syn match tomlInteger /[+-]\=\<0\>/ display
|
|
|
|
syn match tomlInteger /[+-]\=\<0x[[:xdigit:]]\(_\=[[:xdigit:]]\)*\>/ display
|
|
|
|
syn match tomlInteger /[+-]\=\<0o[0-7]\(_\=[0-7]\)*\>/ display
|
|
|
|
syn match tomlInteger /[+-]\=\<0b[01]\(_\=[01]\)*\>/ display
|
|
|
|
syn match tomlInteger /[+-]\=\<\(inf\|nan\)\>/ display
|
2014-04-14 19:16:56 -04:00
|
|
|
hi def link tomlInteger Number
|
|
|
|
|
2018-10-08 13:00:59 -04:00
|
|
|
syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\.\d\+\>/ display
|
|
|
|
syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\(\.\d\(_\=\d\)*\)\=[eE][+-]\=\d\(_\=\d\)*\>/ display
|
2014-04-14 19:16:56 -04:00
|
|
|
hi def link tomlFloat Float
|
|
|
|
|
|
|
|
syn match tomlBoolean /\<\%(true\|false\)\>/ display
|
|
|
|
hi def link tomlBoolean Boolean
|
|
|
|
|
2015-12-06 05:31:38 -05:00
|
|
|
" https://tools.ietf.org/html/rfc3339
|
2017-12-30 05:10:32 -05:00
|
|
|
syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}/ display
|
|
|
|
syn match tomlDate /\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?/ display
|
|
|
|
syn match tomlDate /\d\{4\}-\d\{2\}-\d\{2\}[T ]\d\{2\}:\d\{2\}:\d\{2\}\%(\.\d\+\)\?\%(Z\|[+-]\d\{2\}:\d\{2\}\)\?/ display
|
2014-04-14 19:16:56 -04:00
|
|
|
hi def link tomlDate Constant
|
|
|
|
|
2018-12-26 04:41:57 -05:00
|
|
|
syn match tomlKey /\v(^|[{,])\s*\zs[[:alnum:]._-]+\ze\s*\=/ display
|
2018-07-08 09:16:28 -04:00
|
|
|
hi def link tomlKey Identifier
|
|
|
|
|
|
|
|
syn region tomlKeyDq oneline start=/\v(^|[{,])\s*\zs"/ end=/"\ze\s*=/ contains=tomlEscape
|
2017-11-19 15:26:59 -05:00
|
|
|
hi def link tomlKeyDq Identifier
|
|
|
|
|
2018-07-08 09:16:28 -04:00
|
|
|
syn region tomlKeySq oneline start=/\v(^|[{,])\s*\zs'/ end=/'\ze\s*=/
|
2017-11-19 15:26:59 -05:00
|
|
|
hi def link tomlKeySq Identifier
|
|
|
|
|
2018-07-08 09:16:28 -04:00
|
|
|
syn region tomlTable oneline start=/^\s*\[[^\[]/ end=/\]/ contains=tomlKey,tomlKeyDq,tomlKeySq
|
2018-12-26 04:41:57 -05:00
|
|
|
hi def link tomlTable Title
|
2014-11-10 20:37:21 -05:00
|
|
|
|
2018-07-08 09:16:28 -04:00
|
|
|
syn region tomlTableArray oneline start=/^\s*\[\[/ end=/\]\]/ contains=tomlKey,tomlKeyDq,tomlKeySq
|
2018-12-26 04:41:57 -05:00
|
|
|
hi def link tomlTableArray Title
|
2014-04-14 19:16:56 -04:00
|
|
|
|
|
|
|
syn keyword tomlTodo TODO FIXME XXX BUG contained
|
|
|
|
hi def link tomlTodo Todo
|
|
|
|
|
|
|
|
syn match tomlComment /#.*/ contains=@Spell,tomlTodo
|
|
|
|
hi def link tomlComment Comment
|
|
|
|
|
2017-09-27 13:57:29 -04:00
|
|
|
syn sync minlines=500
|
|
|
|
|
2014-04-14 19:16:56 -04:00
|
|
|
let b:current_syntax = "toml"
|