debcontrol.vim (9513B)
1 " Vim syntax file 2 " Language: Debian control files 3 " Maintainer: Debian Vim Maintainers 4 " Former Maintainers: Gerfried Fuchs <alfie@ist.org> 5 " Wichert Akkerman <wakkerma@debian.org> 6 " Last Change: 2026 Jan 20 7 " URL: https://salsa.debian.org/vim-team/vim-debian/blob/main/syntax/debcontrol.vim 8 9 " Standard syntax initialization 10 if exists('b:current_syntax') 11 finish 12 endif 13 14 let s:cpo_save = &cpo 15 set cpo&vim 16 17 " Should match case except for the keys of each field 18 syn case match 19 20 syn iskeyword @,48-57,- 21 22 " Everything that is not explicitly matched by the rules below 23 syn match debcontrolElse "^.*$" 24 25 " Common separators 26 syn match debControlComma ",[ \t]*" 27 syn match debControlSpace "[ \t]" 28 29 runtime! syntax/shared/debarchitectures.vim 30 31 " Define some common expressions we can use later on 32 syn keyword debcontrolArchitecture contained all any 33 exe 'syn keyword debcontrolArchitecture contained '. join(g:debArchitectureKernelAnyArch) 34 exe 'syn keyword debcontrolArchitecture contained '. join(g:debArchitectureAnyKernelArch) 35 exe 'syn keyword debcontrolArchitecture contained '. join(g:debArchitectureArchs) 36 37 " Keep in sync with https://metadata.ftp-master.debian.org/sections.822 38 " curl -q https://metadata.ftp-master.debian.org/sections.822 2>/dev/null| grep-dctrl -n --not -FSection -sSection / - 39 let s:sections = [ 40 \ 'admin', 'cli-mono', 'comm', 'database', 'debian-installer', 'debug' 41 \, 'devel', 'doc', 'editors', 'education', 'electronics', 'embedded' 42 \, 'fonts', 'games', 'gnome', 'gnu-r', 'gnustep', 'golang', 'graphics' 43 \, 'hamradio', 'haskell', 'httpd', 'interpreters', 'introspection' 44 \, 'java', 'javascript', 'kde', 'kernel', 'libdevel', 'libs', 'lisp' 45 \, 'localization', 'mail', 'math', 'metapackages', 'misc', 'net', 'news' 46 \, 'ocaml', 'oldlibs', 'otherosfs', 'perl', 'php', 'python', 'raku' 47 \, 'ruby', 'rust', 'science', 'shells', 'sound', 'tasks', 'tex', 'text' 48 \, 'utils', 'vcs', 'video', 'web', 'x11', 'xfce', 'zope' 49 \ ] 50 51 syn keyword debcontrolMultiArch contained no foreign allowed same 52 syn match debcontrolName contained "[a-z0-9][a-z0-9+.-]\+" 53 syn keyword debcontrolPriority contained extra important optional required standard 54 exe 'syn match debcontrolSection contained "\%(\%(contrib\|non-free\|non-US/main\|non-US/contrib\|non-US/non-free\|restricted\|universe\|multiverse\)/\)\=\<\%('.join(s:sections, '\|').'\)\>"' 55 syn keyword debcontrolPackageType contained udeb deb 56 syn match debcontrolVariable contained "\${.\{-}}" 57 syn keyword debcontrolDmUpload contained yes 58 syn keyword debcontrolYesNo contained yes no 59 syn match debcontrolR3 contained "\<\%(no\|binary-targets\|[[:graph:]]\+/[[:graph:]]\+\%( \+[[:graph:]]\+/[[:graph:]]\+\)*\)\>" 60 61 unlet s:sections 62 63 " A URL (using the domain name definitions from RFC 1034 and 1738), right now 64 " only enforce protocol and some sanity on the server/path part; 65 syn match debcontrolHTTPUrl contained "\vhttps?://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?$" 66 syn match debcontrolVcsSvn contained "\vsvn%(\+ssh)?://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?$" 67 syn match debcontrolVcsCvs contained "\v%(\-d *)?:pserver:[^@]+\@[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?:/[^[:space:]]*%( [^[:space:]]+)?$" 68 syn match debcontrolVcsGit contained "\v%(git|https?)://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?%(\s+-b\s+[^ ~^:?*[\\]+)?$" 69 70 " An email address 71 syn match debcontrolEmail "[_=[:alnum:]\.+-]\+@[[:alnum:]\./\-]\+" 72 syn match debcontrolEmail "<.\{-}>" 73 74 " #-Comments 75 syn match debcontrolComment "^#.*$" contains=@Spell 76 77 " Build profiles 78 " Since there's no official spec for the field, use dpkg's parsing 79 " (from BuildProfiles.pm) as the de facto spec 80 syn match debcontrolBuildProfile "<\@<!<\s*!\=[-?/;:=@%*~A-Za-z0-9+.]\+\%(\s\+!\=[-?/;:=@%*~A-Za-z0-9+.]\+\)*\s*>" contained 81 82 " Architecture specification for a package relationship 83 let s:all_archs = join(g:debArchitectureKernelAnyArch, '\|') 84 \. '\|' 85 \. join(g:debArchitectureAnyKernelArch, '\|') 86 \. '\|' 87 \. join(g:debArchitectureArchs, '\|') 88 exe 'syn match debcontrolArchSpec "\[\s*!\=\%('. s:all_archs .'\)\%(\s\+!\=\%('. s:all_archs. '\)\)*\s*\]" contained' 89 unlet s:all_archs 90 91 syn case ignore 92 93 " Handle all fields from deb-src-control(5) 94 95 " Catch-all for the legal fields 96 syn region debcontrolField matchgroup=debcontrolKey start="^\%(XSBC-Original-\)\=Maintainer: " end="$" contains=debcontrolVariable,debcontrolEmail oneline 97 syn region debcontrolField matchgroup=debcontrolKey start="^Build-Profiles: " end="$" contains=debcontrolVariable,debcontrolBuildProfile oneline 98 syn region debcontrolField matchgroup=debcontrolKey start="^\%(Standards-Version\|Bugs\|Origin\|X[SB]-Python-Version\|\%(XS-\)\=Vcs-Mtn\|\%(XS-\)\=Testsuite\%(-Triggers\)\=\|Build-Driver\|Tag\|Subarchitecture\|Kernel-Version\|Installer-Menu-Item\): " end="$" contains=debcontrolVariable oneline 99 syn region debcontrolMultiField matchgroup=debcontrolKey start="^\%(Build-\%(Conflicts\|Depends\)\%(-Arch\|-Indep\)\=\|\%(Pre-\)\=Depends\|Recommends\|Suggests\|Breaks\|Enhances\|Replaces\|Conflicts\|Provides\|Built-Using\|Static-Built-Using\): *" skip="^[ \t]" end="^$"me=s-1 end="^[^ \t#]"me=s-1 contains=debcontrolVariable,debcontrolComment,debcontrolBuildProfile,debcontrolArchSpec 100 syn region debcontrolMultiField matchgroup=debcontrolKey start="^X[SBC]\{0,3\}\%(Private-\)\=-[-a-zA-Z0-9]\+: *" skip="^[ \t]" end="^$"me=s-1 end="^[^ \t#]"me=s-1 contains=debcontrolVariable,debcontrolComment 101 syn region debcontrolMultiField matchgroup=debcontrolKey start="^Uploaders: *" skip="^[ \t]" end="^$"me=s-1 end="^[^ \t#]"me=s-1 contains=debcontrolEmail,debcontrolVariable,debcontrolComment 102 syn region debcontrolMultiFieldSpell matchgroup=debcontrolKey start="^Description: *" skip="^[ \t]" end="^$"me=s-1 end="^[^ \t#]"me=s-1 contains=debcontrolVariable,debcontrolComment,@Spell 103 104 " Fields for which we do strict syntax checking 105 syn region debcontrolStrictField matchgroup=debcontrolKey start="^Architecture: *" end="$" contains=debcontrolArchitecture,debcontrolSpace oneline 106 syn region debcontrolStrictField matchgroup=debcontrolKey start="^Multi-Arch: *" end="$" contains=debcontrolMultiArch oneline 107 syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(Package\|Source\): *" end="$" contains=debcontrolName oneline 108 syn region debcontrolStrictField matchgroup=debcontrolKey start="^Priority: *" end="$" contains=debcontrolPriority oneline 109 syn region debcontrolStrictField matchgroup=debcontrolKey start="^Section: *" end="$" contains=debcontrolSection oneline 110 syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(XC-\)\=Package-Type: *" end="$" contains=debcontrolPackageType oneline 111 syn region debcontrolStrictField matchgroup=debcontrolKey start="^Homepage: *" end="$" contains=debcontrolHTTPUrl oneline keepend 112 syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(XS-[-a-zA-Z0-9]\+-\)\=Vcs-\%(Browser\|Arch\|Bzr\|Darcs\|Hg\): *" end="$" contains=debcontrolHTTPUrl oneline keepend 113 syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(XS-[-a-zA-Z0-9]\+-\)\=Vcs-Svn: *" end="$" contains=debcontrolVcsSvn,debcontrolHTTPUrl oneline keepend 114 syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(XS-[-a-zA-Z0-9]\+-\)\=Vcs-Cvs: *" end="$" contains=debcontrolVcsCvs oneline keepend 115 syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(XS-[-a-zA-Z0-9]\+-\)\=Vcs-Git: *" end="$" contains=debcontrolVcsGit oneline keepend 116 syn region debcontrolStrictField matchgroup=debcontrolKey start="^Rules-Requires-Root: *" end="$" contains=debcontrolR3 oneline 117 syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(\%(Build-\)\=Essential\|Protected\): *" end="$" contains=debcontrolYesNo oneline 118 119 syn region debcontrolStrictField matchgroup=debcontrolDeprecatedKey start="^\%(XS-\)\=DM-Upload-Allowed: *" end="$" contains=debcontrolDmUpload oneline 120 121 " Associate our matches and regions with pretty colours 122 hi def link debcontrolKey Keyword 123 hi def link debcontrolField Normal 124 hi def link debcontrolStrictField Error 125 hi def link debcontrolDeprecatedKey Error 126 hi def link debcontrolMultiField Normal 127 hi def link debcontrolArchitecture Normal 128 hi def link debcontrolMultiArch Normal 129 hi def link debcontrolName Normal 130 hi def link debcontrolPriority Normal 131 hi def link debcontrolSection Normal 132 hi def link debcontrolPackageType Normal 133 hi def link debcontrolVariable Identifier 134 hi def link debcontrolArchSpec Identifier 135 hi def link debcontrolBuildProfile Identifier 136 hi def link debcontrolEmail Identifier 137 hi def link debcontrolVcsSvn Identifier 138 hi def link debcontrolVcsCvs Identifier 139 hi def link debcontrolVcsGit Identifier 140 hi def link debcontrolHTTPUrl Identifier 141 hi def link debcontrolDmUpload Identifier 142 hi def link debcontrolYesNo Identifier 143 hi def link debcontrolR3 Identifier 144 hi def link debcontrolComment Comment 145 hi def link debcontrolElse Special 146 147 let b:current_syntax = 'debcontrol' 148 149 let &cpo = s:cpo_save 150 unlet s:cpo_save 151 152 " vim: ts=8 sw=2