robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
ab20681c52
master
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 9if exists ( "b:current_syntax" ) 10finish 11endif 12let b: current_syntax = "spajson" 13 14syn 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. 20syn iskeyword 32-126,^, ^",^#,^:,^,,^=,^],^},^\ 21 22syn match spajsonEscape "\\ [ "\\/bfnrt ] "contained 23syn match spajsonEscape "\\u [ 0-9A-Fa-f ] \{4} "contained 24 25syn match spajsonError ". " 26syn match spajsonBare "\k\+ " 27syn match spajsonComment "#. * $ "contains = @Spell 28syn region spajsonString start = /" /skip = /\\\\\|\\" /end = /" /contains = spajsonEscape 29syn match spajsonKeyDelimiter "[ := ] " 30syn region spajsonArray matchgroup = spajsonBracket start = "\[ "end = "] "contains = ALLBUT , spajsonKeyDelimiter fold 31syn region spajsonObject matchgroup = spajsonBrace start = "{ "end = "} "contains = ALL fold 32syn match spajsonFloat "\< [ +- ] \? [ 0-9 ] \+\(\. [ 0-9 ] * \)\?\( [ Ee ][ +- ] \? [ 0-9 ] \+\)\?\> " 33syn match spajsonFloat "\< [ +- ] \?\. [ 0-9 ] \+\( [ Ee ][ +- ] \? [ 0-9 ] \+\)\?\> " 34syn match spajsonInt "\< [ +- ] \?0 [ Xx ][ 0-9A-Fa-f ] \+\> " 35syn match spajsonInt "\< [ +- ] \? [ 1-9 ][ 0-9 ] * \> " 36syn match spajsonInt "\< [ +- ] \?0 [ 0-7 ] * \> " 37syn keyword spajsonBoolean true false 38syn keyword spajsonNull null 39syn match spajsonWhitespace "[ \x00\t \r\n, ] " 40 41hi def link spajsonBoolean Boolean 42hi def link spajsonBrace Delimiter 43hi def link spajsonBracket Delimiter 44hi def link spajsonComment Comment 45hi def link spajsonError Error 46hi def link spajsonEscape SpecialChar 47hi def link spajsonFloat Float 48hi def link spajsonInt Number 49hi def link spajsonNull Constant 50hi def link spajsonString String