2 " Purpose: Vim syntax file
3 " Language: SPEC: Build/install scripts for PLD Linux RPM packages
4 " Maintainer: PLD Linux <feedback@pld-linux.org>
5 " URL: http://www.pld-linux.org/
6 " Last Change: $Date$ (UTC)
9 " For version 5.x: Clear all syntax items
10 " For version 6.x: Quit when a syntax file was already loaded
13 elseif exists("b:current_syntax")
17 syn sync minlines=1000
19 syn match specSpecialChar contained '[][!$()\\|>^;:]'
20 syn match specColon contained ':'
21 syn match specPercent contained '%'
22 syn match specSubstChar contained '[#%]'
24 syn match specVariables contained '\$\h\w*' contains=specSpecialVariablesNames,specSpecialChar
25 syn match specVariables contained '\${\w*}' contains=specSpecialVariablesNames,specSpecialChar
26 syn match specVariables contained '\${\w*[#%][^}]*}' contains=specSubstChar
28 syn match specMacroIdentifier contained '%\h\w*' contains=specMacroNameLocal,specMacroNameOther,specPercent,specSpecialChar
29 syn region specMacroIdentifier oneline matchgroup=Special start='%{' skip='\\}' end='}' contains=specMacroNameLocal,specMacroNameOther,specPercent,specSpecialChar
30 syn match specBcond contained '%{with\(out\)\?\s\+[a-zA-Z0-9_-]\+}'
32 syn match specSpecialVariables contained '\$[0-9]\|\${[0-9]}'
33 syn match specCommandOpts contained '\s\(-\w\+\|--\w[a-zA-Z0-9_-]\+\)'ms=s+1
34 syn match specComment '^\s*#.*$'
38 " matches with no highlight
39 syn match specNoNumberHilite 'X11\|X11R6\|[a-zA-Z]*\.\d\|[a-zA-Z][-/]\d'
40 syn match specManpageFile '[a-zA-Z]\.1'
42 " Day, Month and most used license acronyms
43 syn keyword specLicense contained GPL LGPL BSD MIT GNU Apache PHP
44 syn keyword specLicenseWarning contained unknown
45 syn match specLicenseWarning contained /same as perl/
46 syn match specLicenseWarning contained "(enter GPL/LGPL/BSD/BSD-like/Artistic/other license name here)"
47 syn keyword specWeekday contained Mon Tue Wed Thu Fri Sat Sun
48 syn keyword specMonth contained Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec
49 syn keyword specMonth contained January February March April May June July August September October November December
52 syn match specNumber '\(^-\=\|[ \t]-\=\|-\)[0-9.-]*[0-9]'
53 syn match specEmail contained "<\=\<[A-Za-z0-9_.-]\+@\([A-Za-z0-9_-]\+\.\)\+[A-Za-z]\+\>>\="
54 syn match specURL contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#?=-]\+\>'
55 syn match specURLMacro contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#%{}-]\+\>' contains=specMacroIdentifier
57 " TODO take specSpecialVariables out of the cluster for the sh* contains (ALLBUT)
58 " Special system directories
59 syn match specListedFilesPrefix contained '/\(usr\|local\|opt\|X11R6\|X11\)/'me=e-1
60 syn match specListedFilesBin contained '/s\=bin/'me=e-1
61 syn match specListedFilesLib contained '/\(lib\|include\)/'me=e-1
62 syn match specListedFilesDoc contained '/\(man\d*\|doc\|info\)\>'
63 syn match specListedFilesEtc contained '/etc/'me=e-1
64 syn match specListedFilesShare contained '/share/'me=e-1
65 syn cluster specListedFiles contains=specListedFilesBin,specListedFilesLib,specListedFilesDoc,specListedFilesEtc,specListedFilesShare,specListedFilesPrefix,specSpecialChar
68 syn match specConfigure contained '\./configure'
69 syn match specTarCommand contained '\<tar\s\+[cxvpzjf]\{,5}\s*'
71 " XXX don't forget to update specScriptArea when updating specMacro
72 syn match specMacro contained '%\(group\|user\)\(add\|remove\)'
73 syn match specMacro contained '%\(depmod\|banner\|service\|addusertogroup\|env_update\)'
74 syn match specMacro contained '%\(\(nsplugin\|apache_config\)_\(un\)\?install\)'
75 syn match specMacro contained '%\(\(openldap_schema\|webapp\)_\(un\)\?register\)'
76 syn match specMacro contained '%\(pear_package_\(setup\|install\)\)'
77 syn match specMacro contained '%\(py_o\?comp\|py_postclean\|py_lint\)'
78 syn match specMacro contained '%\(build\|install\)_kernel_modules'
79 syn match specMacro contained '%ant'
80 syn match specMacro contained '%\(php\|php4\)_webserver_restart'
81 syn match specMacro contained '%update_browser_plugins\|%browser_plugins_add_browser'
82 syn match specMacro contained '%gconf_schema_\(un\)?install'
83 syn match specMacro contained '%scrollkeeper_update_post\(un\)?'
84 syn match specMacro contained '%update_icon_cache\|%update_mime_database'
86 syn keyword specCommandSpecial contained root
87 syn 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
88 syn cluster specCommands contains=specCommand,specTarCommand,specConfigure,specCommandSpecial,specMacro
90 " frequently used rpm env vars
91 syn keyword specSpecialVariablesNames contained RPM_BUILD_ROOT RPM_BUILD_DIR RPM_SOURCE_DIR RPM_OPT_FLAGS LDFLAGS CC CC_FLAGS CPPNAME CFLAGS CXX CXXFLAGS CPPFLAGS
93 " valid macro names from /usr/lib/rpm/macros*
94 syn keyword specMacroNameOther contained ix86 x8664 ppc
95 syn keyword specMacroNameOther contained buildroot buildsubdir distribution disturl name nil optflags perl_sitearch release requires_eq vendor version
96 syn keyword specMacroNameOther contained __kernel_ver date debugcflags debuginfocflags epoch kgcc kgcc_package packager
97 syn keyword specMacroNameOther contained pear_package_install pear_package_setup perl_archlib perl_privlib perl_sitelib
98 syn keyword specMacroNameOther contained perl_vendorarch perl_vendorlib php_pear_dir php_data_dir py_sitedir py_scriptdir py_sitescriptdir
99 syn keyword specMacroNameOther contained requires_php_extension requires_php_pdo_module
100 syn keyword specMacroNameOther contained requires_zend_extension ruby_mod_ver_requires_eq ruby_ver_requires_eq rpmcflags rpmcxxflags rpmldflags tmpdir
101 syn keyword specMacroNameOther contained ruby_archdir ruby_rubylibdir ruby_vendorarchdir ruby_vendorlibdir ruby_ridir ruby_sitearchdir ruby_sitelibdir ruby_version
102 syn keyword specMacroNameOther contained apache_modules_api php_sysconfdir php_includedir php_extensiondir _browserpluginsdir _browserpluginsconfdir
103 syn keyword specMacroNameOther contained releq_kernel releq_kernel_up releq_kernel_smp requires_releq_kernel requires_releq_kernel_up requires_releq_kernel_smp
105 syn match specMacroNameOther contained '\<\(PATCH\|SOURCE\)\d*\>'
107 " valid _macro names from /usr/lib/rpm/macros*
108 syn keyword specMacroNameLocal contained _aclocaldir _applnkdir _arch _binary_payload _bindir _build _build_arch _build_alias
109 syn keyword specMacroNameLocal contained _build_cpu _builddir _build_os _buildshell _buildsubdir _build_vendor _bzip2bin _datadir
110 syn keyword specMacroNameLocal contained _dbpath _dbpath_rebuild _defaultdocdir _desktopdir _docdir _examplesdir _excludedocs _kdedocdir
111 syn keyword specMacroNameLocal contained _exec_prefix _fixgroup _fixowner _fixperms _fontsdir _ftpport _ftpproxy _gnu _gpg_name
112 syn keyword specMacroNameLocal contained _gpg_path _gtkdocdir _gzipbin _host _host_alias _host_cpu _host_os _host_vendor
113 syn keyword specMacroNameLocal contained _httpport _httpproxy _iconsdir _includedir _infodir _initrddir _install_langs
114 syn keyword specMacroNameLocal contained _install_script_path _instchangelog _javaclasspath _javadir _javadocdir _kernelsrcdir
115 syn keyword specMacroNameLocal contained _kernel_ver _kernel_ver_str _kernel_vermagic _langpatt _lib _libdir _libexecdir _localstatedir _mandir
116 syn keyword specMacroNameLocal contained _netsharedpath _oldincludedir _omf_dest_dir _os _package_version _pgpbin _pgp_name
117 syn keyword specMacroNameLocal contained _pgp_path _pixmapsdir _pkgconfigdir _prefix _preScriptEnvironment _provides _rpmdir
118 syn keyword specMacroNameLocal contained _rpmfilename _sbindir _sharedstatedir _signature _smp_mflags _sourcedir _source_payload
119 syn keyword specMacroNameLocal contained _specdir _srcrpmdir _sysconfdir _target _target_alias _target_cpu _target_os _target_platform
120 syn keyword specMacroNameLocal contained _target_vendor _target_base_arch _timecheck _tmppath _topdir _usr _usrsrc _var _vendor
121 syn keyword specMacroNameLocal contained __cxx __cc __ar __libtoolize __autopoint __aclocal __autoconf __automake __autoheader
122 syn keyword specMacroNameLocal contained __gettextize __glib_gettextize __intltoolize
123 syn keyword specMacroNameLocal contained __bzip2 __cat __chgrp __chmod __chown __cp __cpio __file __gpg __grep __gzip
124 syn keyword specMacroNameLocal contained __id __install __ld __make __mkdir __mkdir_p __mv __nm __objcopy __objdump
125 syn keyword specMacroNameLocal contained __patch __perl __pgp __python __rm __rsh __sed __ssh __strip __tar __unzip
129 " ------------------------------------------------------------------------------
130 " here's is all the spec sections definitions: PreAmble, Description, Package,
131 " Scripts, Files and Changelog
133 " One line macros - valid in all ScriptAreas
134 " tip: remember do include new items on specScriptArea's skip section
135 syn 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
136 syn region specSectionMacroBracketArea oneline matchgroup=specSectionMacro start='^%{\(configure2_13\|configure\|GNUconfigure\|find_lang\|makeinstall\|cmake\|scons\|waf\)}' end='$' contains=specCommandOpts,specMacroIdentifier
137 syn region specSectionMacroBcondArea oneline matchgroup=specBlock start='%{!\??\(with\(out\)\?_[a-zA-Z0-9_]\+\|debug\):' skip='\\}' end='}' contains=ALL
139 " %% Files Section %%
140 " TODO %config valid parameters: missingok\|noreplace
141 " TODO %verify valid parameters: \(not\)\= \(md5\|atime\|...\)
142 syn region specFilesArea matchgroup=specSection start="^%files\>"
143 \ skip="%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|verify\|ghost\|exclude\|dev\|if\|ifarch\|ifnarch\|else\|endif\)\>"
144 \ end='^%[a-zA-Z]'me=e-2
145 \ contains=specFilesOpts,specFilesDirective,@specListedFiles,specComment,specCommandSpecial,specMacroIdentifier,specSectionMacroBcondArea,specIf
147 " tip: remember to include new items in specFilesArea above
148 syn match specFilesDirective contained '%\(dir\|docdir\|doc\|ghost\|exclude\)\>'
149 syn region specFilesDirective contained start="%\(attrib\|attr\|defattr\|config\|lang\|verify\|dev\)(" end=")" contains=specAttr transparent
150 syn match specAttr contained "%\(attrib\|attr\|defattr\|config\|lang\|verify\|dev\)"
152 " valid options for certain section headers
153 syn match specDescriptionOpts contained '\s-[ln]\s\a'ms=s+1,me=e-1 contains=specDescriptionCharset
154 "syn match specDescriptionOptLang contained '\s-l\s*[a-zA-Z0-9.-]\+'ms=s+1
155 syn match specPackageOpts contained '\s-n\s*\w'ms=s+1,me=e-1
156 syn match specFilesOpts contained '\s-f\s*\w'ms=s+1,me=e-1
158 " charset: et,et.UTF-8,pl.UTF-8,pt_BR, ... etc
159 syn match specDescriptionCharset contained '-l\s[a-z_A-Z]\+\(\.UTF-8\)\?'ms=s+2
160 syn match specPreAmbleCharset contained '([a-z_A-Z]\+\(\.UTF-8\)\?):'
166 " %% PreAmble Section %%
167 " Copyright and Serial were deprecated by License and Epoch
168 " PreReq and BuildPreReq deprecated by Requires ans BuildRequires
169 syn region specPreAmbleDeprecated oneline matchgroup=specError start='^\(Copyright\|Serial\|PreReq\|BuildPreReq\(uires\)\?\)' end='$' contains=specEmail,specURL,specURLMacro,specLicense,specColon,specVariables,specSpecialChar,specMacroIdentifier
170 syn region specPreAmble oneline matchgroup=specPreambleField
171 \ start='\(^\|\(^%{!\??\(with\(out\)\?_[a-zA-Z0-9_]\+\|debug\):\)\@<=\)\(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\)'
173 \ contains=specEmail,specURL,specURLMacro,specLicense,specLicenseWarning,specColon,specVariables,specSpecialChar,specMacroIdentifier,specSectionMacroBcondArea
175 syn region specPreAmble oneline matchgroup=specPreambleField
176 \ start='\(Summary\)'
178 \ contains=specPreambleCharset
180 " %% Description Section %%
181 syn region specDescriptionArea matchgroup=specSection start='^%description' end='^%'me=e-1
182 \ contains=specDescriptionOpts,specEmail,specURL,specNumber,specMacroIdentifier,specComment
184 " %% Package Section %%
185 syn region specPackageArea matchgroup=specSection start='^%package' end='^%'me=e-1
186 \ contains=specPackageOpts,specPreAmble,specComment,specMacroNameOther
188 " %% Scripts Section %%
189 syn region specScriptArea matchgroup=specSection
190 \ start='^%\(prep\|build\|install\|clean\|pre\|postun\|preun\|post\|triggerin\|triggerun\|triggerpostun\|pretrans\|posttrans\|verifyscript\|check\)\>'
191 \ 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\|py_lint\|\(openldap_schema\|webapp\)_\(un\)\?register\|depmod\|pear_package_\(setup\|install\)\|\(build\|install\)_kernel_modules\|php_webserver_restart\|php4_webserver_restart\|update_browser_plugins\|gconf_schema_\(un\)?install\|scrollkeeper_update_post\(un\)?\|update_icon_cache\|update_mime_database\)\>'
193 \ contains=specSpecialVariables,specVariables,@specCommands,specVariables,shDo,shFor,shCaseEsac,specNoNumberHilite,specCommandOpts,shComment,shIf,specSpecialChar,specMacroIdentifier,specSectionMacroArea,specSectionMacroBracketArea,shOperator,shQuote1,shQuote2,specSectionMacroBcondArea
194 " XXX don't forget to update specMacro when updating specScriptArea skip definition
196 " %% Changelog Section %%
197 syn region specChangelogArea matchgroup=specSection start='^%changelog' end='^%'me=e-1
198 \ contains=specEmail,specURL,specWeekday,specMonth,specNumber,specComment,specLicense,specRevision,specLogMessage,specLogError
200 syn match specRevision contained "^Revision [.0-9]\+ [-/0-9]\+ [:0-9]\+ [a-zA-Z0-9]\+$"
201 syn region specLogMessage contained start="^[- ] " end="$" contains=specLogError,specURL,specEmail
202 syn match specLogError contained "%%"
204 " ------------------------------------------------------------------------------
205 " here's the shell syntax for all the Script Sections
211 " sh-like comment style, only valid in script part
212 syn match shComment contained '#.*$'
214 syn region shQuote1 contained matchgroup=shQuoteDelim start=+'+ skip=+\\'+ end=+'+ contains=specMacroIdentifier
215 syn region shQuote2 contained matchgroup=shQuoteDelim start=+"+ skip=+\\"+ end=+"+ contains=specVariables,specMacroIdentifier,specSectionMacroBcondArea
217 syn match shOperator contained '[><|!&;]\|[!=]='
218 syn region shDo transparent matchgroup=specBlock start="\(^\|\s\)do\(\s\|$\)" end="\(^\|\s\)done\(\s\|$\)" contains=ALLBUT,shDoError,shCase,specPreAmble,@specListedFiles
219 syn region shIf transparent matchgroup=specBlock start="\(^\|\s\)if\(\s\|$\)" end="\(^\|\s\)fi\(\s\|$\)" contains=ALLBUT,shIfError,shCase,@specListedFiles
221 syn region shFor matchgroup=specBlock start="\(^\|\s\)for\(\s\|$\)" end="\(^\|\s\)in\(\s\|$\)" contains=ALLBUT,shInError,shCase,@specListedFiles
223 syn region shCaseEsac transparent matchgroup=specBlock start="\(^\|\s\)case\(\s\|$\)" matchgroup=NONE end="\(^\|\s\)in\(\s\|$\)"me=s-1 contains=ALLBUT,@specListedFiles nextgroup=shCaseEsac
224 syn region shCaseEsac matchgroup=specBlock start="\(^\|\s\)in\(\s\|$\)" end="\(^\|\s\)esac\(\s\|$\)" contains=ALLBUT,@specListedFilesBin
225 syn region shCase matchgroup=specBlock contained start=")" end=";;" contains=ALLBUT,shCase,@specListedFiles
227 syn sync match shDoSync grouphere shDo "\<do\>"
228 syn sync match shDoSync groupthere shDo "\<done\>"
229 syn sync match shIfSync grouphere shIf "\<if\>"
230 syn sync match shIfSync groupthere shIf "\<fi\>"
231 syn sync match shForSync grouphere shFor "\<for\>"
232 syn sync match shForSync groupthere shFor "\<in\>"
233 syn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>"
234 syn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>"
236 syn region specIf matchgroup=specBlock start="%ifosf\|%ifos\|%ifnos\|%ifarch\|%ifnarch\|ifdef\|ifndef\|%if\|%else" end='%endif' contains=ALLBUT, specOutSkip, specOut2
239 if exists("spec_if0")
240 syn region specOut start="^\s*%if\s\+0$" end="$" contains=specOut2
241 syn region specOut2 contained start="%if\s\+0" end="^\s*%\(endif\>\|else\>\)" contains=specOutSkip
243 syn region specOutSkip contained start="^\s*%if\>" end="^\s*%endif\>" contains=specOutSkip
245 syn sync match specIfSync grouphere specIf "%ifarch\|%ifos\|%ifnos"
246 syn sync match specIfSync groupthere specIf "%endIf"
249 " Define the default highlighting.
250 " For version 5.7 and earlier: only when not done already
251 " For version 5.8 and later: only when an item doesn't have highlighting yet
252 if version >= 508 || !exists("did_spec_syntax_inits")
254 let did_spec_syntax_inits = 1
255 command -nargs=+ HiLink hi link <args>
257 command -nargs=+ HiLink hi def link <args>
260 "main types color definitions
261 HiLink specSection Structure
262 HiLink specSectionMacro Macro
263 HiLink specWWWlink PreProc
264 HiLink specOpts Operator
266 "yes, it's ugly, but white is sooo cool
267 if &background == "dark"
268 hi def specGlobalMacro ctermfg=white
270 HiLink specGlobalMacro Identifier
274 HiLink shComment Comment
275 HiLink shIf Statement
276 HiLink shOperator Special
277 HiLink shQuote1 String
278 HiLink shQuote2 String
279 HiLink shQuoteDelim Statement
282 HiLink specBlock Function
283 HiLink specBcond Function
284 HiLink specColon Special
285 HiLink specCommand Statement
286 HiLink specPreambleField Statement
287 HiLink specCommandOpts specOpts
288 HiLink specCommandSpecial Special
289 HiLink specComment Comment
290 HiLink specConfigure specCommand
291 HiLink specDate String
292 HiLink specPreAmbleCharset String
293 HiLink specDescriptionCharset String
294 HiLink specDescriptionOpts specOpts
295 HiLink specEmail specWWWlink
296 HiLink specError Error
297 HiLink specFilesDirective specSectionMacro
298 HiLink specAttr specSectionMacro
299 HiLink specFilesOpts specOpts
300 HiLink specLicense String
301 HiLink specLicenseWarning specError
302 HiLink specMacroNameLocal specGlobalMacro
303 HiLink specMacroNameOther specGlobalMacro
304 HiLink specManpageFile NONE
305 HiLink specMonth specDate
306 HiLink specNoNumberHilite NONE
307 HiLink specNumber Number
308 HiLink specPackageOpts specOpts
309 HiLink specPercent Special
310 HiLink specSpecialChar Special
311 HiLink specSubstChar Special
312 HiLink specSpecialVariables specGlobalMacro
313 HiLink specSpecialVariablesNames specGlobalMacro
314 HiLink specTarCommand specCommand
315 HiLink specMacro Macro
316 HiLink specURL specWWWlink
317 HiLink specURLMacro specWWWlink
318 HiLink specVariables Identifier
319 HiLink specWeekday specDate
320 HiLink specListedFilesBin Statement
321 HiLink specListedFilesDoc Statement
322 HiLink specListedFilesEtc Statement
323 HiLink specListedFilesLib Statement
324 HiLink specListedFilesPrefix Statement
325 HiLink specListedFilesShare Statement
327 HiLink specRevision Number
328 HiLink specLogMessage Identifier
329 HiLink specLogError Error
331 HiLink specOutSkip specOut
332 HiLink specOut2 specOut
333 HiLink specOut Comment
338 let b:current_syntax = "spec"