codekingpro/portable-devtools
115k
1" Vim syntax file2" Language: Debian control files3" Maintainer: Debian Vim Maintainers4" Former Maintainers: Gerfried Fuchs <alfie@ist.org>5" Wichert Akkerman <wakkerma@debian.org>6" Last Change: 2026 Jan 207" URL: https://salsa.debian.org/vim-team/vim-debian/blob/main/syntax/debcontrol.vim8 9" Standard syntax initialization10if exists('b:current_syntax')11 finish12endif13 14let s:cpo_save = &cpo15set cpo&vim16 17" Should match case except for the keys of each field18syn case match19 20syn iskeyword @,48-57,-21 22" Everything that is not explicitly matched by the rules below23syn match debcontrolElse "^.*$"24 25" Common separators26syn match debControlComma ",[ \t]*"27syn match debControlSpace "[ \t]"28 29runtime! syntax/shared/debarchitectures.vim30 31" Define some common expressions we can use later on32syn keyword debcontrolArchitecture contained all any33exe 'syn keyword debcontrolArchitecture contained '. join(g:debArchitectureKernelAnyArch)34exe 'syn keyword debcontrolArchitecture contained '. join(g:debArchitectureAnyKernelArch)35exe 'syn keyword debcontrolArchitecture contained '. join(g:debArchitectureArchs)36 37" Keep in sync with https://metadata.ftp-master.debian.org/sections.82238" curl -q https://metadata.ftp-master.debian.org/sections.822 2>/dev/null| grep-dctrl -n --not -FSection -sSection / -39let 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 51syn keyword debcontrolMultiArch contained no foreign allowed same52syn match debcontrolName contained "[a-z0-9][a-z0-9+.-]\+"53syn keyword debcontrolPriority contained extra important optional required standard54exe 'syn match debcontrolSection contained "\%(\%(contrib\|non-free\|non-US/main\|non-US/contrib\|non-US/non-free\|restricted\|universe\|multiverse\)/\)\=\<\%('.join(s:sections, '\|').'\)\>"'55syn keyword debcontrolPackageType contained udeb deb56syn match debcontrolVariable contained "\${.\{-}}"57syn keyword debcontrolDmUpload contained yes58syn keyword debcontrolYesNo contained yes no59syn match debcontrolR3 contained "\<\%(no\|binary-targets\|[[:graph:]]\+/[[:graph:]]\+\%( \+[[:graph:]]\+/[[:graph:]]\+\)*\)\>"60 61unlet s:sections62 63" A URL (using the domain name definitions from RFC 1034 and 1738), right now64" only enforce protocol and some sanity on the server/path part;65syn match debcontrolHTTPUrl contained "\vhttps?://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?$"66syn match debcontrolVcsSvn contained "\vsvn%(\+ssh)?://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?$"67syn match debcontrolVcsCvs contained "\v%(\-d *)?:pserver:[^@]+\@[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?:/[^[:space:]]*%( [^[:space:]]+)?$"68syn match debcontrolVcsGit contained "\v%(git|https?)://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?%(\s+-b\s+[^ ~^:?*[\\]+)?$"69 70" An email address71syn match debcontrolEmail "[_=[:alnum:]\.+-]\+@[[:alnum:]\./\-]\+"72syn match debcontrolEmail "<.\{-}>"73 74" #-Comments75syn match debcontrolComment "^#.*$" contains=@Spell76 77" Build profiles78" Since there's no official spec for the field, use dpkg's parsing79" (from BuildProfiles.pm) as the de facto spec80syn match debcontrolBuildProfile "<\@<!<\s*!\=[-?/;:=@%*~A-Za-z0-9+.]\+\%(\s\+!\=[-?/;:=@%*~A-Za-z0-9+.]\+\)*\s*>" contained81 82" Architecture specification for a package relationship83let s:all_archs = join(g:debArchitectureKernelAnyArch, '\|')84 \. '\|'85 \. join(g:debArchitectureAnyKernelArch, '\|')86 \. '\|'87 \. join(g:debArchitectureArchs, '\|')88exe 'syn match debcontrolArchSpec "\[\s*!\=\%('. s:all_archs .'\)\%(\s\+!\=\%('. s:all_archs. '\)\)*\s*\]" contained'89unlet s:all_archs90 91syn case ignore92 93" Handle all fields from deb-src-control(5)94 95" Catch-all for the legal fields96syn region debcontrolField matchgroup=debcontrolKey start="^\%(XSBC-Original-\)\=Maintainer: " end="$" contains=debcontrolVariable,debcontrolEmail oneline97syn region debcontrolField matchgroup=debcontrolKey start="^Build-Profiles: " end="$" contains=debcontrolVariable,debcontrolBuildProfile oneline98syn 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 oneline99syn 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,debcontrolArchSpec100syn 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,debcontrolComment101syn region debcontrolMultiField matchgroup=debcontrolKey start="^Uploaders: *" skip="^[ \t]" end="^$"me=s-1 end="^[^ \t#]"me=s-1 contains=debcontrolEmail,debcontrolVariable,debcontrolComment102syn region debcontrolMultiFieldSpell matchgroup=debcontrolKey start="^Description: *" skip="^[ \t]" end="^$"me=s-1 end="^[^ \t#]"me=s-1 contains=debcontrolVariable,debcontrolComment,@Spell103 104" Fields for which we do strict syntax checking105syn region debcontrolStrictField matchgroup=debcontrolKey start="^Architecture: *" end="$" contains=debcontrolArchitecture,debcontrolSpace oneline106syn region debcontrolStrictField matchgroup=debcontrolKey start="^Multi-Arch: *" end="$" contains=debcontrolMultiArch oneline107syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(Package\|Source\): *" end="$" contains=debcontrolName oneline108syn region debcontrolStrictField matchgroup=debcontrolKey start="^Priority: *" end="$" contains=debcontrolPriority oneline109syn region debcontrolStrictField matchgroup=debcontrolKey start="^Section: *" end="$" contains=debcontrolSection oneline110syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(XC-\)\=Package-Type: *" end="$" contains=debcontrolPackageType oneline111syn region debcontrolStrictField matchgroup=debcontrolKey start="^Homepage: *" end="$" contains=debcontrolHTTPUrl oneline keepend112syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(XS-[-a-zA-Z0-9]\+-\)\=Vcs-\%(Browser\|Arch\|Bzr\|Darcs\|Hg\): *" end="$" contains=debcontrolHTTPUrl oneline keepend113syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(XS-[-a-zA-Z0-9]\+-\)\=Vcs-Svn: *" end="$" contains=debcontrolVcsSvn,debcontrolHTTPUrl oneline keepend114syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(XS-[-a-zA-Z0-9]\+-\)\=Vcs-Cvs: *" end="$" contains=debcontrolVcsCvs oneline keepend115syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(XS-[-a-zA-Z0-9]\+-\)\=Vcs-Git: *" end="$" contains=debcontrolVcsGit oneline keepend116syn region debcontrolStrictField matchgroup=debcontrolKey start="^Rules-Requires-Root: *" end="$" contains=debcontrolR3 oneline117syn region debcontrolStrictField matchgroup=debcontrolKey start="^\%(\%(Build-\)\=Essential\|Protected\): *" end="$" contains=debcontrolYesNo oneline118 119syn region debcontrolStrictField matchgroup=debcontrolDeprecatedKey start="^\%(XS-\)\=DM-Upload-Allowed: *" end="$" contains=debcontrolDmUpload oneline120 121" Associate our matches and regions with pretty colours122hi def link debcontrolKey Keyword123hi def link debcontrolField Normal124hi def link debcontrolStrictField Error125hi def link debcontrolDeprecatedKey Error126hi def link debcontrolMultiField Normal127hi def link debcontrolArchitecture Normal128hi def link debcontrolMultiArch Normal129hi def link debcontrolName Normal130hi def link debcontrolPriority Normal131hi def link debcontrolSection Normal132hi def link debcontrolPackageType Normal133hi def link debcontrolVariable Identifier134hi def link debcontrolArchSpec Identifier135hi def link debcontrolBuildProfile Identifier136hi def link debcontrolEmail Identifier137hi def link debcontrolVcsSvn Identifier138hi def link debcontrolVcsCvs Identifier139hi def link debcontrolVcsGit Identifier140hi def link debcontrolHTTPUrl Identifier141hi def link debcontrolDmUpload Identifier142hi def link debcontrolYesNo Identifier143hi def link debcontrolR3 Identifier144hi def link debcontrolComment Comment145hi def link debcontrolElse Special146 147let b:current_syntax = 'debcontrol'148 149let &cpo = s:cpo_save150unlet s:cpo_save151 152" vim: ts=8 sw=2153 