Bram Moolenaar | 9712ff1 | 2022-09-18 13:04:22 +0100 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: Valve Data Format |
| 3 | " Maintainer: ObserverOfTime <chronobserver@disroot.org> |
| 4 | " Filenames: *.vdf |
| 5 | " Last Change: 2022 Sep 15 |
| 6 | |
| 7 | if exists('b:current_syntax') |
| 8 | finish |
| 9 | endif |
| 10 | |
| 11 | let s:cpo_save = &cpoptions |
| 12 | set cpoptions&vim |
| 13 | |
| 14 | " Comment |
| 15 | syn keyword vdfTodo contained TODO FIXME XXX |
| 16 | syn match vdfComment +//.*+ contains=vdfTodo |
| 17 | |
| 18 | " Macro |
| 19 | syn match vdfMacro /^\s*#.*/ |
| 20 | |
| 21 | " Tag |
| 22 | syn region vdfTag start=/"/ skip=/\\"/ end=/"/ |
| 23 | \ nextgroup=vdfValue skipwhite oneline |
| 24 | |
| 25 | " Section |
| 26 | syn region vdfSection matchgroup=vdfBrace |
| 27 | \ start=/{/ end=/}/ transparent fold |
| 28 | \ contains=vdfTag,vdfSection,vdfComment,vdfConditional |
| 29 | |
| 30 | " Conditional |
| 31 | syn match vdfConditional /\[\$\w\{1,1021}\]/ nextgroup=vdfTag |
| 32 | |
| 33 | " Value |
| 34 | syn region vdfValue start=/"/ skip=/\\"/ end=/"/ |
| 35 | \ oneline contained contains=vdfVariable,vdfNumber,vdfEscape |
| 36 | syn region vdfVariable start=/%/ skip=/\\%/ end=/%/ oneline contained |
| 37 | syn match vdfEscape /\\[nt\\"]/ contained |
| 38 | syn match vdfNumber /"-\?\d\+"/ contained |
| 39 | |
| 40 | hi def link vdfBrace Delimiter |
| 41 | hi def link vdfComment Comment |
| 42 | hi def link vdfConditional Constant |
| 43 | hi def link vdfEscape SpecialChar |
| 44 | hi def link vdfMacro Macro |
| 45 | hi def link vdfNumber Number |
| 46 | hi def link vdfTag Keyword |
| 47 | hi def link vdfTodo Todo |
| 48 | hi def link vdfValue String |
| 49 | hi def link vdfVariable Identifier |
| 50 | |
| 51 | let b:current_syntax = 'vdf' |
| 52 | |
| 53 | let &cpoptions = s:cpo_save |
| 54 | unlet s:cpo_save |