blob: be51ab5b100019118e7e10193385e6ae5f075bcc [file] [log] [blame]
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +02001" Vim syntax file
2" Language: dts/dtsi (device tree files)
3" Maintainer: Daniel Mack <vim@zonque.org>
Bram Moolenaard592deb2022-06-17 15:42:40 +01004" Last Change: 2022 Jun 14
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +02005
6if exists("b:current_syntax")
7 finish
8endif
Bram Moolenaard592deb2022-06-17 15:42:40 +01009let b:current_syntax = 'dts'
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020010
11syntax region dtsComment start="/\*" end="\*/"
12syntax match dtsReference "&[[:alpha:][:digit:]_]\+"
Bram Moolenaar3ec32172021-05-16 12:39:47 +020013syntax region dtsBinaryProperty start="\[" end="\]"
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020014syntax match dtsStringProperty "\".*\""
Bram Moolenaard5d015d2013-11-03 21:14:31 +010015syntax match dtsKeyword "/.\{-1,\}/"
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020016syntax match dtsLabel "^[[:space:]]*[[:alpha:][:digit:]_]\+:"
Bram Moolenaarbf884932013-04-05 22:26:15 +020017syntax match dtsNode /[[:alpha:][:digit:]-_]\+\(@[0-9a-fA-F]\+\|\)[[:space:]]*{/he=e-1
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020018syntax region dtsCellProperty start="<" end=">" contains=dtsReference,dtsBinaryProperty,dtsStringProperty,dtsComment
19syntax region dtsCommentInner start="/\*" end="\*/"
Bram Moolenaard5d015d2013-11-03 21:14:31 +010020syntax match dtsCommentLine "//.*$"
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020021
Bram Moolenaar3ec32172021-05-16 12:39:47 +020022" Accept %: for # (C99)
23syn region cPreCondit start="^\s*\zs\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError
24syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>"
25if !exists("c_no_if0")
26 syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip
27 syn region cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold
28 syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse
29 if !exists("c_no_if0_fold")
30 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold
31 else
32 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
33 endif
34 syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit
35 syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold
36 syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit
37 if !exists("c_no_if0_fold")
38 syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold
39 else
40 syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2
41 endif
42 syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
43 syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip
44 syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc
45endif
46syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
47syn match cIncluded display contained "<[^>]*>"
48syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
49"syn match cLineSkip "\\$"
50syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti,cBadBlock
51syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
52syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
53
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020054hi def link dtsCellProperty Number
55hi def link dtsBinaryProperty Number
56hi def link dtsStringProperty String
57hi def link dtsKeyword Include
58hi def link dtsLabel Label
Bram Moolenaarac7bd632013-03-19 11:35:58 +010059hi def link dtsNode Structure
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020060hi def link dtsReference Macro
61hi def link dtsComment Comment
Bram Moolenaar3ec32172021-05-16 12:39:47 +020062hi def link dtsCommentInner Comment
Bram Moolenaard5d015d2013-11-03 21:14:31 +010063hi def link dtsCommentLine Comment
Bram Moolenaar3ec32172021-05-16 12:39:47 +020064
65hi def link cInclude Include
66hi def link cPreProc PreProc
67hi def link cDefine Macro
68hi def link cIncluded cString
69hi def link cString String
70
71hi def link cCppInWrapper cCppOutWrapper
72hi def link cCppOutWrapper cPreCondit
73hi def link cPreConditMatch cPreCondit
74hi def link cPreCondit PreCondit
75hi def link cCppOutSkip cCppOutIf2
76
77hi def link cCppInElse2 cCppOutIf2
78hi def link cCppOutIf2 cCppOut
79hi def link cCppOut Comment