]> git.pld-linux.org Git - packages/vim.git/blame - spec.vim
- Original file from vim 6.3 sources
[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
18syn match specSpecialChar contained '[][!$()\\|>^;:{}]'
19syn match specColon contained ':'
20syn match specPercent contained '%'
21
22syn match specVariables contained '\$\h\w*' contains=specSpecialVariablesNames,specSpecialChar
23syn match specVariables contained '\${\w*}' contains=specSpecialVariablesNames,specSpecialChar
24
25syn match specMacroIdentifier contained '%\h\w*' contains=specMacroNameLocal,specMacroNameOther,specPercent
26syn match specMacroIdentifier contained '%{\w*}' contains=specMacroNameLocal,specMacroNameOther,specPercent,specSpecialChar
27
28syn match specSpecialVariables contained '\$[0-9]\|\${[0-9]}'
29syn match specCommandOpts contained '\s\(-\w\+\|--\w[a-zA-Z_-]\+\)'ms=s+1
30syn match specComment '^\s*#.*$'
31
32
33syn case match
34
35
36"matches with no highlight
37syn match specNoNumberHilite 'X11\|X11R6\|[a-zA-Z]*\.\d\|[a-zA-Z][-/]\d'
38syn match specManpageFile '[a-zA-Z]\.1'
39
40"Day, Month and most used license acronyms
41syn keyword specLicense contained GPL LGPL BSD MIT GNU
42syn keyword specWeekday contained Mon Tue Wed Thu Fri Sat Sun
43syn keyword specMonth contained Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec
44syn keyword specMonth contained January February March April May June July August September October November December
45
46"#, @, www
47syn match specNumber '\(^-\=\|[ \t]-\=\|-\)[0-9.-]*[0-9]'
48syn match specEmail contained "<\=\<[A-Za-z0-9_.-]\+@\([A-Za-z0-9_-]\+\.\)\+[A-Za-z]\+\>>\="
49syn match specURL contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#-]\+\>'
50syn match specURLMacro contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#%{}-]\+\>' contains=specMacroIdentifier
51
52"TODO take specSpecialVariables out of the cluster for the sh* contains (ALLBUT)
53"Special system directories
54syn match specListedFilesPrefix contained '/\(usr\|local\|opt\|X11R6\|X11\)/'me=e-1
55syn match specListedFilesBin contained '/s\=bin/'me=e-1
56syn match specListedFilesLib contained '/\(lib\|include\)/'me=e-1
57syn match specListedFilesDoc contained '/\(man\d*\|doc\|info\)\>'
58syn match specListedFilesEtc contained '/etc/'me=e-1
59syn match specListedFilesShare contained '/share/'me=e-1
60syn cluster specListedFiles contains=specListedFilesBin,specListedFilesLib,specListedFilesDoc,specListedFilesEtc,specListedFilesShare,specListedFilesPrefix,specVariables,specSpecialChar
61
62"specComands
63syn match specConfigure contained '\./configure'
64syn match specTarCommand contained '\<tar\s\+[cxvpzIf]\{,5}\s*'
65syn keyword specCommandSpecial contained root
66syn 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
67syn cluster specCommands contains=specCommand,specTarCommand,specConfigure,specCommandSpecial
68
69"frequently used rpm env vars
70syn 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
72"valid macro names from /usr/lib/rpm/macros
73syn keyword specMacroNameOther contained buildroot buildsubdir distribution disturl ix86 name nil optflags perl_sitearch release requires_eq vendor version
74syn match specMacroNameOther contained '\<\(PATCH\|SOURCE\)\d*\>'
75
76"valid _macro names from /usr/lib/rpm/macros
77syn 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
78
79
80"------------------------------------------------------------------------------
81" here's is all the spec sections definitions: PreAmble, Description, Package,
82" Scripts, Files and Changelog
83
84"One line macros - valid in all ScriptAreas
85"tip: remember do include new itens on specScriptArea's skip section
86syn region specSectionMacroArea oneline matchgroup=specSectionMacro start='^%\(define\|patch\d*\|setup\|configure\|GNUconfigure\|find_lang\|makeinstall\)\>' end='$' contains=specCommandOpts,specMacroIdentifier
87syn region specSectionMacroBracketArea oneline matchgroup=specSectionMacro start='^%{\(configure\|GNUconfigure\|find_lang\|makeinstall\)}' end='$' contains=specCommandOpts,specMacroIdentifier
88
89"%% Files Section %%
90"TODO %config valid parameters: missingok\|noreplace
91"TODO %verify valid parameters: \(not\)\= \(md5\|atime\|...\)
92syn 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
93"tip: remember to include new itens in specFilesArea above
94syn match specFilesDirective contained '%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|verify\|ghost\)\>'
95
96"valid options for certain section headers
97syn match specDescriptionOpts contained '\s-[ln]\s*\a'ms=s+1,me=e-1
98syn match specPackageOpts contained '\s-n\s*\w'ms=s+1,me=e-1
99syn match specFilesOpts contained '\s-f\s*\w'ms=s+1,me=e-1
100
101
102syn case ignore
103
104
105"%% PreAmble Section %%
106"Copyright and Serial were deprecated by License and Epoch
107syn region specPreAmbleDeprecated oneline matchgroup=specError start='^\(Copyright\|Serial\)' end='$' contains=specEmail,specURL,specURLMacro,specLicense,specColon,specVariables,specSpecialChar,specMacroIdentifier
108syn 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
110"%% Description Section %%
111syn region specDescriptionArea matchgroup=specSection start='^%description' end='^%'me=e-1 contains=specDescriptionOpts,specEmail,specURL,specNumber,specMacroIdentifier,specComment
112
113"%% Package Section %%
114syn region specPackageArea matchgroup=specSection start='^%package' end='^%'me=e-1 contains=specPackageOpts,specPreAmble,specComment
115
116"%% Scripts Section %%
117syn 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
119"%% Changelog Section %%
120syn region specChangelogArea matchgroup=specSection start='^%changelog' end='^%'me=e-1 contains=specEmail,specURL,specWeekday,specMonth,specNumber,specComment,specLicense
121
122
123
124"------------------------------------------------------------------------------
125"here's the shell syntax for all the Script Sections
126
127
128syn case match
129
130
131"sh-like comment stile, only valid in script part
132syn match shComment contained '#.*$'
133
134syn region shQuote1 contained matchgroup=shQuoteDelim start=+'+ skip=+\\'+ end=+'+ contains=specMacroIdentifier
135syn region shQuote2 contained matchgroup=shQuoteDelim start=+"+ skip=+\\"+ end=+"+ contains=specVariables,specMacroIdentifier
136
137syn match shOperator contained '[><|!&;]\|[!=]='
138syn region shDo transparent matchgroup=specBlock start="\<do\>" end="\<done\>" contains=ALLBUT,shFunction,shDoError,shCase,specPreAmble,@specListedFiles
139
140syn region specIf matchgroup=specBlock start="%ifosf\|%ifos\|%ifnos\|%ifarch\|%ifnarch\|%else" end='%endif' contains=ALLBUT, specIfError, shCase
141
142syn region shIf transparent matchgroup=specBlock start="\<if\>" end="\<fi\>" contains=ALLBUT,shFunction,shIfError,shCase,@specListedFiles
143
144syn region shFor matchgroup=specBlock start="\<for\>" end="\<in\>" contains=ALLBUT,shFunction,shInError,shCase,@specListedFiles
145
146syn region shCaseEsac transparent matchgroup=specBlock start="\<case\>" matchgroup=NONE end="\<in\>"me=s-1 contains=ALLBUT,shFunction,shCaseError,@specListedFiles nextgroup=shCaseEsac
147syn region shCaseEsac matchgroup=specBlock start="\<in\>" end="\<esac\>" contains=ALLBUT,shFunction,shCaseError,@specListedFilesBin
148syn region shCase matchgroup=specBlock contained start=")" end=";;" contains=ALLBUT,shFunction,shCaseError,shCase,@specListedFiles
149
150syn sync match shDoSync grouphere shDo "\<do\>"
151syn sync match shDoSync groupthere shDo "\<done\>"
152syn sync match shIfSync grouphere shIf "\<if\>"
153syn sync match shIfSync groupthere shIf "\<fi\>"
154syn sync match specIfSync grouphere specIf "%ifarch\|%ifos\|%ifnos"
155syn sync match specIfSync groupthere specIf "%endIf"
156syn sync match shForSync grouphere shFor "\<for\>"
157syn sync match shForSync groupthere shFor "\<in\>"
158syn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>"
159syn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>"
160
161" Define the default highlighting.
162" For version 5.7 and earlier: only when not done already
163" For version 5.8 and later: only when an item doesn't have highlighting yet
164if version >= 508 || !exists("did_spec_syntax_inits")
165 if version < 508
166 let did_spec_syntax_inits = 1
167 command -nargs=+ HiLink hi link <args>
168 else
169 command -nargs=+ HiLink hi def link <args>
170 endif
171
172 "main types color definitions
173 HiLink specSection Structure
174 HiLink specSectionMacro Macro
175 HiLink specWWWlink PreProc
176 HiLink specOpts Operator
177
178 "yes, it's ugly, but white is sooo cool
179 if &background == "dark"
180 hi def specGlobalMacro ctermfg=white
181 else
182 HiLink specGlobalMacro Identifier
183 endif
184
185 "sh colors
186 HiLink shComment Comment
187 HiLink shIf Statement
188 HiLink shOperator Special
189 HiLink shQuote1 String
190 HiLink shQuote2 String
191 HiLink shQuoteDelim Statement
192
193 "spec colors
194 HiLink specBlock Function
195 HiLink specColon Special
196 HiLink specCommand Statement
197 HiLink specCommandOpts specOpts
198 HiLink specCommandSpecial Special
199 HiLink specComment Comment
200 HiLink specConfigure specCommand
201 HiLink specDate String
202 HiLink specDescriptionOpts specOpts
203 HiLink specEmail specWWWlink
204 HiLink specError Error
205 HiLink specFilesDirective specSectionMacro
206 HiLink specFilesOpts specOpts
207 HiLink specLicense String
208 HiLink specMacroNameLocal specGlobalMacro
209 HiLink specMacroNameOther specGlobalMacro
210 HiLink specManpageFile NONE
211 HiLink specMonth specDate
212 HiLink specNoNumberHilite NONE
213 HiLink specNumber Number
214 HiLink specPackageOpts specOpts
215 HiLink specPercent Special
216 HiLink specSpecialChar Special
217 HiLink specSpecialVariables specGlobalMacro
218 HiLink specSpecialVariablesNames specGlobalMacro
219 HiLink specTarCommand specCommand
220 HiLink specURL specWWWlink
221 HiLink specURLMacro specWWWlink
222 HiLink specVariables Identifier
223 HiLink specWeekday specDate
224 HiLink specListedFilesBin Statement
225 HiLink specListedFilesDoc Statement
226 HiLink specListedFilesEtc Statement
227 HiLink specListedFilesLib Statement
228 HiLink specListedFilesPrefix Statement
229 HiLink specListedFilesShare Statement
230
231 delcommand HiLink
232endif
233
234let b:current_syntax = "spec"
235
236" vim: ts=8
This page took 0.074709 seconds and 4 git commands to generate.