1" Vim syntax file 2" Language: Debian control files 3" Maintainer: Debian Vim Maintainers <[email protected]> 4" Former Maintainers: Gerfried Fuchs <[email protected]> 5" Wichert Akkerman <[email protected]> 6" Last Change: 2016 Aug 30 7" URL: https://anonscm.debian.org/cgit/pkg-vim/vim.git/plain/runtime/syntax/debcontrol.vim 8 9" Standard syntax initialization 10if exists("b:current_syntax") 11 finish 12endif 13 14let s:cpo_save = &cpo 15set cpo&vim 16 17" Should match case except for the keys of each field 18syn case match 19 20" Everything that is not explicitly matched by the rules below 21syn match debcontrolElse "^.*$" 22 23" Common seperators 24syn match debControlComma ", *" 25syn match debControlSpace " " 26 27let s:kernels = '\%(linux\|hurd\|kfreebsd\|knetbsd\|kopensolaris\|netbsd\)' 28let s:archs = '\%(alpha\|amd64\|armeb\|armel\|armhf\|arm64\|avr32\|hppa\|i386' 29 \ . '\|ia64\|lpia\|m32r\|m68k\|mipsel\|mips64el\|mips\|powerpcspe\|powerpc\|ppc64el' 30 \ . '\|ppc64\|s390x\|s390\|sh3eb\|sh3\|sh4eb\|sh4\|sh\|sparc64\|sparc\|x32\)' 31let s:pairs = 'hurd-i386\|kfreebsd-i386\|kfreebsd-amd64\|knetbsd-i386\|kopensolaris-i386\|netbsd-alpha\|netbsd-i386' 32 33" Define some common expressions we can use later on 34exe 'syn match debcontrolArchitecture contained "\%(all\|'. s:kernels .'-any\|\%(any-\)\='. s:archs .'\|'. s:pairs .'\|any\)"' 35 36unlet s:kernels s:archs s:pairs 37 38syn match debcontrolMultiArch contained "\%(no\|foreign\|allowed\|same\)" 39syn match debcontrolName contained "[a-z0-9][a-z0-9+.-]\+" 40syn match debcontrolPriority contained "\(extra\|important\|optional\|required\|standard\)" 41syn match debcontrolSection contained "\v((contrib|non-free|non-US/main|non-US/contrib|non-US/non-free|restricted|universe|multiverse)/)?(admin|cli-mono|comm|database|debian-installer|debug|devel|doc|editors|education|electronics|embedded|fonts|games|gnome|gnustep|gnu-r|graphics|hamradio|haskell|httpd|interpreters|introspection|java|kde|kernel|libs|libdevel|lisp|localization|mail|math|metapackages|misc|net|news|ocaml|oldlibs|otherosfs|perl|php|python|ruby|science|shells|sound|text|tex|utils|vcs|video|web|x11|xfce|zope)" 42syn match debcontrolPackageType contained "u\?deb" 43syn match debcontrolVariable contained "\${.\{-}}" 44syn match debcontrolDmUpload contained "\cyes" 45 46" A URL (using the domain name definitions from RFC 1034 and 1738), right now 47" only enforce protocol and some sanity on the server/path part; 48syn match debcontrolHTTPUrl contained "\vhttps?://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?$" 49syn match debcontrolVcsSvn contained "\vsvn%(\+ssh)?://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?$" 50syn match debcontrolVcsCvs contained "\v%(\-d *)?:pserver:[^@]+\@[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?:/[^[:space:]]*%( [^[:space:]]+)?$" 51syn match debcontrolVcsGit contained "\v%(git|https?)://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?%(\s+-b\s+[^ ~^:?*[\\]+)?$" 52 53" An email address 54syn match debcontrolEmail "[_=[:alnum:]\.+-]\+@[[:alnum:]\./\-]\+" 55syn match debcontrolEmail "<.\{-}>" 56 57" #-Comments 58syn match debcontrolComment "^#.*$" contains=@Spell 59 60syn case ignore 61 62" List of all legal keys 63syn match debcontrolKey contained "^\%(Source\|Package\|Section\|Priority\|\%(XSBC-Original-\)\=Maintainer\|Uploaders\|Build-\%(Conflicts\|Depends\)\%(-Indep\)\=\|Standards-Version\|\%(Pre-\)\=Depends\|Recommends\|Suggests\|Provides\|Replaces\|Conflicts\|Enhances\|Breaks\|Essential\|Architecture\|Multi-Arch\|Description\|Bugs\|Origin\|X[SB]-Python-Version\|Homepage\|\(XS-\)\=Vcs-\(Browser\|Arch\|Bzr\|Cvs\|Darcs\|Git\|Hg\|Mtn\|Svn\)\|\%(XC-\)\=Package-Type\): *" 64 65syn match debcontrolDeprecatedKey contained "^\%(\%(XS-\)\=DM-Upload-Allowed\): *" 66 67" Fields for which we do strict syntax checking 68syn region debcontrolStrictField start="^Architecture" end="$" contains=debcontrolKey,debcontrolArchitecture,debcontrolSpace oneline 69syn region debcontrolStrictField start="^Multi-Arch" end="$" contains=debcontrolKey,debcontrolMultiArch oneline 70syn region debcontrolStrictField start="^\(Package\|Source\)" end="$" contains=debcontrolKey,debcontrolName oneline 71syn region debcontrolStrictField start="^Priority" end="$" contains=debcontrolKey,debcontrolPriority oneline 72syn region debcontrolStrictField start="^Section" end="$" contains=debcontrolKey,debcontrolSection oneline 73syn region debcontrolStrictField start="^\%(XC-\)\=Package-Type" end="$" contains=debcontrolKey,debcontrolPackageType oneline 74syn region debcontrolStrictField start="^Homepage" end="$" contains=debcontrolKey,debcontrolHTTPUrl oneline keepend 75syn region debcontrolStrictField start="^\%(XS-\)\=Vcs-\%(Browser\|Arch\|Bzr\|Darcs\|Hg\)" end="$" contains=debcontrolKey,debcontrolHTTPUrl oneline keepend 76syn region debcontrolStrictField start="^\%(XS-\)\=Vcs-Svn" end="$" contains=debcontrolKey,debcontrolVcsSvn,debcontrolHTTPUrl oneline keepend 77syn region debcontrolStrictField start="^\%(XS-\)\=Vcs-Cvs" end="$" contains=debcontrolKey,debcontrolVcsCvs oneline keepend 78syn region debcontrolStrictField start="^\%(XS-\)\=Vcs-Git" end="$" contains=debcontrolKey,debcontrolVcsGit oneline keepend 79syn region debcontrolStrictField start="^\%(XS-\)\=DM-Upload-Allowed" end="$" contains=debcontrolDeprecatedKey,debcontrolDmUpload oneline 80 81" Catch-all for the other legal fields 82syn region debcontrolField start="^\%(\%(XSBC-Original-\)\=Maintainer\|Standards-Version\|Essential\|Bugs\|Origin\|X[SB]-Python-Version\|\%(XS-\)\=Vcs-Mtn\):" end="$" contains=debcontrolKey,debcontrolVariable,debcontrolEmail oneline 83syn region debcontrolMultiField start="^\%(Build-\%(Conflicts\|Depends\)\%(-Indep\)\=\|\%(Pre-\)\=Depends\|Recommends\|Suggests\|Provides\|Replaces\|Conflicts\|Enhances\|Breaks\|Uploaders\|Description\):" skip="^ " end="^$"me=s-1 end="^[^ #]"me=s-1 contains=debcontrolKey,debcontrolEmail,debcontrolVariable,debcontrolComment 84syn region debcontrolMultiFieldSpell start="^\%(Description\):" skip="^ " end="^$"me=s-1 end="^[^ #]"me=s-1 contains=debcontrolKey,debcontrolEmail,debcontrolVariable,debcontrolComment,@Spell 85 86" Associate our matches and regions with pretty colours 87hi def link debcontrolKey Keyword 88hi def link debcontrolField Normal 89hi def link debcontrolStrictField Error 90hi def link debcontrolDeprecatedKey Error 91hi def link debcontrolMultiField Normal 92hi def link debcontrolArchitecture Normal 93hi def link debcontrolMultiArch Normal 94hi def link debcontrolName Normal 95hi def link debcontrolPriority Normal 96hi def link debcontrolSection Normal 97hi def link debcontrolPackageType Normal 98hi def link debcontrolVariable Identifier 99hi def link debcontrolEmail Identifier 100hi def link debcontrolVcsSvn Identifier 101hi def link debcontrolVcsCvs Identifier 102hi def link debcontrolVcsGit Identifier 103hi def link debcontrolHTTPUrl Identifier 104hi def link debcontrolDmUpload Identifier 105hi def link debcontrolComment Comment 106hi def link debcontrolElse Special 107 108let b:current_syntax = "debcontrol" 109 110let &cpo = s:cpo_save 111unlet s:cpo_save 112 113" vim: ts=8 sw=2 114