2004-06-13 20:20:40 +00:00
" Vim syntax file
2010-05-14 23:24:24 +02:00
" Language: Debian control files
2006-05-02 22:08:30 +00:00
" Maintainer: Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org>
" Former Maintainers: Gerfried Fuchs <alfie@ist.org>
" Wichert Akkerman <wakkerma@debian.org>
2017-11-11 20:58:53 +01:00
" Last Change: 2017 Nov 04
2015-12-29 19:10:25 +01:00
" URL: https://anonscm.debian.org/cgit/pkg-vim/vim.git/plain/runtime/syntax/debcontrol.vim
2004-06-13 20:20:40 +00:00
" Standard syntax initialization
2016-08-30 23:26:57 +02:00
if exists ( "b:current_syntax" )
2004-06-13 20:20:40 +00:00
finish
endif
2014-07-19 14:04:47 +02:00
let s :cpo_save = &cpo
set cpo &vim
2008-06-24 22:58:06 +00:00
" Should match case except for the keys of each field
syn case match
2017-11-11 20:58:53 +01:00
syn iskeyword @, 48 -57 , - , /
2004-06-13 20:20:40 +00:00
" Everything that is not explicitly matched by the rules below
syn match debcontrolElse "^.*$"
" Common seperators
2017-08-27 16:52:01 +02:00
syn match debControlComma ",[ \t]*"
syn match debControlSpace "[ \t]"
2004-06-13 20:20:40 +00:00
2017-11-11 20:58:53 +01:00
let s :kernels = ['linux' , 'hurd' , 'kfreebsd' , 'knetbsd' , 'kopensolaris' , 'netbsd' ]
let s :archs = [
\ 'alpha' , 'amd64' , 'armeb' , 'armel' , 'armhf' , 'arm64' , 'avr32' , 'hppa'
\, 'i386' , 'ia64' , 'lpia' , 'm32r' , 'm68k' , 'mipsel' , 'mips64el' , 'mips'
\, 'powerpcspe' , 'powerpc' , 'ppc64el' , 'ppc64' , 's390x' , 's390' , 'sh3eb'
\, 'sh3' , 'sh4eb' , 'sh4' , 'sh' , 'sparc64' , 'sparc' , 'x32'
\ ]
let s :pairs = [
\ 'hurd-i386' , 'kfreebsd-i386' , 'kfreebsd-amd64' , 'knetbsd-i386'
\, 'kopensolaris-i386' , 'netbsd-alpha' , 'netbsd-i386'
\ ]
2014-07-19 14:04:47 +02:00
2004-06-13 20:20:40 +00:00
" Define some common expressions we can use later on
2017-11-11 20:58:53 +01:00
syn keyword debcontrolArchitecture contained all any
exe 'syn keyword debcontrolArchitecture contained ' . join ( map ( s :kernels , {k , v - > v .'-any' }) )
exe 'syn keyword debcontrolArchitecture contained ' . join ( map ( s :archs , {k , v - > 'any-' .v }) )
exe 'syn keyword debcontrolArchitecture contained ' . join ( s :archs )
exe 'syn keyword debcontrolArchitecture contained ' . join ( s :pairs )
2014-07-19 14:04:47 +02:00
unlet s :kernels s :archs s :pairs
2017-11-11 20:58:53 +01:00
let s :sections = [
\ 'admin' , 'cli-mono' , 'comm' , 'database' , 'debian-installer' , 'debug'
\, 'devel' , 'doc' , 'editors' , 'education' , 'electronics' , 'embedded'
\, 'fonts' , 'games' , 'gnome' , 'gnustep' , 'gnu-r' , 'golang' , 'graphics'
\, 'hamradio' , 'haskell' , 'httpd' , 'interpreters' , 'introspection'
\, 'java' , 'javascript' , 'kde' , 'kernel' , 'libs' , 'libdevel' , 'lisp'
\, 'localization' , 'mail' , 'math' , 'metapackages' , 'misc' , 'net'
\, 'news' , 'ocaml' , 'oldlibs' , 'otherosfs' , 'perl' , 'php' , 'python'
\, 'ruby' , 'rust' , 'science' , 'shells' , 'sound' , 'text' , 'tex'
\, 'utils' , 'vcs' , 'video' , 'web' , 'x11' , 'xfce' , 'zope'
\ ]
syn keyword debcontrolMultiArch contained no foreign allowed same
2008-06-24 22:58:06 +00:00
syn match debcontrolName contained "[a-z0-9][a-z0-9+.-]\+"
2017-11-11 20:58:53 +01:00
syn keyword debcontrolPriority contained extra important optional required standard
exe 'syn match debcontrolSection contained "\%(\%(contrib\|non-free\|non-US/main\|non-US/contrib\|non-US/non-free\|restricted\|universe\|multiverse\)/\)\=\%(' .join ( s :sections , '\|' ) .'\)"'
syn keyword debcontrolPackageType contained udeb deb
2004-06-13 20:20:40 +00:00
syn match debcontrolVariable contained "\${.\{-}}"
2017-11-11 20:58:53 +01:00
syn keyword debcontrolDmUpload contained yes
syn keyword debcontrolYesNo contained yes no
syn match debcontrolR3 contained "\<\%(no\|binary-targets\|[[:graph:]]\+/[[:graph:]]\+\%( \+[[:graph:]]\+/[[:graph:]]\+\)*\)\>"
unlet s :sections
2004-06-13 20:20:40 +00:00
2008-06-24 22:58:06 +00:00
" A URL (using the domain name definitions from RFC 1034 and 1738), right now
" only enforce protocol and some sanity on the server/path part;
syn match debcontrolHTTPUrl contained "\vhttps?://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?$"
syn match debcontrolVcsSvn contained "\vsvn%(\+ssh)?://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?$"
syn match debcontrolVcsCvs contained "\v%(\-d *)?:pserver:[^@]+\@[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?:/[^[:space:]]*%( [^[:space:]]+)?$"
2015-06-09 19:44:55 +02:00
syn match debcontrolVcsGit contained "\v%(git|https?)://[[:alnum:]][-[:alnum:]]*[[:alnum:]]?(\.[[:alnum:]][-[:alnum:]]*[[:alnum:]]?)*\.[[:alpha:]][-[:alnum:]]*[[:alpha:]]?(:\d+)?(/[^[:space:]]*)?%(\s+-b\s+[^ ~^:?*[\\]+)?$"
2008-06-24 22:58:06 +00:00
2004-06-13 20:20:40 +00:00
" An email address
syn match debcontrolEmail "[_=[:alnum:]\.+-]\+@[[:alnum:]\./\-]\+"
syn match debcontrolEmail "<.\{-}>"
2008-06-24 22:58:06 +00:00
" #-Comments
2012-10-21 03:02:54 +02:00
syn match debcontrolComment "^#.*$" contains = @Spell
2008-06-24 22:58:06 +00:00
syn case ignore
2017-11-11 20:58:53 +01:00
" List of all legal keys, in order, from deb-src-control(5)
" Source fields
syn match debcontrolKey contained "^\%(Source\|Maintainer\|Uploaders\|Standards-Version\|Description\|Homepage\|Bugs\|Rules-Requires-Root\): *"
syn match debcontrolKey contained "^\%(XS-\)\=Vcs-\%(Arch\|Bzr\|Cvs\|Darcs\|Git\|Hg\|Mtn\|Svn\|Browser\): *"
syn match debcontrolKey contained "^\%(Origin\|Section\|Priority\): *"
syn match debcontrolKey contained "^Build-\%(Depends\|Conflicts\)\%(-Arch\|-Indep\)\=: *"
" Binary fields
syn match debcontrolKey contained "^\%(Package\%(-Type\)\=\|Architecture\|Build-Profiles\): *"
syn match debcontrolKey contained "^\%(\%(Build-\)\=Essential\|Multi-Arch\|Tag\): *"
syn match debcontrolKey contained "^\%(\%(Pre-\)\=Depends\|Recommends\|Suggests\|Breaks\|Enhances\|Replaces\|Conflicts\|Provides\|Built-Using\): *"
syn match debcontrolKey contained "^\%(Subarchitecture\|Kernel-Version\|Installer-Menu-Item\): *"
" User-defined fields
syn match debcontrolKey contained "^X[SBC]\{0,3\}\%(-Private\)\=-[-a-zA-Z0-9]\+: *"
2013-03-19 11:35:58 +01:00
syn match debcontrolDeprecatedKey contained "^\%(\%(XS-\)\=DM-Upload-Allowed\): *"
2004-06-13 20:20:40 +00:00
" Fields for which we do strict syntax checking
syn region debcontrolStrictField start = "^Architecture" end = "$" contains = debcontrolKey , debcontrolArchitecture , debcontrolSpace oneline
2011-06-19 05:09:16 +02:00
syn region debcontrolStrictField start = "^Multi-Arch" end = "$" contains = debcontrolKey , debcontrolMultiArch oneline
2017-11-11 20:58:53 +01:00
syn region debcontrolStrictField start = "^\%(Package\|Source\)" end = "$" contains = debcontrolKey , debcontrolName oneline
2004-06-13 20:20:40 +00:00
syn region debcontrolStrictField start = "^Priority" end = "$" contains = debcontrolKey , debcontrolPriority oneline
syn region debcontrolStrictField start = "^Section" end = "$" contains = debcontrolKey , debcontrolSection oneline
2011-06-19 05:09:16 +02:00
syn region debcontrolStrictField start = "^\%(XC-\)\=Package-Type" end = "$" contains = debcontrolKey , debcontrolPackageType oneline
2008-06-24 22:58:06 +00:00
syn region debcontrolStrictField start = "^Homepage" end = "$" contains = debcontrolKey , debcontrolHTTPUrl oneline keepend
2010-01-06 20:54:52 +01:00
syn region debcontrolStrictField start = "^\%(XS-\)\=Vcs-\%(Browser\|Arch\|Bzr\|Darcs\|Hg\)" end = "$" contains = debcontrolKey , debcontrolHTTPUrl oneline keepend
syn region debcontrolStrictField start = "^\%(XS-\)\=Vcs-Svn" end = "$" contains = debcontrolKey , debcontrolVcsSvn , debcontrolHTTPUrl oneline keepend
syn region debcontrolStrictField start = "^\%(XS-\)\=Vcs-Cvs" end = "$" contains = debcontrolKey , debcontrolVcsCvs oneline keepend
syn region debcontrolStrictField start = "^\%(XS-\)\=Vcs-Git" end = "$" contains = debcontrolKey , debcontrolVcsGit oneline keepend
2013-03-19 11:35:58 +01:00
syn region debcontrolStrictField start = "^\%(XS-\)\=DM-Upload-Allowed" end = "$" contains = debcontrolDeprecatedKey , debcontrolDmUpload oneline
2017-11-11 20:58:53 +01:00
syn region debcontrolStrictField start = "^Rules-Requires-Root" end = "$" contains = debcontrolKey , debcontrolR3 oneline
syn region debcontrolStrictField start = "^\%(Build-\)\=Essential" end = "$" contains = debcontrolKey , debcontrolYesNo oneline
2004-06-13 20:20:40 +00:00
" Catch-all for the other legal fields
2017-11-11 20:58:53 +01:00
syn region debcontrolField start = "^\%(\%(XSBC-Original-\)\=Maintainer\|Standards-Version\|Bugs\|Origin\|X[SB]-Python-Version\|\%(XS-\)\=Vcs-Mtn\|\%(XS-\)\=Testsuite\|Build-Profiles\|Tag\|Subarchitecture\|Kernel-Version\|Installer-Menu-Item\):" end = "$" contains = debcontrolKey , debcontrolVariable , debcontrolEmail oneline
syn region debcontrolMultiField start = "^\%(Build-\%(Conflicts\|Depends\)\%(-Arch\|-Indep\)\=\|\%(Pre-\)\=Depends\|Recommends\|Suggests\|Breaks\|Enhances\|Replaces\|Conflicts\|Provides\|Built-Using\|Uploaders\|X[SBC]\{0,3\}\%(Private-\)\=-[-a-zA-Z0-9]\+\):" skip = "^[ \t]" end = "^$" me = s -1 end = "^[^ \t#]" me = s -1 contains = debcontrolKey , debcontrolEmail , debcontrolVariable , debcontrolComment
2017-08-27 16:52:01 +02:00
syn region debcontrolMultiFieldSpell start = "^\%(Description\):" skip = "^[ \t]" end = "^$" me = s -1 end = "^[^ \t#]" me = s -1 contains = debcontrolKey , debcontrolEmail , debcontrolVariable , debcontrolComment , @Spell
2004-06-13 20:20:40 +00:00
" Associate our matches and regions with pretty colours
2016-08-31 22:22:10 +02:00
hi def link debcontrolKey Keyword
hi def link debcontrolField Normal
hi def link debcontrolStrictField Error
hi def link debcontrolDeprecatedKey Error
hi def link debcontrolMultiField Normal
hi def link debcontrolArchitecture Normal
hi def link debcontrolMultiArch Normal
hi def link debcontrolName Normal
hi def link debcontrolPriority Normal
hi def link debcontrolSection Normal
hi def link debcontrolPackageType Normal
hi def link debcontrolVariable Identifier
hi def link debcontrolEmail Identifier
hi def link debcontrolVcsSvn Identifier
hi def link debcontrolVcsCvs Identifier
hi def link debcontrolVcsGit Identifier
hi def link debcontrolHTTPUrl Identifier
hi def link debcontrolDmUpload Identifier
2017-11-11 20:58:53 +01:00
hi def link debcontrolYesNo Identifier
hi def link debcontrolR3 Identifier
2016-08-31 22:22:10 +02:00
hi def link debcontrolComment Comment
hi def link debcontrolElse Special
2004-06-13 20:20:40 +00:00
let b :current_syntax = "debcontrol"
2014-07-19 14:04:47 +02:00
let &cpo = s :cpo_save
unlet s :cpo_save
2004-06-13 20:20:40 +00:00
" vim: ts=8 sw=2