2 " Purpose: Vim syntax file
3 " Language: SPEC: Build/install scripts for Linux RPM packages
4 " Maintainer: Donovan Rebbechi elflord@panix.com
5 " Last Change: Fri Dec 3 11:54 EST 2004 Marcin Dalecki
7 " For version 5.x: Clear all syntax items
8 " For version 6.x: Quit when a syntax file was already loaded
11 elseif exists("b:current_syntax")
15 syn sync minlines=1000
17 syn match specSpecialChar contained '[][!$()\\|>^;:{}]'
18 syn match specColon contained ':'
19 syn match specPercent contained '%'
21 syn match specVariables contained '\$\h\w*' contains=specSpecialVariablesNames,specSpecialChar
22 syn match specVariables contained '\${\w*}' contains=specSpecialVariablesNames,specSpecialChar
24 syn match specMacroIdentifier contained '%\h\w*' contains=specMacroNameLocal,specMacroNameOther,specPercent
25 syn match specMacroIdentifier contained '%{\w*}' contains=specMacroNameLocal,specMacroNameOther,specPercent,specSpecialChar
27 syn match specSpecialVariables contained '\$[0-9]\|\${[0-9]}'
28 syn match specCommandOpts contained '\s\(-\w\+\|--\w[a-zA-Z_-]\+\)'ms=s+1
29 syn match specComment '^\s*#.*$'
35 "matches with no highlight
36 syn match specNoNumberHilite 'X11\|X11R6\|[a-zA-Z]*\.\d\|[a-zA-Z][-/]\d'
37 syn match specManpageFile '[a-zA-Z]\.1'
39 "Day, Month and most used license acronyms
40 syn keyword specLicense contained GPL LGPL BSD MIT GNU
41 syn keyword specWeekday contained Mon Tue Wed Thu Fri Sat Sun
42 syn keyword specMonth contained Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec
43 syn keyword specMonth contained January February March April May June July August September October November December
46 syn match specNumber '\(^-\=\|[ \t]-\=\|-\)[0-9.-]*[0-9]'
47 syn match specEmail contained "<\=\<[A-Za-z0-9_.-]\+@\([A-Za-z0-9_-]\+\.\)\+[A-Za-z]\+\>>\="
48 syn match specURL contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#-]\+\>'
49 syn match specURLMacro contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#%{}-]\+\>' contains=specMacroIdentifier
51 "TODO take specSpecialVariables out of the cluster for the sh* contains (ALLBUT)
52 "Special system directories
53 syn match specListedFilesPrefix contained '/\(usr\|local\|opt\|X11R6\|X11\)/'me=e-1
54 syn match specListedFilesBin contained '/s\=bin/'me=e-1
55 syn match specListedFilesLib contained '/\(lib\|include\)/'me=e-1
56 syn match specListedFilesDoc contained '/\(man\d*\|doc\|info\)\>'
57 syn match specListedFilesEtc contained '/etc/'me=e-1
58 syn match specListedFilesShare contained '/share/'me=e-1
59 syn cluster specListedFiles contains=specListedFilesBin,specListedFilesLib,specListedFilesDoc,specListedFilesEtc,specListedFilesShare,specListedFilesPrefix,specVariables,specSpecialChar
62 syn match specConfigure contained '\./configure'
63 syn match specTarCommand contained '\<tar\s\+[cxvpzIf]\{,5}\s*'
64 syn keyword specCommandSpecial contained root
65 syn keyword specCommand contained make xmkmf mkdir chmod ln find sed rm strip moc echo grep ls rm mv mkdir install cp pwd cat tail then else elif cd gzip rmdir ln eval export touch
66 syn cluster specCommands contains=specCommand,specTarCommand,specConfigure,specCommandSpecial
68 "frequently used rpm env vars
69 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
71 "valid macro names from /usr/lib/rpm/macros
72 syn keyword specMacroNameOther contained buildroot buildsubdir distribution disturl ix86 name nil optflags perl_sitearch release requires_eq vendor version
73 syn match specMacroNameOther contained '\<\(PATCH\|SOURCE\)\d*\>'
75 "valid _macro names from /usr/lib/rpm/macros
76 syn keyword specMacroNameLocal contained _arch _binary_payload _bindir _build _build_alias _build_cpu _builddir _build_os _buildshell _buildsubdir _build_vendor _bzip2bin _datadir _dbpath _dbpath_rebuild _defaultdocdir _docdir _excludedocs _exec_prefix _fixgroup _fixowner _fixperms _ftpport _ftpproxy _gpg_path _gzipbin _host _host_alias _host_cpu _host_os _host_vendor _httpport _httpproxy _includedir _infodir _install_langs _install_script_path _instchangelog _langpatt _lib _libdir _libexecdir _localstatedir _mandir _netsharedpath _oldincludedir _os _pgpbin _pgp_path _prefix _preScriptEnvironment _provides _rpmdir _rpmfilename _sbindir _sharedstatedir _signature _sourcedir _source_payload _specdir _srcrpmdir _sysconfdir _target _target_alias _target_cpu _target_os _target_platform _target_vendor _timecheck _tmppath _topdir _usr _usrsrc _var _vendor
79 "------------------------------------------------------------------------------
80 " here's is all the spec sections definitions: PreAmble, Description, Package,
81 " Scripts, Files and Changelog
83 "One line macros - valid in all ScriptAreas
84 "tip: remember do include new items on specScriptArea's skip section
85 syn region specSectionMacroArea oneline matchgroup=specSectionMacro start='^%\(define\|patch\d*\|setup\|configure\|GNUconfigure\|find_lang\|makeinstall\|include\)\>' end='$' contains=specCommandOpts,specMacroIdentifier
86 syn region specSectionMacroBracketArea oneline matchgroup=specSectionMacro start='^%{\(configure\|GNUconfigure\|find_lang\|makeinstall\)}' end='$' contains=specCommandOpts,specMacroIdentifier
89 "TODO %config valid parameters: missingok\|noreplace
90 "TODO %verify valid parameters: \(not\)\= \(md5\|atime\|...\)
91 syn region specFilesArea matchgroup=specSection start='^%[Ff][Ii][Ll][Ee][Ss]\>' skip='%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|verify\|ghost\)\>' end='^%[a-zA-Z]'me=e-2 contains=specFilesOpts,specFilesDirective,@specListedFiles,specComment,specCommandSpecial,specMacroIdentifier
92 "tip: remember to include new itens in specFilesArea above
93 syn match specFilesDirective contained '%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|verify\|ghost\)\>'
95 "valid options for certain section headers
96 syn match specDescriptionOpts contained '\s-[ln]\s*\a'ms=s+1,me=e-1
97 syn match specPackageOpts contained '\s-n\s*\w'ms=s+1,me=e-1
98 syn match specFilesOpts contained '\s-f\s*\w'ms=s+1,me=e-1
104 "%% PreAmble Section %%
105 "Copyright and Serial were deprecated by License and Epoch
106 syn region specPreAmbleDeprecated oneline matchgroup=specError start='^\(Copyright\|Serial\)' end='$' contains=specEmail,specURL,specURLMacro,specLicense,specColon,specVariables,specSpecialChar,specMacroIdentifier
107 syn region specPreAmble oneline matchgroup=specCommand start='^\(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\|AutoReq\|AutoReqProv\|AutoProv\|Epoch\)' end='$' contains=specEmail,specURL,specURLMacro,specLicense,specColon,specVariables,specSpecialChar,specMacroIdentifier
109 "%% Description Section %%
110 syn region specDescriptionArea matchgroup=specSection start='^%description' end='^%'me=e-1 contains=specDescriptionOpts,specEmail,specURL,specNumber,specMacroIdentifier,specComment
112 "%% Package Section %%
113 syn region specPackageArea matchgroup=specSection start='^%package' end='^%'me=e-1 contains=specPackageOpts,specPreAmble,specComment
115 "%% Scripts Section %%
116 syn region specScriptArea matchgroup=specSection start='^%\(prep\|build\|install\|clean\|pre\|postun\|preun\|post\)\>' skip='^%{\|^%\(define\|patch\d*\|configure\|GNUconfigure\|setup\|find_lang\|makeinstall\)\>' end='^%'me=e-1 contains=specSpecialVariables,specVariables,@specCommands,specVariables,shDo,shFor,shCaseEsac,specNoNumberHilite,specCommandOpts,shComment,shIf,specSpecialChar,specMacroIdentifier,specSectionMacroArea,specSectionMacroBracketArea,shOperator,shQuote1,shQuote2
118 "%% Changelog Section %%
119 syn region specChangelogArea matchgroup=specSection start='^%changelog' end='^%'me=e-1 contains=specEmail,specURL,specWeekday,specMonth,specNumber,specComment,specLicense
123 "------------------------------------------------------------------------------
124 "here's the shell syntax for all the Script Sections
130 "sh-like comment stile, only valid in script part
131 syn match shComment contained '#.*$'
133 syn region shQuote1 contained matchgroup=shQuoteDelim start=+'+ skip=+\\'+ end=+'+ contains=specMacroIdentifier
134 syn region shQuote2 contained matchgroup=shQuoteDelim start=+"+ skip=+\\"+ end=+"+ contains=specVariables,specMacroIdentifier
136 syn match shOperator contained '[><|!&;]\|[!=]='
137 syn region shDo transparent matchgroup=specBlock start="\<do\>" end="\<done\>" contains=ALLBUT,shFunction,shDoError,shCase,specPreAmble,@specListedFiles
139 syn region specIf matchgroup=specBlock start="%ifosf\|%ifos\|%ifnos\|%ifarch\|%ifnarch\|%else" end='%endif' contains=ALLBUT, specIfError, shCase
141 syn region shIf transparent matchgroup=specBlock start="\<if\>" end="\<fi\>" contains=ALLBUT,shFunction,shIfError,shCase,@specListedFiles
143 syn region shFor matchgroup=specBlock start="\<for\>" end="\<in\>" contains=ALLBUT,shFunction,shInError,shCase,@specListedFiles
145 syn region shCaseEsac transparent matchgroup=specBlock start="\<case\>" matchgroup=NONE end="\<in\>"me=s-1 contains=ALLBUT,shFunction,shCaseError,@specListedFiles nextgroup=shCaseEsac
146 syn region shCaseEsac matchgroup=specBlock start="\<in\>" end="\<esac\>" contains=ALLBUT,shFunction,shCaseError,@specListedFilesBin
147 syn region shCase matchgroup=specBlock contained start=")" end=";;" contains=ALLBUT,shFunction,shCaseError,shCase,@specListedFiles
149 syn sync match shDoSync grouphere shDo "\<do\>"
150 syn sync match shDoSync groupthere shDo "\<done\>"
151 syn sync match shIfSync grouphere shIf "\<if\>"
152 syn sync match shIfSync groupthere shIf "\<fi\>"
153 syn sync match specIfSync grouphere specIf "%ifarch\|%ifos\|%ifnos"
154 syn sync match specIfSync groupthere specIf "%endIf"
155 syn sync match shForSync grouphere shFor "\<for\>"
156 syn sync match shForSync groupthere shFor "\<in\>"
157 syn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>"
158 syn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>"
160 " Define the default highlighting.
161 " For version 5.7 and earlier: only when not done already
162 " For version 5.8 and later: only when an item doesn't have highlighting yet
163 if version >= 508 || !exists("did_spec_syntax_inits")
165 let did_spec_syntax_inits = 1
166 command -nargs=+ HiLink hi link <args>
168 command -nargs=+ HiLink hi def link <args>
171 "main types color definitions
172 HiLink specSection Structure
173 HiLink specSectionMacro Macro
174 HiLink specWWWlink PreProc
175 HiLink specOpts Operator
177 "yes, it's ugly, but white is sooo cool
178 if &background == "dark"
179 hi def specGlobalMacro ctermfg=white
181 HiLink specGlobalMacro Identifier
185 HiLink shComment Comment
186 HiLink shIf Statement
187 HiLink shOperator Special
188 HiLink shQuote1 String
189 HiLink shQuote2 String
190 HiLink shQuoteDelim Statement
193 HiLink specBlock Function
194 HiLink specColon Special
195 HiLink specCommand Statement
196 HiLink specCommandOpts specOpts
197 HiLink specCommandSpecial Special
198 HiLink specComment Comment
199 HiLink specConfigure specCommand
200 HiLink specDate String
201 HiLink specDescriptionOpts specOpts
202 HiLink specEmail specWWWlink
203 HiLink specError Error
204 HiLink specFilesDirective specSectionMacro
205 HiLink specFilesOpts specOpts
206 HiLink specLicense String
207 HiLink specMacroNameLocal specGlobalMacro
208 HiLink specMacroNameOther specGlobalMacro
209 HiLink specManpageFile NONE
210 HiLink specMonth specDate
211 HiLink specNoNumberHilite NONE
212 HiLink specNumber Number
213 HiLink specPackageOpts specOpts
214 HiLink specPercent Special
215 HiLink specSpecialChar Special
216 HiLink specSpecialVariables specGlobalMacro
217 HiLink specSpecialVariablesNames specGlobalMacro
218 HiLink specTarCommand specCommand
219 HiLink specURL specWWWlink
220 HiLink specURLMacro specWWWlink
221 HiLink specVariables Identifier
222 HiLink specWeekday specDate
223 HiLink specListedFilesBin Statement
224 HiLink specListedFilesDoc Statement
225 HiLink specListedFilesEtc Statement
226 HiLink specListedFilesLib Statement
227 HiLink specListedFilesPrefix Statement
228 HiLink specListedFilesShare Statement
233 let b:current_syntax = "spec"