]> git.pld-linux.org Git - packages/vim.git/blame - spec.vim
- vim-plugin-securemodelines should be suggested, not required
[packages/vim.git] / spec.vim
CommitLineData
18f77c52
ER
1" Filename: spec.vim
2" Purpose: Vim syntax file
3" Language: SPEC: Build/install scripts for Linux RPM packages
4" Maintainer: Donovan Rebbechi elflord@pegasus.rutgers.edu
5" URL: http://pegasus.rutgers.edu/~elflord/vim/syntax/spec.vim
6" Last Change: Tue Oct 3 17:35:15 BRST 2000 <aurelio@conectiva.com.br>
7
8" For version 5.x: Clear all syntax items
9" For version 6.x: Quit when a syntax file was already loaded
10if version < 600
11 syntax clear
12elseif exists("b:current_syntax")
13 finish
14endif
15
16syn sync minlines=1000
17
06d78f8d 18syn match specSpecialChar contained '[][!$()\\|>^;:]'
18f77c52
ER
19syn match specColon contained ':'
20syn match specPercent contained '%'
036cd7fe 21syn match specSubstChar contained '[#%]'
18f77c52
ER
22
23syn match specVariables contained '\$\h\w*' contains=specSpecialVariablesNames,specSpecialChar
24syn match specVariables contained '\${\w*}' contains=specSpecialVariablesNames,specSpecialChar
036cd7fe 25syn match specVariables contained '\${\w*[#%][^}]*}' contains=specSubstChar
18f77c52 26
4bea97b7 27syn match specMacroIdentifier contained '%\h\w*' contains=specMacroNameLocal,specMacroNameOther,specPercent,specSpecialChar
06d78f8d
ER
28"syn match specMacroIdentifier contained '%{\w*}' contains=specMacroNameLocal,specMacroNameOther,specPercent,specSpecialChar
29syn region specMacroIdentifier oneline matchgroup=Special start='%{' skip='\\}' end='}' contains=specMacroNameLocal,specMacroNameOther,specPercent,specSpecialChar
30syn match specBcond contained '%{with\(out\)\?\s\+[a-zA-Z0-9_-]\+}'
18f77c52
ER
31
32syn match specSpecialVariables contained '\$[0-9]\|\${[0-9]}'
7da61caa 33syn match specCommandOpts contained '\s\(-\w\+\|--\w[a-zA-Z0-9_-]\+\)'ms=s+1
18f77c52
ER
34syn match specComment '^\s*#.*$'
35
36
37syn case match
38
39
983d4cf0 40" matches with no highlight
18f77c52
ER
41syn match specNoNumberHilite 'X11\|X11R6\|[a-zA-Z]*\.\d\|[a-zA-Z][-/]\d'
42syn match specManpageFile '[a-zA-Z]\.1'
43
983d4cf0 44" Day, Month and most used license acronyms
4bea97b7 45syn keyword specLicense contained GPL LGPL BSD MIT GNU Apache PHP
31225a17 46syn keyword specLicenseWarning contained unknown
d01c1c34 47syn match specLicenseWarning contained /same as perl/
22f2423e 48syn match specLicenseWarning contained "(enter GPL/LGPL/BSD/BSD-like/Artistic/other license name here)"
18f77c52
ER
49syn keyword specWeekday contained Mon Tue Wed Thu Fri Sat Sun
50syn keyword specMonth contained Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec
51syn keyword specMonth contained January February March April May June July August September October November December
52
983d4cf0 53" #, @, www
18f77c52
ER
54syn match specNumber '\(^-\=\|[ \t]-\=\|-\)[0-9.-]*[0-9]'
55syn match specEmail contained "<\=\<[A-Za-z0-9_.-]\+@\([A-Za-z0-9_-]\+\.\)\+[A-Za-z]\+\>>\="
09c38e14 56syn match specURL contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#?=-]\+\>'
18f77c52
ER
57syn match specURLMacro contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#%{}-]\+\>' contains=specMacroIdentifier
58
983d4cf0
ER
59" TODO take specSpecialVariables out of the cluster for the sh* contains (ALLBUT)
60" Special system directories
18f77c52
ER
61syn match specListedFilesPrefix contained '/\(usr\|local\|opt\|X11R6\|X11\)/'me=e-1
62syn match specListedFilesBin contained '/s\=bin/'me=e-1
63syn match specListedFilesLib contained '/\(lib\|include\)/'me=e-1
64syn match specListedFilesDoc contained '/\(man\d*\|doc\|info\)\>'
65syn match specListedFilesEtc contained '/etc/'me=e-1
66syn match specListedFilesShare contained '/share/'me=e-1
036cd7fe 67syn cluster specListedFiles contains=specListedFilesBin,specListedFilesLib,specListedFilesDoc,specListedFilesEtc,specListedFilesShare,specListedFilesPrefix,specSpecialChar
18f77c52 68
983d4cf0 69" specComands
18f77c52 70syn match specConfigure contained '\./configure'
4273bb63 71syn match specTarCommand contained '\<tar\s\+[cxvpzjf]\{,5}\s*'
58f56a33 72
7d7d47a3 73" XXX don't forget to update specScriptArea when updating specMacro
58f56a33 74syn match specMacro contained '%\(group\|user\)\(add\|remove\)'
0fb6b582 75syn match specMacro contained '%\(depmod\|banner\|service\|addusertogroup\|env_update\)'
58f56a33 76syn match specMacro contained '%\(\(nsplugin\|apache_config\)_\(un\)\?install\)'
711e9e8a 77syn match specMacro contained '%\(\(openldap_schema\|webapp\)_\(un\)\?register\)'
58f56a33
ER
78syn match specMacro contained '%\(pear_package_\(setup\|install\)\)'
79syn match specMacro contained '%\(py_o\?comp\|py_postclean\)'
dabdc22d 80syn match specMacro contained '%\(build\|install\)_kernel_modules'
400b2064 81syn match specMacro contained '%ant'
ddf582de 82syn match specMacro contained '%\(php\|php4\)_webserver_restart'
07faf8fe 83syn match specMacro contained '%update_browser_plugins\|%browser_plugins_add_browser'
58f56a33 84
18f77c52 85syn keyword specCommandSpecial contained root
73b8e09b 86syn keyword specCommand contained make xmkmf mkdir chmod find sed rm strip moc echo grep ls rm mv mkdir chown install cp pwd cat tail then else elif cd gzip rmdir ln eval export touch unzip bzip2
3e77e77f 87syn cluster specCommands contains=specCommand,specTarCommand,specConfigure,specCommandSpecial,specMacro
18f77c52 88
983d4cf0 89" frequently used rpm env vars
18f77c52
ER
90syn keyword specSpecialVariablesNames contained RPM_BUILD_ROOT RPM_BUILD_DIR RPM_SOURCE_DIR RPM_OPT_FLAGS LDFLAGS CC CC_FLAGS CPPNAME CFLAGS CXX CXXFLAGS CPPFLAGS
91
983d4cf0 92" valid macro names from /usr/lib/rpm/macros
8d61db40
ER
93syn keyword specMacroNameOther contained buildroot buildsubdir distribution disturl ix86 name nil optflags perl_sitearch release requires_eq vendor version
94syn keyword specMacroNameOther contained __kernel_ver date debugcflags debuginfocflags epoch kgcc kgcc_package packager
95syn keyword specMacroNameOther contained pear_package_install pear_package_setup perl_archlib perl_privlib perl_sitelib
ea186f5b
ER
96syn keyword specMacroNameOther contained perl_vendorarch perl_vendorlib php_pear_dir py_sitedir py_scriptdir py_sitescriptdir
97syn keyword specMacroNameOther contained requires_php_extension requires_php_pdo_module
f1e582f3 98syn keyword specMacroNameOther contained requires_zend_extension ruby_mod_ver_requires_eq ruby_ver_requires_eq rpmcflags rpmcxxflags rpmldflags tmpdir x8664
2bb9ce1f 99syn keyword specMacroNameOther contained ruby_archdir ruby_rubylibdir ruby_vendorarchdir ruby_vendorlibdir ruby_ridir ruby_sitearchdir ruby_sitelibdir ruby_version
f1e582f3 100syn keyword specMacroNameOther contained apache_modules_api php_sysconfdir php_includedir php_extensiondir _browserpluginsdir _browserpluginsconfdir
ea186f5b 101syn keyword specMacroNameOther contained releq_kernel releq_kernel_up releq_kernel_smp requires_releq_kernel requires_releq_kernel_up requires_releq_kernel_smp
8d61db40 102
18f77c52
ER
103syn match specMacroNameOther contained '\<\(PATCH\|SOURCE\)\d*\>'
104
983d4cf0
ER
105" valid _macro names from /usr/lib/rpm/macros
106syn keyword specMacroNameLocal contained _aclocaldir _applnkdir _arch _binary_payload _bindir _build _build_arch _build_alias
107syn keyword specMacroNameLocal contained _build_cpu _builddir _build_os _buildshell _buildsubdir _build_vendor _bzip2bin _datadir
7d7d47a3 108syn keyword specMacroNameLocal contained _dbpath _dbpath_rebuild _defaultdocdir _desktopdir _docdir _examplesdir _excludedocs _kdedocdir
983d4cf0
ER
109syn keyword specMacroNameLocal contained _exec_prefix _fixgroup _fixowner _fixperms _fontsdir _ftpport _ftpproxy _gnu _gpg_name
110syn keyword specMacroNameLocal contained _gpg_path _gtkdocdir _gzipbin _host _host_alias _host_cpu _host_os _host_vendor
111syn keyword specMacroNameLocal contained _httpport _httpproxy _iconsdir _includedir _infodir _initrddir _install_langs
112syn keyword specMacroNameLocal contained _install_script_path _instchangelog _javaclasspath _javadir _javadocdir _kernelsrcdir
113syn keyword specMacroNameLocal contained _kernel_ver _kernel_ver_str _langpatt _lib _libdir _libexecdir _localstatedir _mandir
114syn keyword specMacroNameLocal contained _netsharedpath _oldincludedir _omf_dest_dir _os _package_version _pgpbin _pgp_name
115syn keyword specMacroNameLocal contained _pgp_path _pixmapsdir _pkgconfigdir _prefix _preScriptEnvironment _provides _rpmdir
116syn keyword specMacroNameLocal contained _rpmfilename _sbindir _sharedstatedir _signature _smp_mflags _sourcedir _source_payload
117syn keyword specMacroNameLocal contained _specdir _srcrpmdir _sysconfdir _target _target_alias _target_cpu _target_os _target_platform
118syn keyword specMacroNameLocal contained _target_vendor _target_base_arch _timecheck _tmppath _topdir _usr _usrsrc _var _vendor
4e9f4380
ER
119syn keyword specMacroNameLocal contained __cxx __cc __libtoolize __autopoint __aclocal __autoconf __automake __autoheader
120syn keyword specMacroNameLocal contained __gettextize __glib_gettextize __intltoolize
121syn keyword specMacroNameLocal contained __bzip2 __cat __chgrp __chmod __chown __cp __cpio __file __gpg __grep __gzip
122syn keyword specMacroNameLocal contained __id __install __ld __make __mkdir __mkdir_p __mv __nm __objcopy __objdump
123syn keyword specMacroNameLocal contained __patch __perl __pgp __python __rm __rsh __sed __ssh __strip __tar __unzip
124
18f77c52
ER
125
126
983d4cf0 127" ------------------------------------------------------------------------------
18f77c52
ER
128" here's is all the spec sections definitions: PreAmble, Description, Package,
129" Scripts, Files and Changelog
130
983d4cf0
ER
131" One line macros - valid in all ScriptAreas
132" tip: remember do include new items on specScriptArea's skip section
5645859b
ER
133syn region specSectionMacroArea oneline matchgroup=specSectionMacro start='^%\(\(un\)\?define\|dump\|trace\|patch\d*\|setup\|configure2_13\|configure\|GNUconfigure\|find_lang\|makeinstall\|cmake\|scons\|waf\|bcond_with\(out\)\?\|include\)\>' end='$' contains=specCommandOpts,specMacroIdentifier,specSectionMacroBcondArea
134syn region specSectionMacroBracketArea oneline matchgroup=specSectionMacro start='^%{\(configure2_13\|configure\|GNUconfigure\|find_lang\|makeinstall\|cmake\|scons\|waf\)}' end='$' contains=specCommandOpts,specMacroIdentifier
06d78f8d 135syn region specSectionMacroBcondArea oneline matchgroup=specBlock start='%{!\??\(with\(out\)\?_[a-zA-Z0-9_]\+\|debug\):' skip='\\}' end='}' contains=ALLBUT,shCase
18f77c52 136
983d4cf0
ER
137" %% Files Section %%
138" TODO %config valid parameters: missingok\|noreplace
139" TODO %verify valid parameters: \(not\)\= \(md5\|atime\|...\)
c1269790
ER
140syn region specFilesArea matchgroup=specSection start='^%[Ff][Ii][Ll][Ee][Ss]\>'
141 \ skip='%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|verify\|ghost\|exclude\|dev\|if\|else\|endif\)\>'
142 \ end='^%[a-zA-Z]'me=e-2
143 \ contains=specFilesOpts,specFilesDirective,@specListedFiles,specComment,specCommandSpecial,specMacroIdentifier,specSectionMacroBcondArea,specIf
144
983d4cf0 145" tip: remember to include new items in specFilesArea above
53534d87 146syn match specFilesDirective contained '%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|verify\|ghost\|exclude\|dev\)\>'
18f77c52 147
983d4cf0 148" valid options for certain section headers
18f77c52
ER
149syn match specDescriptionOpts contained '\s-[ln]\s*\a'ms=s+1,me=e-1
150syn match specPackageOpts contained '\s-n\s*\w'ms=s+1,me=e-1
151syn match specFilesOpts contained '\s-f\s*\w'ms=s+1,me=e-1
152
153
154syn case ignore
155
156
983d4cf0
ER
157" %% PreAmble Section %%
158" Copyright and Serial were deprecated by License and Epoch
4bea97b7
ER
159" PreReq and BuildPreReq deprecated by Requires ans BuildRequires
160syn region specPreAmbleDeprecated oneline matchgroup=specError start='^\(Copyright\|Serial\|PreReq\|BuildPreReq\(uires\)\?\)' end='$' contains=specEmail,specURL,specURLMacro,specLicense,specColon,specVariables,specSpecialChar,specMacroIdentifier
41131cd0 161syn region specPreAmble oneline matchgroup=specCommand
08242281 162 \ start='\(^\|\(^%{!\??\(with\(out\)\?_[a-zA-Z0-9_]\+\|debug\):\)\@<=\)\(Summary\|Name\|Version\|Packager\|Requires\|Suggests\|Icon\|URL\|Source\d*\|Patch\d*\|Prefix\|Packager\|Group\|License\|Release\|BuildRoot\|Distribution\|Vendor\|Provides\|ExclusiveArch\|ExcludeArch\|ExclusiveOS\|Obsoletes\|BuildArch\|BuildArchitectures\|BuildRequires\|BuildConflicts\|Conflicts\|AutoRequires\|AutoReqProv\|AutoReq\|AutoProv\|Epoch\|NoSource\)'
41131cd0 163 \ end='$\|}\@='
31225a17 164 \ contains=specEmail,specURL,specURLMacro,specLicense,specLicenseWarning,specColon,specVariables,specSpecialChar,specMacroIdentifier,specSectionMacroBcondArea
18f77c52 165
983d4cf0 166" %% Description Section %%
2ce88e66
ER
167syn region specDescriptionArea matchgroup=specSection start='^%description' end='^%'me=e-1
168 \ contains=specDescriptionOpts,specEmail,specURL,specNumber,specMacroIdentifier,specComment
18f77c52 169
983d4cf0 170" %% Package Section %%
2ce88e66
ER
171syn region specPackageArea matchgroup=specSection start='^%package' end='^%'me=e-1
172 \ contains=specPackageOpts,specPreAmble,specComment,specMacroNameOther
18f77c52 173
983d4cf0 174" %% Scripts Section %%
3e77e77f 175syn region specScriptArea matchgroup=specSection
675ba4b8 176 \ start='^%\(prep\|build\|install\|clean\|pre\|postun\|preun\|post\|triggerin\|triggerun\|triggerpostun\|pretrans\|posttrans\|verifyscript\|check\)\>'
64f94ba0 177 \ skip='^%{\|^%\(define\|patch\d*\|configure2_13\|configure\|ant\|GNUconfigure\|setup\|find_lang\|makeinstall\|cmake\|scons\|waf\|useradd\|groupadd\|addusertogroup\|banner\|service\|env_update\|py_o\?comp\|py_postclean\|\(openldap_schema\|webapp\)_\(un\)\?register\|depmod\|pear_package_\(setup\|install\)\|\(build\|install\)_kernel_modules\|php_webserver_restart\|php4_webserver_restart\|update_browser_plugins\)\>'
3e77e77f
ER
178 \ end='^%'me=e-1
179 \ contains=specSpecialVariables,specVariables,@specCommands,specVariables,shDo,shFor,shCaseEsac,specNoNumberHilite,specCommandOpts,shComment,shIf,specSpecialChar,specMacroIdentifier,specSectionMacroArea,specSectionMacroBracketArea,shOperator,shQuote1,shQuote2,specSectionMacroBcondArea
675ba4b8 180" XXX don't forget to update specMacro when updating specScriptArea skip definition
18f77c52 181
983d4cf0 182" %% Changelog Section %%
bc8bbced
ER
183syn region specChangelogArea matchgroup=specSection start='^%changelog' end='^%'me=e-1
184 \ contains=specEmail,specURL,specWeekday,specMonth,specNumber,specComment,specLicense,specRevision,specLogMessage,specLogError
18f77c52 185
4d8f817a 186syn match specRevision contained "^Revision [.0-9]\+ [-/0-9]\+ [:0-9]\+ [a-zA-Z0-9]\+$"
09c38e14 187syn region specLogMessage contained start="^[- ] " end="$" contains=specLogError,specURL,specEmail
09c38e14 188syn match specLogError contained "%%"
18f77c52 189
983d4cf0
ER
190" ------------------------------------------------------------------------------
191" here's the shell syntax for all the Script Sections
18f77c52
ER
192
193
194syn case match
195
196
983d4cf0 197" sh-like comment style, only valid in script part
18f77c52
ER
198syn match shComment contained '#.*$'
199
200syn region shQuote1 contained matchgroup=shQuoteDelim start=+'+ skip=+\\'+ end=+'+ contains=specMacroIdentifier
06d78f8d 201syn region shQuote2 contained matchgroup=shQuoteDelim start=+"+ skip=+\\"+ end=+"+ contains=specVariables,specMacroIdentifier,specSectionMacroBcondArea
18f77c52
ER
202
203syn match shOperator contained '[><|!&;]\|[!=]='
036cd7fe 204syn region shDo transparent matchgroup=specBlock start="\(^\|\s\)do\(\s\|$\)" end="\(^\|\s\)done\(\s\|$\)" contains=ALLBUT,shDoError,shCase,specPreAmble,@specListedFiles
18f77c52 205
d83fcd4c 206syn region specIf matchgroup=specBlock start="%ifosf\|%ifos\|%ifnos\|%ifarch\|%ifnarch\|ifdef\|ifndef\|%if\|%else" end='%endif' contains=ALLBUT, specIfError, shCase, shComment
18f77c52 207
036cd7fe 208syn region shIf transparent matchgroup=specBlock start="\(^\|\s\)if\(\s\|$\)" end="\(^\|\s\)fi\(\s\|$\)" contains=ALLBUT,shIfError,shCase,@specListedFiles
18f77c52 209
036cd7fe 210syn region shFor matchgroup=specBlock start="\(^\|\s\)for\(\s\|$\)" end="\(^\|\s\)in\(\s\|$\)" contains=ALLBUT,shInError,shCase,@specListedFiles
18f77c52 211
036cd7fe 212syn region shCaseEsac transparent matchgroup=specBlock start="\(^\|\s\)case\(\s\|$\)" matchgroup=NONE end="\(^\|\s\)in\(\s\|$\)"me=s-1 contains=ALLBUT,@specListedFiles nextgroup=shCaseEsac
213syn region shCaseEsac matchgroup=specBlock start="\(^\|\s\)in\(\s\|$\)" end="\(^\|\s\)esac\(\s\|$\)" contains=ALLBUT,@specListedFilesBin
214syn region shCase matchgroup=specBlock contained start=")" end=";;" contains=ALLBUT,shCase,@specListedFiles
18f77c52
ER
215
216syn sync match shDoSync grouphere shDo "\<do\>"
217syn sync match shDoSync groupthere shDo "\<done\>"
218syn sync match shIfSync grouphere shIf "\<if\>"
219syn sync match shIfSync groupthere shIf "\<fi\>"
220syn sync match specIfSync grouphere specIf "%ifarch\|%ifos\|%ifnos"
221syn sync match specIfSync groupthere specIf "%endIf"
222syn sync match shForSync grouphere shFor "\<for\>"
223syn sync match shForSync groupthere shFor "\<in\>"
224syn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>"
225syn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>"
226
227" Define the default highlighting.
228" For version 5.7 and earlier: only when not done already
229" For version 5.8 and later: only when an item doesn't have highlighting yet
230if version >= 508 || !exists("did_spec_syntax_inits")
231 if version < 508
232 let did_spec_syntax_inits = 1
233 command -nargs=+ HiLink hi link <args>
234 else
235 command -nargs=+ HiLink hi def link <args>
236 endif
237
238 "main types color definitions
239 HiLink specSection Structure
240 HiLink specSectionMacro Macro
241 HiLink specWWWlink PreProc
242 HiLink specOpts Operator
243
244 "yes, it's ugly, but white is sooo cool
245 if &background == "dark"
246 hi def specGlobalMacro ctermfg=white
247 else
248 HiLink specGlobalMacro Identifier
249 endif
250
251 "sh colors
252 HiLink shComment Comment
253 HiLink shIf Statement
254 HiLink shOperator Special
255 HiLink shQuote1 String
256 HiLink shQuote2 String
257 HiLink shQuoteDelim Statement
258
983d4cf0 259 " spec colors
18f77c52 260 HiLink specBlock Function
06d78f8d 261 HiLink specBcond Function
18f77c52
ER
262 HiLink specColon Special
263 HiLink specCommand Statement
264 HiLink specCommandOpts specOpts
265 HiLink specCommandSpecial Special
266 HiLink specComment Comment
267 HiLink specConfigure specCommand
268 HiLink specDate String
269 HiLink specDescriptionOpts specOpts
270 HiLink specEmail specWWWlink
271 HiLink specError Error
272 HiLink specFilesDirective specSectionMacro
273 HiLink specFilesOpts specOpts
274 HiLink specLicense String
31225a17 275 HiLink specLicenseWarning specError
18f77c52
ER
276 HiLink specMacroNameLocal specGlobalMacro
277 HiLink specMacroNameOther specGlobalMacro
278 HiLink specManpageFile NONE
279 HiLink specMonth specDate
280 HiLink specNoNumberHilite NONE
281 HiLink specNumber Number
282 HiLink specPackageOpts specOpts
283 HiLink specPercent Special
284 HiLink specSpecialChar Special
036cd7fe 285 HiLink specSubstChar Special
18f77c52
ER
286 HiLink specSpecialVariables specGlobalMacro
287 HiLink specSpecialVariablesNames specGlobalMacro
288 HiLink specTarCommand specCommand
3e77e77f 289 HiLink specMacro Macro
18f77c52
ER
290 HiLink specURL specWWWlink
291 HiLink specURLMacro specWWWlink
292 HiLink specVariables Identifier
293 HiLink specWeekday specDate
294 HiLink specListedFilesBin Statement
295 HiLink specListedFilesDoc Statement
296 HiLink specListedFilesEtc Statement
297 HiLink specListedFilesLib Statement
298 HiLink specListedFilesPrefix Statement
299 HiLink specListedFilesShare Statement
300
09c38e14
ER
301 HiLink specRevision Number
302 HiLink specLogMessage Identifier
09c38e14
ER
303 HiLink specLogError Error
304
18f77c52
ER
305 delcommand HiLink
306endif
307
308let b:current_syntax = "spec"
309
310" vim: ts=8
This page took 0.097987 seconds and 4 git commands to generate.