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