neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

dts.vim (5273B)


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