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