spajson.vim (1892B)
1 " Vim syntax file 2 " Language: SPA JSON 3 " Maintainer: David Mandelberg <david@mandelberg.org> 4 " Last Change: 2025 Mar 22 5 " 6 " Based on parser code: 7 " https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/spa/include/spa/utils/json-core.h 8 9 if exists("b:current_syntax") 10 finish 11 endif 12 let b:current_syntax = "spajson" 13 14 syn sync minlines=500 15 16 " Treat the __BARE parser state as a keyword, to make it easier to match 17 " keywords and numbers only when they're not part of a larger __BARE section. 18 " E.g., v4l2 and pipewire-0 probably shouldn't highlight anything as 19 " spajsonInt. 20 syn iskeyword 32-126,^ ,^",^#,^:,^,,^=,^],^},^\ 21 22 syn match spajsonEscape "\\["\\/bfnrt]" contained 23 syn match spajsonEscape "\\u[0-9A-Fa-f]\{4}" contained 24 25 syn match spajsonError "." 26 syn match spajsonBare "\k\+" 27 syn match spajsonComment "#.*$" contains=@Spell 28 syn region spajsonString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=spajsonEscape 29 syn match spajsonKeyDelimiter "[:=]" 30 syn region spajsonArray matchgroup=spajsonBracket start="\[" end="]" contains=ALLBUT,spajsonKeyDelimiter fold 31 syn region spajsonObject matchgroup=spajsonBrace start="{" end="}" contains=ALL fold 32 syn match spajsonFloat "\<[+-]\?[0-9]\+\(\.[0-9]*\)\?\([Ee][+-]\?[0-9]\+\)\?\>" 33 syn match spajsonFloat "\<[+-]\?\.[0-9]\+\([Ee][+-]\?[0-9]\+\)\?\>" 34 syn match spajsonInt "\<[+-]\?0[Xx][0-9A-Fa-f]\+\>" 35 syn match spajsonInt "\<[+-]\?[1-9][0-9]*\>" 36 syn match spajsonInt "\<[+-]\?0[0-7]*\>" 37 syn keyword spajsonBoolean true false 38 syn keyword spajsonNull null 39 syn match spajsonWhitespace "[\x00\t \r\n,]" 40 41 hi def link spajsonBoolean Boolean 42 hi def link spajsonBrace Delimiter 43 hi def link spajsonBracket Delimiter 44 hi def link spajsonComment Comment 45 hi def link spajsonError Error 46 hi def link spajsonEscape SpecialChar 47 hi def link spajsonFloat Float 48 hi def link spajsonInt Number 49 hi def link spajsonNull Constant 50 hi def link spajsonString String