Parse sync database
[pacman-ng.git] / contrib / PKGBUILD.vim.in
blob8b40ed7c9a1c35339d0f62ed275ff84dfe4fff25
1 " Vim syntax file
2 " Language:     PKGBUILD
3 " Maintainer:   Alessio 'mOLOk' Bolognino <themolok at gmail.com>
4 " Last Change:  2007/05/08
5 " Version Info: PKGBUILD-0.2 (colorphobic)
7 " For version 5.x: Clear all syntax items
8 " For version 6.x: Quit when a syntax file was already loaded
9 if version < 600
10         syntax clear
11 elseif exists("b:current_syntax")
12         finish
13 endif
15 let b:main_syntax = "sh"
16 runtime! syntax/sh.vim
18 " case on
19 syn case match
21 " pkgname
22 " FIXME if '=' is in pkgname/pkgver, it highlights whole string, not just '='
23 syn keyword pb_k_pkgname pkgname contained
24 syn match pbValidPkgname /\([[:alnum:]]\|+\|-\|_\){,32}/ contained contains=pbIllegalPkgname
25 syn match pbIllegalPkgname /[[:upper:]]\|[^[:alnum:]-+_=]\|=.*=\|=['"]\?.\{33,\}['"]\?/ contained
26 syn match pbPkgnameGroup /^pkgname=.*/ contains=pbIllegalPkgname,pb_k_pkgname,shDoubleQuote,shSingleQuote
28 " pkgbase
29 " FIXME if '=' is in pkgbase/pkgname/pkgver, it highlights whole string, not just '='
30 syn keyword pb_k_pkgbase pkgbase contained
31 syn match pbValidPkgbase /\([[:alnum:]]\|+\|-\|_\){,32}/ contained contains=pbIllegalPkgbase
32 syn match pbIllegalPkgbase /[[:upper:]]\|[^[:alnum:]-+_=]\|=.*=\|=['"]\?.\{33,\}['"]\?/ contained
33 syn match pbPkgbaseGroup /^pkgbase=.*/ contains=pbIllegalPkgbase,pb_k_pkgbase,shDoubleQuote,shSingleQuote
35 " pkgver
36 syn keyword pb_k_pkgver pkgver contained
37 syn match pbValidPkgver /\([[:alnum:]]\|\.\|+\|_\)/ contained contains=pbIllegalPkgver
38 syn match pbIllegalPkgver /[^[:alnum:]+=\.\_]\|=.*=/ contained
39 syn match pbPkgverGroup /^pkgver=.*/ contains=pbIllegalPkgver,pbValidPkgver,pb_k_pkgver,shDoubleQuote,shSingleQuote
41 " pkgrel
42 syn keyword pb_k_pkgrel pkgrel contained
43 syn match pbValidPkgrel /[[:digit:]]*/ contained contains=pbIllegalPkgver
44 syn match pbIllegalPkgrel /[^[:digit:]=]\|=.*=/ contained
45 syn match pbPkgrelGroup /^pkgrel=.*/ contains=pbIllegalPkgrel,pbValidPkgrel,pb_k_pkgrel,shDoubleQuote,shSingleQuote
47 " pkgdesc
48 syn keyword pb_k_desc pkgdesc contained
49 " 90 chars: 80 for description, 8 for pkgdesc and 2 for ''
50 syn match pbIllegalPkgdesc /.\{90,}\|=['"]\?.*['" ]\+[iI][sS] [aA]/ contained contains=pbPkgdescSign
51 syn match pbValidPkgdesc /[^='"]\.\{,80}/ contained contains=pbIllegalPkgdesc
52 syn match pbPkgdescGroup /^pkgdesc=.*/ contains=pbIllegalPkgdesc,pb_k_desc,pbValidPkgdesc,shDoubleQuote,shSingleQuote
53 syn match pbPkgdescSign /[='"]/ contained
55 " url
56 syn keyword pb_k_url url contained
57 syn match pbValidUrl /['"]*\(https\|http\|ftp\)\:\/.*\.\+.*/ contained
59 syn match pbIllegalUrl /[^=]/ contained contains=pbValidUrl
60 syn match pbUrlGroup /^url=.*/ contains=pbValidUrl,pb_k_url,pbIllegalUrl,shDoubleQuote,shSingleQuote
62 " license
63 syn keyword pb_k_license license contained
64 syn keyword pbLicense  APACHE CCPL CDDL CPL EPL FDL FDL1.2 FDL1.3 GPL GPL2 GPL3 LGPL LGPL2.1 LGPL3 LPPL MPL PHP PSF PerlArtistic RALINK RUBY ZPL contained
65 syn match pbLicenseCustom /custom\(:[[:alnum:]]*\)*/ contained
66 syn match pbIllegalLicense /[^='"() ]/ contained contains=pbLicenseCustom,pbLicense
67 syn region pbLicenseGroup start=/^license=(/ end=/)/ contains=pb_k_license,pbLicenseCustom,pbLicense,pbIllegalLicense
69 " backup
70 syn keyword pb_k_backup backup contained
71 syn match pbValidBackup   /\.\?[[:alpha:]]*\/[[:alnum:]\{\}+._$-]*]*/ contained
72 syn region pbBackupGroup start=/^backup=(/ end=/)/ contains=pb_k_backup,pbValidBackup,shDoubleQuote,shSingleQuote
74 " arch
75 syn keyword pb_k_arch arch contained
76 syn keyword pbArch i686 x86_64 ppc any contained
77 syn match pbIllegalArch /[^='"() ]/ contained contains=pbArch
78 syn region pbArchGroup start=/^arch=(/ end=/)/ contains=pb_k_arch,pbArch,pbIllegalArch
80 " groups
81 syn keyword pb_k_groups groups contained
82 syn match pbValidGroups /\([[:alnum:]]\|+\|-\|_\)*/ contained
83 syn region pbGroupsGroup start=/^groups=(/ end=/)/ contains=pb_k_groups,pbValidGroups,shDoubleQuote,shSingleQuote
85 " depends
86 syn keyword pb_k_depends depends contained
87 syn match pbValidDepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
88 syn region pbDependsGroup start=/^depends=(/ end=/)/ contains=pb_k_depends,pbValidDepends,shDoubleQuote,shSingleQuote
90 " makedepends
91 syn keyword pb_k_makedepends makedepends contained
92 syn match pbValidMakedepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
93 syn region pbMakedependsGroup start=/^makedepends=(/ end=/)/ contains=pb_k_makedepends,pbValidMakedepends,shDoubleQuote,shSingleQuote
95 " optdepends
96 syn keyword pb_k_optdepends optdepends contained
97 syn match pbValidOptdepends /\([[:alnum:]]\|+\|-\|_\)*/ contained
98 syn region pbOptdependsGroup start=/^optdepends=(/ end=/)/ contains=pb_k_optdepends,pbValidOptdepends,shDoubleQuote,shSingleQuote
100 " conflicts
101 syn keyword pb_k_conflicts conflicts contained
102 syn match pbValidConflicts /\([[:alnum:]]\|+\|-\|_\)*/ contained
103 syn region pbConflictsGroup start=/^conflicts=(/ end=/)/ contains=pb_k_conflicts,pbValidConflicts,shDoubleQuote,shSingleQuote
105 " provides
106 syn keyword pb_k_provides provides contained
107 syn match pbValidProvides /\([[:alnum:]]\|+\|-\|_\)*/ contained
108 syn region pbProvidesGroup start=/^provides=(/ end=/)/ contains=pb_k_provides,pbValidProvides,shDoubleQuote,shSingleQuote
110 " replaces
111 syn keyword pb_k_replaces replaces contained
112 syn match pbValidReplaces /\([[:alnum:]]\|+\|-\|_\)*/ contained
113 syn region pbReplacesGroup start=/^replaces=(/  end=/)/ contains=pb_k_replaces,pbValidReplaces,shDoubleQuote,shSingleQuote
115 " install
116 " XXX remove install from bashStatement, fix strange bug
117 syn clear bashStatement
118 syn keyword bashStatement chmod clear complete du egrep expr fgrep find gnufind gnugrep grep less ls mkdir mv rm rmdir rpm sed sleep sort strip tail touch
120 syn keyword pb_k_install install contained
121 syn match pbValidInstall /\([[:alnum:]]\|\$\|+\|-\|_\)*\.install/ contained
122 syn match pbIllegalInstall /[^=]/ contained contains=pbValidInstall
123 syn match pbInstallGroup /^install=.*/ contains=pb_k_install,pbValidInstall,pbIllegalInstall,shDeref,shDoubleQuote,shSingleQuote
125 " changelog
126 syn keyword pb_k_changelog changelog contained
127 syn match pbValidChangelog /\([[:alnum:]]\|\$\|+\|-\|_\)*/ contained
128 syn match pbIllegalChangelog /[^=]/ contained contains=pbValidChangelog
129 syn match pbChangelogGroup /^changelog=.*/ contains=pb_k_changelog,pbValidChangelog,pbIllegalChangelog,shDeref,shDoubleQuote,shSingleQuote
131 " source:
132 " XXX remove source from shStatement, fix strange bug
133 syn clear shStatement
134 syn keyword shStatement xxx wait getopts return autoload whence printf true popd nohup enable r trap readonly fc fg kill ulimit umask disown stop pushd read history logout times local exit test pwd time eval integer suspend dirs shopt hash false newgrp bg print jobs continue functions exec help cd break unalias chdir type shift builtin let bind
136 syn keyword pb_k_source source contained
137 syn match pbIllegalSource /\(http\|ftp\|https\).*\.\+\(dl\|download.\?\)\.\(sourceforge\|sf\).net/
138 syn region pbSourceGroup  start=/^source=(/ end=/)/ contains=pb_k_source,pbIllegalSource,shNumber,shDoubleQuote,shSingleQuote,pbDerefEmulation
139 syn match pbDerefEmulation /\$[{]\?[[:alnum:]_]*[}]\?/ contained
140 hi def link pbDerefEmulation PreProc
142 " md5sums
143 syn keyword pb_k_md5sums md5sums contained
144 syn match pbIllegalMd5sums /[^='"()\/ ]/ contained contains=pbValidMd5sums
145 syn match pbValidMd5sums /\x\{32\}/ contained
146 syn region pbMd5sumsGroup start=/^md5sums/ end=/)/ contains=pb_k_md5sums,pbMd5Quotes,pbMd5Hash,pbIllegalMd5sums keepend
147 syn match pbMd5Quotes /'.*'\|".*"/ contained contains=pbMd5Hash,pbIllegalMd5sums
148 syn match pbMd5Hash /\x\+/ contained contains=pbValidMd5sums
149 hi def link pbMd5Quotes Keyword
150 hi def link pbMd5Hash Error
151 hi def link pbValidMd5sums  Number
153 " sha1sums
154 syn keyword pb_k_sha1sums sha1sums contained
155 syn match pbIllegalSha1sums /[^='"()\/ ]/ contained contains=pbValidSha1sums
156 syn match pbValidSha1sums /\x\{40\}/ contained
157 syn region pbSha1sumsGroup start=/^sha1sums/ end=/)/ contains=pb_k_sha1sums,pbSha1Quotes,pbSha1Hash,pbIllegalSha1sums keepend
158 syn match pbSha1Quotes /'.*'\|".*"/ contained contains=pbSha1Hash,pbIllegalSha1sums
159 syn match pbSha1Hash /\x\+/ contained contains=pbValidSha1sums
160 hi def link pbSha1Quotes Keyword
161 hi def link pbSha1Hash Error
162 hi def link pbValidSha1sums  Number
164 " options
165 syn keyword pb_k_options options contained
166 syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|ccache\|distcc\|makeflags\|force\)/ contained
167 syn match   pbOptionsNeg     /\!/ contained
168 syn match   pbOptionsDeprec  /no/ contained
169 syn region pbOptionsGroup start=/^options=(/ end=/)/ contains=pb_k_options,pbOptions,pbOptionsNeg,pbOptionsDeprec,pbIllegalOption,shDoubleQuote,shSingleQuote
170 syn match pbIllegalOption /[^!"'()= ]/ contained contains=pbOptionsDeprec,pbOptions
172 " noextract
173 syn match pbNoextract /[[:alnum:]+._${}-]\+/ contained
174 syn keyword pb_k_noextract noextract  contained
175 syn region pbNoextractGroup  start=/^noextract=(/ end=/)/ contains=pb_k_noextract,pbNoextract,shDoubleQuote,shSingleQuote
177 " comments
178 syn keyword    pb_k_maintainer Maintainer Contributor contained
179 syn match      pbMaintainerGroup /Maintainer.*/ contains=pbMaintainer contained
181 syn match pbDate /[0-9]\{4}\/[0-9]\{2}\/[0-9]\{2}/ contained
183 syn cluster    pbCommentGroup   contains=pbTodo,pb_k_maintainer,pbMaintainerGroup,pbDate
184 syn keyword    pbTodo   contained       COMBAK FIXME TODO XXX
185 syn match      pbComment        "^#.*$" contains=@pbCommentGroup
186 syn match      pbComment        "[^0-9]#.*$"    contains=@pbCommentGroup
188 " quotes are handled by sh.vim
190 hi def link pbComment Comment
191 hi def link pbTodo Todo
193 hi def link pbIllegalPkgname Error
194 hi def link pb_k_pkgname pbKeywords
196 hi def link pbIllegalPkgbase Error
197 hi def link pb_k_pkgbase pbKeywords
199 hi def link pbIllegalPkgver Error
200 hi def link pb_k_pkgver pbKeywords
202 hi def link pbIllegalPkgrel Error
203 hi def link pb_k_pkgrel pbKeywords
205 hi def link pbIllegalPkgdesc Error
206 hi def link pb_k_desc pbKeywords
208 hi def link pbIllegalUrl Error
209 hi def link pb_k_url pbKeywords
211 hi def link pb_k_license pbKeywords
212 hi def link pbIllegalLicense Error
214 hi def link pb_k_backup pbKeywords
216 hi def link pb_k_arch pbKeywords
217 hi def link pbIllegalArch Error
219 hi def link pb_k_groups pbKeywords
220 hi def link pb_k_makedepends pbKeywords
221 hi def link pb_k_optdepends pbKeywords
222 hi def link pb_k_depends pbKeywords
223 hi def link pb_k_replaces pbKeywords
224 hi def link pb_k_conflicts pbKeywords
225 hi def link pb_k_provides pbKeywords
227 hi def link pbIllegalInstall Error
228 hi def link pb_k_install pbKeywords
230 hi def link pbIllegalChangelog Error
231 hi def link pb_k_changelog pbKeywords
233 hi def link pb_k_source pbKeywords
234 hi def link pbIllegalSource Error
236 hi def link pb_k_md5sums pbKeywords
237 hi def link pbIllegalMd5sums Error
239 hi def link pb_k_sha1sums pbKeywords
240 hi def link pbIllegalSha1sums Error
242 hi def link pb_k_options pbKeywords
243 hi def link pbOptionsDeprec Todo
244 hi def link pbIllegalOption Error
246 hi def link pb_k_noextract pbKeywords
247 hi def link pbNoextract Normal
249 hi def link pb_k_maintainer pbKeywords
251 hi def link pbKeywords Keyword
253 hi def link pbDate Special
255 "syntax include @SHELL syntax/sh.vim
256 "syntax region BUILD start=/^build()/ end=/^}/ contains=@SHELL
257 "let b:current_syntax = "PKGBUILD"
259 " vim: ft=vim