blob: bb7eff7be1fc252ab3990e2104ae76b78603a78e [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 Moolenaarb7398fe2023-05-14 18:50:25 +01004" Last Change: 2023 Apr 28
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 Moolenaarb7398fe2023-05-14 18:50:25 +010013syntax match dtsReference "&{[[:alpha:][:digit:]@_/-]\+}"
Bram Moolenaar3ec32172021-05-16 12:39:47 +020014syntax region dtsBinaryProperty start="\[" end="\]"
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020015syntax match dtsStringProperty "\".*\""
Bram Moolenaarb7398fe2023-05-14 18:50:25 +010016syntax match dtsKeyword "/[[:alpha:][:digit:]-]\+/\([[:space:]]\|;\)"he=e-1
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020017syntax match dtsLabel "^[[:space:]]*[[:alpha:][:digit:]_]\+:"
Bram Moolenaarbf884932013-04-05 22:26:15 +020018syntax match dtsNode /[[:alpha:][:digit:]-_]\+\(@[0-9a-fA-F]\+\|\)[[:space:]]*{/he=e-1
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020019syntax region dtsCellProperty start="<" end=">" contains=dtsReference,dtsBinaryProperty,dtsStringProperty,dtsComment
20syntax region dtsCommentInner start="/\*" end="\*/"
Bram Moolenaard5d015d2013-11-03 21:14:31 +010021syntax match dtsCommentLine "//.*$"
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020022
Bram Moolenaar3ec32172021-05-16 12:39:47 +020023" Accept %: for # (C99)
24syn region cPreCondit start="^\s*\zs\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError
25syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>"
26if !exists("c_no_if0")
27 syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip
28 syn region cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold
29 syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse
30 if !exists("c_no_if0_fold")
31 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
32 else
33 syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
34 endif
35 syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit
36 syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold
37 syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit
38 if !exists("c_no_if0_fold")
39 syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold
40 else
41 syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2
42 endif
43 syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
44 syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip
45 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
46endif
47syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
48syn match cIncluded display contained "<[^>]*>"
49syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
50"syn match cLineSkip "\\$"
51syn 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
52syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
53syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
54
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020055hi def link dtsCellProperty Number
56hi def link dtsBinaryProperty Number
57hi def link dtsStringProperty String
58hi def link dtsKeyword Include
59hi def link dtsLabel Label
Bram Moolenaarac7bd632013-03-19 11:35:58 +010060hi def link dtsNode Structure
Bram Moolenaar0c5fa7d2012-10-05 22:26:30 +020061hi def link dtsReference Macro
62hi def link dtsComment Comment
Bram Moolenaar3ec32172021-05-16 12:39:47 +020063hi def link dtsCommentInner Comment
Bram Moolenaard5d015d2013-11-03 21:14:31 +010064hi def link dtsCommentLine Comment
Bram Moolenaar3ec32172021-05-16 12:39:47 +020065
66hi def link cInclude Include
67hi def link cPreProc PreProc
68hi def link cDefine Macro
69hi def link cIncluded cString
70hi def link cString String
71
72hi def link cCppInWrapper cCppOutWrapper
73hi def link cCppOutWrapper cPreCondit
74hi def link cPreConditMatch cPreCondit
75hi def link cPreCondit PreCondit
76hi def link cCppOutSkip cCppOutIf2
77
78hi def link cCppInElse2 cCppOutIf2
79hi def link cCppOutIf2 cCppOut
80hi def link cCppOut Comment