summaryrefslogtreecommitdiffstats
path: root/syntax/toml.vim
diff options
context:
space:
mode:
Diffstat (limited to 'syntax/toml.vim')
-rw-r--r--syntax/toml.vim55
1 files changed, 30 insertions, 25 deletions
diff --git a/syntax/toml.vim b/syntax/toml.vim
index 9540d2c5..98ac4698 100644
--- a/syntax/toml.vim
+++ b/syntax/toml.vim
@@ -2,10 +2,12 @@ if polyglot#init#is_disabled(expand('<sfile>:p'), 'toml', 'syntax/toml.vim')
finish
endif
-" Language: TOML
-" Maintainer: Caleb Spare <cespare@gmail.com>
-" URL: https://github.com/cespare/vim-toml
-" LICENSE: MIT
+" Vim syntax file
+" Language: TOML
+" Homepage: https://github.com/cespare/vim-toml
+" Maintainer: Aman Verma
+" Previous Maintainer: Caleb Spare <cespare@gmail.com>
+" Last Change: Oct 8, 2021
if exists('b:current_syntax')
finish
@@ -14,10 +16,7 @@ endif
syn match tomlEscape /\\[btnfr"/\\]/ display contained
syn match tomlEscape /\\u\x\{4}/ contained
syn match tomlEscape /\\U\x\{8}/ contained
-hi def link tomlEscape SpecialChar
-
syn match tomlLineEscape /\\$/ contained
-hi def link tomlLineEscape SpecialChar
" Basic strings
syn region tomlString oneline start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=tomlEscape
@@ -27,7 +26,6 @@ syn region tomlString start=/"""/ end=/"""/ contains=tomlEscape,tomlLineEscape
syn region tomlString oneline start=/'/ end=/'/
" Multi-line literal strings
syn region tomlString start=/'''/ end=/'''/
-hi def link tomlString String
syn match tomlInteger /[+-]\=\<[1-9]\(_\=\d\)*\>/ display
syn match tomlInteger /[+-]\=\<0\>/ display
@@ -35,46 +33,53 @@ 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
-hi def link tomlInteger Number
syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\.\d\+\>/ display
syn match tomlFloat /[+-]\=\<\d\(_\=\d\)*\(\.\d\(_\=\d\)*\)\=[eE][+-]\=\d\(_\=\d\)*\>/ display
-hi def link tomlFloat Float
syn match tomlBoolean /\<\%(true\|false\)\>/ display
-hi def link tomlBoolean Boolean
" https://tools.ietf.org/html/rfc3339
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
-hi def link tomlDate Constant
-
-syn match tomlKey /\v(^|[{,])\s*\zs[[:alnum:]._-]+\ze\s*\=/ display
-hi def link tomlKey Identifier
+syn match tomlDotInKey /\v[^.]+\zs\./ contained display
+syn match tomlKey /\v(^|[{,])\s*\zs[[:alnum:]._-]+\ze\s*\=/ contains=tomlDotInKey display
syn region tomlKeyDq oneline start=/\v(^|[{,])\s*\zs"/ end=/"\ze\s*=/ contains=tomlEscape
-hi def link tomlKeyDq Identifier
-
syn region tomlKeySq oneline start=/\v(^|[{,])\s*\zs'/ end=/'\ze\s*=/
-hi def link tomlKeySq Identifier
-syn region tomlTable oneline start=/^\s*\[[^\[]/ end=/\]/ contains=tomlKey,tomlKeyDq,tomlKeySq
-hi def link tomlTable Title
+syn region tomlTable oneline start=/^\s*\[[^\[]/ end=/\]/ contains=tomlKey,tomlKeyDq,tomlKeySq,tomlDotInKey
-syn region tomlTableArray oneline start=/^\s*\[\[/ end=/\]\]/ contains=tomlKey,tomlKeyDq,tomlKeySq
-hi def link tomlTableArray Title
+syn region tomlTableArray oneline start=/^\s*\[\[/ end=/\]\]/ contains=tomlKey,tomlKeyDq,tomlKeySq,tomlDotInKey
-syn cluster tomlValue contains=tomlArray,tomlString,tomlInteger,tomlFloat,tomlBoolean,tomlDate,tomlComment
syn region tomlKeyValueArray start=/=\s*\[\zs/ end=/\]/ contains=@tomlValue
+
syn region tomlArray start=/\[/ end=/\]/ contains=@tomlValue contained
+syn cluster tomlValue contains=tomlArray,tomlString,tomlInteger,tomlFloat,tomlBoolean,tomlDate,tomlComment
+
syn keyword tomlTodo TODO FIXME XXX BUG contained
-hi def link tomlTodo Todo
syn match tomlComment /#.*/ contains=@Spell,tomlTodo
+
hi def link tomlComment Comment
+hi def link tomlTodo Todo
+hi def link tomlTableArray Title
+hi def link tomlTable Title
+hi def link tomlDotInKey Normal
+hi def link tomlKeySq Identifier
+hi def link tomlKeyDq Identifier
+hi def link tomlKey Identifier
+hi def link tomlDate Constant
+hi def link tomlBoolean Boolean
+hi def link tomlFloat Float
+hi def link tomlInteger Number
+hi def link tomlString String
+hi def link tomlLineEscape SpecialChar
+hi def link tomlEscape SpecialChar
syn sync minlines=500
-
let b:current_syntax = 'toml'
+
+" vim: et sw=2 sts=2