robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
c68e9d2a59
master
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 10if exists ( 'b:current_syntax' ) 11finish 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 20syn iskeyword @,48-57,- 21 22" Everything that is not explicitly matched by the rules below 23syn match debcontrolElse "^. * $ " 24 25" Common separators 26syn match debControlComma ", [ \t ] * " 27syn match debControlSpace "[ \t ] " 28 29runtime ! syntax/shared/debarchitectures.vim 30 31" Define some common expressions we can use later on 32syn keyword debcontrolArchitecture contained all any 33exe '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.822 38" 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 same 52syn match debcontrolName contained "[ a-z0-9 ][ a-z0-9+.- ] \+ " 53syn keyword debcontrolPriority contained extra important optional required standard 54exe '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 deb 56syn match debcontrolVariable contained "\${.\{-}} " 57syn keyword debcontrolDmUpload contained yes 58syn keyword debcontrolYesNo contained yes no 59syn match debcontrolR3 contained "\<\%(no\|binary-targets\| [ [:graph: ] ]\+/ [ [:graph: ] ]\+\%( \+ [ [:graph: ] ]\+/ [ [:graph: ] ]\+\) * \)\> " 60 61unlet 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; 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 address 71syn match debcontrolEmail "[ _=[:alnum: ] \.+-]\+@ [ [:alnum: ] \./\-]\+ " 72syn match debcontrolEmail "<.\{-}> " 73 74" #-Comments 75syn 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 80syn match debcontrolBuildProfile "<\@<!<\s * !\= [ -?/;:=@%*~A-Za-z0-9+. ] \+\%(\s\+!\= [ -?/;:=@%*~A-Za-z0-9+. ] \+\) * \s * > "contained 81 82" Architecture specification for a package relationship 83let 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_archs 90 91syn case ignore 92 93" Handle all fields from deb-src-control(5) 94 95" Catch-all for the legal fields 96syn region debcontrolField matchgroup = debcontrolKey start = "^\%(XSBC-Original-\)\=Maintainer: "end = "$ "contains = debcontrolVariable , debcontrolEmail oneline 97syn region debcontrolField matchgroup = debcontrolKey start = "^Build-Profiles: "end = "$ "contains = debcontrolVariable , debcontrolBuildProfile oneline 98syn 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 99syn 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-1end = "^ [ ^ \t# ] "me= s-1contains = debcontrolVariable , debcontrolComment , debcontrolBuildProfile , debcontrolArchSpec 100syn region debcontrolMultiField matchgroup = debcontrolKey start = "^X [ SBC ] \{0,3\}\%(Private-\)\=- [ -a-zA-Z0-9 ] \+: * "skip = "^ [ \t ] "end = "^$ "me= s-1end = "^ [ ^ \t# ] "me= s-1contains = debcontrolVariable , debcontrolComment 101syn region debcontrolMultiField matchgroup = debcontrolKey start = "^Uploaders: * "skip = "^ [ \t ] "end = "^$ "me= s-1end = "^ [ ^ \t# ] "me= s-1contains = debcontrolEmail , debcontrolVariable , debcontrolComment 102syn region debcontrolMultiFieldSpell matchgroup = debcontrolKey start = "^Description: * "skip = "^ [ \t ] "end = "^$ "me= s-1end = "^ [ ^ \t# ] "me= s-1contains = debcontrolVariable , debcontrolComment , @Spell 103 104" Fields for which we do strict syntax checking 105syn region debcontrolStrictField matchgroup = debcontrolKey start = "^Architecture: * "end = "$ "contains = debcontrolArchitecture , debcontrolSpace oneline 106syn region debcontrolStrictField matchgroup = debcontrolKey start = "^Multi-Arch: * "end = "$ "contains = debcontrolMultiArch oneline 107syn region debcontrolStrictField matchgroup = debcontrolKey start = "^\%(Package\|Source\): * "end = "$ "contains = debcontrolName oneline 108syn region debcontrolStrictField matchgroup = debcontrolKey start = "^Priority: * "end = "$ "contains = debcontrolPriority oneline 109syn region debcontrolStrictField matchgroup = debcontrolKey start = "^Section: * "end = "$ "contains = debcontrolSection oneline 110syn region debcontrolStrictField matchgroup = debcontrolKey start = "^\%(XC-\)\=Package-Type: * "end = "$ "contains = debcontrolPackageType oneline 111syn region debcontrolStrictField matchgroup = debcontrolKey start = "^Homepage: * "end = "$ "contains = debcontrolHTTPUrl oneline keepend 112syn region debcontrolStrictField matchgroup = debcontrolKey start = "^\%(XS- [ -a-zA-Z0-9 ] \+-\)\=Vcs-\%(Browser\|Arch\|Bzr\|Darcs\|Hg\): * "end = "$ "contains = debcontrolHTTPUrl oneline keepend 113syn region debcontrolStrictField matchgroup = debcontrolKey start = "^\%(XS- [ -a-zA-Z0-9 ] \+-\)\=Vcs-Svn: * "end = "$ "contains = debcontrolVcsSvn , debcontrolHTTPUrl oneline keepend 114syn region debcontrolStrictField matchgroup = debcontrolKey start = "^\%(XS- [ -a-zA-Z0-9 ] \+-\)\=Vcs-Cvs: * "end = "$ "contains = debcontrolVcsCvs oneline keepend 115syn region debcontrolStrictField matchgroup = debcontrolKey start = "^\%(XS- [ -a-zA-Z0-9 ] \+-\)\=Vcs-Git: * "end = "$ "contains = debcontrolVcsGit oneline keepend 116syn region debcontrolStrictField matchgroup = debcontrolKey start = "^Rules-Requires-Root: * "end = "$ "contains = debcontrolR3 oneline 117syn region debcontrolStrictField matchgroup = debcontrolKey start = "^\%(\%(Build-\)\=Essential\|Protected\): * "end = "$ "contains = debcontrolYesNo oneline 118 119syn region debcontrolStrictField matchgroup = debcontrolDeprecatedKey start = "^\%(XS-\)\=DM-Upload-Allowed: * "end = "$ "contains = debcontrolDmUpload oneline 120 121" Associate our matches and regions with pretty colours 122hi def link debcontrolKey Keyword 123hi def link debcontrolField Normal 124hi def link debcontrolStrictField Error 125hi def link debcontrolDeprecatedKey Error 126hi def link debcontrolMultiField Normal 127hi def link debcontrolArchitecture Normal 128hi def link debcontrolMultiArch Normal 129hi def link debcontrolName Normal 130hi def link debcontrolPriority Normal 131hi def link debcontrolSection Normal 132hi def link debcontrolPackageType Normal 133hi def link debcontrolVariable Identifier 134hi def link debcontrolArchSpec Identifier 135hi def link debcontrolBuildProfile Identifier 136hi def link debcontrolEmail Identifier 137hi def link debcontrolVcsSvn Identifier 138hi def link debcontrolVcsCvs Identifier 139hi def link debcontrolVcsGit Identifier 140hi def link debcontrolHTTPUrl Identifier 141hi def link debcontrolDmUpload Identifier 142hi def link debcontrolYesNo Identifier 143hi def link debcontrolR3 Identifier 144hi def link debcontrolComment Comment 145hi def link debcontrolElse Special 146 147let b: current_syntax = 'debcontrol' 148 149let & cpo = s: cpo_save 150unlet s: cpo_save 151 152" vim: ts=8 sw=2