3854
|
1 " Vim syntax file
|
|
2 " Language: dts/dtsi (device tree files)
|
|
3 " Maintainer: Daniel Mack <vim@zonque.org>
|
29193
|
4 " Last Change: 2022 Jun 14
|
3854
|
5
|
|
6 if exists("b:current_syntax")
|
|
7 finish
|
|
8 endif
|
29193
|
9 let b:current_syntax = 'dts'
|
3854
|
10
|
|
11 syntax region dtsComment start="/\*" end="\*/"
|
|
12 syntax match dtsReference "&[[:alpha:][:digit:]_]\+"
|
24636
|
13 syntax region dtsBinaryProperty start="\[" end="\]"
|
3854
|
14 syntax match dtsStringProperty "\".*\""
|
5425
|
15 syntax match dtsKeyword "/.\{-1,\}/"
|
3854
|
16 syntax match dtsLabel "^[[:space:]]*[[:alpha:][:digit:]_]\+:"
|
4264
|
17 syntax match dtsNode /[[:alpha:][:digit:]-_]\+\(@[0-9a-fA-F]\+\|\)[[:space:]]*{/he=e-1
|
3854
|
18 syntax region dtsCellProperty start="<" end=">" contains=dtsReference,dtsBinaryProperty,dtsStringProperty,dtsComment
|
|
19 syntax region dtsCommentInner start="/\*" end="\*/"
|
5425
|
20 syntax match dtsCommentLine "//.*$"
|
3854
|
21
|
24636
|
22 " Accept %: for # (C99)
|
|
23 syn region cPreCondit start="^\s*\zs\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError
|
|
24 syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>"
|
|
25 if !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
|
|
45 endif
|
|
46 syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
|
|
47 syn match cIncluded display contained "<[^>]*>"
|
|
48 syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
|
|
49 "syn match cLineSkip "\\$"
|
|
50 syn 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
|
|
51 syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
|
|
52 syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
|
|
53
|
3854
|
54 hi def link dtsCellProperty Number
|
|
55 hi def link dtsBinaryProperty Number
|
|
56 hi def link dtsStringProperty String
|
|
57 hi def link dtsKeyword Include
|
|
58 hi def link dtsLabel Label
|
4229
|
59 hi def link dtsNode Structure
|
3854
|
60 hi def link dtsReference Macro
|
|
61 hi def link dtsComment Comment
|
24636
|
62 hi def link dtsCommentInner Comment
|
5425
|
63 hi def link dtsCommentLine Comment
|
24636
|
64
|
|
65 hi def link cInclude Include
|
|
66 hi def link cPreProc PreProc
|
|
67 hi def link cDefine Macro
|
|
68 hi def link cIncluded cString
|
|
69 hi def link cString String
|
|
70
|
|
71 hi def link cCppInWrapper cCppOutWrapper
|
|
72 hi def link cCppOutWrapper cPreCondit
|
|
73 hi def link cPreConditMatch cPreCondit
|
|
74 hi def link cPreCondit PreCondit
|
|
75 hi def link cCppOutSkip cCppOutIf2
|
|
76
|
|
77 hi def link cCppInElse2 cCppOutIf2
|
|
78 hi def link cCppOutIf2 cCppOut
|
|
79 hi def link cCppOut Comment
|