robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqvim-patch:c6f6f16: runtime(toml): update syntax script and fix highlight of dates and escapes (#38239)ddccf882ff

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