7
|
1 " Filename: spec.vim
|
|
2 " Purpose: Vim syntax file
|
|
3 " Language: SPEC: Build/install scripts for Linux RPM packages
|
5697
|
4 " Maintainer: Igor Gnatenko i.gnatenko.brain@gmail.com
|
|
5 " Former Maintainer: Donovan Rebbechi elflord@panix.com (until March 2014)
|
|
6 " Last Change: Sun Mar 2 10:33 MSK 2014 Igor Gnatenko
|
7
|
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
|
|
28 syn match specSpecialVariables contained '\$[0-9]\|\${[0-9]}'
|
|
29 syn match specCommandOpts contained '\s\(-\w\+\|--\w[a-zA-Z_-]\+\)'ms=s+1
|
|
30 syn match specComment '^\s*#.*$'
|
|
31
|
|
32
|
|
33 syn case match
|
|
34
|
|
35
|
|
36 "matches with no highlight
|
|
37 syn match specNoNumberHilite 'X11\|X11R6\|[a-zA-Z]*\.\d\|[a-zA-Z][-/]\d'
|
|
38 syn match specManpageFile '[a-zA-Z]\.1'
|
|
39
|
|
40 "Day, Month and most used license acronyms
|
|
41 syn keyword specLicense contained GPL LGPL BSD MIT GNU
|
|
42 syn keyword specWeekday contained Mon Tue Wed Thu Fri Sat Sun
|
|
43 syn keyword specMonth contained Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec
|
|
44 syn keyword specMonth contained January February March April May June July August September October November December
|
|
45
|
|
46 "#, @, www
|
|
47 syn match specNumber '\(^-\=\|[ \t]-\=\|-\)[0-9.-]*[0-9]'
|
|
48 syn match specEmail contained "<\=\<[A-Za-z0-9_.-]\+@\([A-Za-z0-9_-]\+\.\)\+[A-Za-z]\+\>>\="
|
|
49 syn match specURL contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#-]\+\>'
|
|
50 syn 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
|
|
54 syn match specListedFilesPrefix contained '/\(usr\|local\|opt\|X11R6\|X11\)/'me=e-1
|
|
55 syn match specListedFilesBin contained '/s\=bin/'me=e-1
|
|
56 syn match specListedFilesLib contained '/\(lib\|include\)/'me=e-1
|
|
57 syn match specListedFilesDoc contained '/\(man\d*\|doc\|info\)\>'
|
|
58 syn match specListedFilesEtc contained '/etc/'me=e-1
|
|
59 syn match specListedFilesShare contained '/share/'me=e-1
|
|
60 syn cluster specListedFiles contains=specListedFilesBin,specListedFilesLib,specListedFilesDoc,specListedFilesEtc,specListedFilesShare,specListedFilesPrefix,specVariables,specSpecialChar
|
|
61
|
|
62 "specComands
|
|
63 syn match specConfigure contained '\./configure'
|
|
64 syn match specTarCommand contained '\<tar\s\+[cxvpzIf]\{,5}\s*'
|
|
65 syn keyword specCommandSpecial contained root
|
|
66 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
|
|
67 syn cluster specCommands contains=specCommand,specTarCommand,specConfigure,specCommandSpecial
|
|
68
|
|
69 "frequently used rpm env vars
|
|
70 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
|
|
72 "valid macro names from /usr/lib/rpm/macros
|
|
73 syn keyword specMacroNameOther contained buildroot buildsubdir distribution disturl ix86 name nil optflags perl_sitearch release requires_eq vendor version
|
|
74 syn match specMacroNameOther contained '\<\(PATCH\|SOURCE\)\d*\>'
|
|
75
|
|
76 "valid _macro names from /usr/lib/rpm/macros
|
|
77 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
|
|
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
|
45
|
85 "tip: remember do include new items on specScriptArea's skip section
|
5697
|
86 syn region specSectionMacroArea oneline matchgroup=specSectionMacro start='^%\(define\|global\|patch\d*\|setup\|configure\|GNUconfigure\|find_lang\|makeinstall\|make_install\|include\)\>' end='$' contains=specCommandOpts,specMacroIdentifier
|
|
87 syn region specSectionMacroBracketArea oneline matchgroup=specSectionMacro start='^%{\(configure\|GNUconfigure\|find_lang\|makeinstall\|make_install\)}' end='$' contains=specCommandOpts,specMacroIdentifier
|
7
|
88
|
|
89 "%% Files Section %%
|
|
90 "TODO %config valid parameters: missingok\|noreplace
|
|
91 "TODO %verify valid parameters: \(not\)\= \(md5\|atime\|...\)
|
|
92 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
|
|
93 "tip: remember to include new itens in specFilesArea above
|
|
94 syn match specFilesDirective contained '%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|verify\|ghost\)\>'
|
|
95
|
|
96 "valid options for certain section headers
|
|
97 syn match specDescriptionOpts contained '\s-[ln]\s*\a'ms=s+1,me=e-1
|
|
98 syn match specPackageOpts contained '\s-n\s*\w'ms=s+1,me=e-1
|
|
99 syn match specFilesOpts contained '\s-f\s*\w'ms=s+1,me=e-1
|
|
100
|
|
101
|
|
102 syn case ignore
|
|
103
|
|
104
|
|
105 "%% PreAmble Section %%
|
|
106 "Copyright and Serial were deprecated by License and Epoch
|
|
107 syn region specPreAmbleDeprecated oneline matchgroup=specError start='^\(Copyright\|Serial\)' end='$' contains=specEmail,specURL,specURLMacro,specLicense,specColon,specVariables,specSpecialChar,specMacroIdentifier
|
|
108 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
|
|
110 "%% Description Section %%
|
|
111 syn region specDescriptionArea matchgroup=specSection start='^%description' end='^%'me=e-1 contains=specDescriptionOpts,specEmail,specURL,specNumber,specMacroIdentifier,specComment
|
|
112
|
|
113 "%% Package Section %%
|
|
114 syn region specPackageArea matchgroup=specSection start='^%package' end='^%'me=e-1 contains=specPackageOpts,specPreAmble,specComment
|
|
115
|
|
116 "%% Scripts Section %%
|
5697
|
117 syn region specScriptArea matchgroup=specSection start='^%\(prep\|build\|install\|clean\|pre\|postun\|preun\|post\|posttrans\)\>' skip='^%{\|^%\(define\|patch\d*\|configure\|GNUconfigure\|setup\|find_lang\|makeinstall\|make_install\)\>' end='^%'me=e-1 contains=specSpecialVariables,specVariables,@specCommands,specVariables,shDo,shFor,shCaseEsac,specNoNumberHilite,specCommandOpts,shComment,shIf,specSpecialChar,specMacroIdentifier,specSectionMacroArea,specSectionMacroBracketArea,shOperator,shQuote1,shQuote2
|
7
|
118
|
|
119 "%% Changelog Section %%
|
|
120 syn 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
|
|
128 syn case match
|
|
129
|
|
130
|
|
131 "sh-like comment stile, only valid in script part
|
|
132 syn match shComment contained '#.*$'
|
|
133
|
|
134 syn region shQuote1 contained matchgroup=shQuoteDelim start=+'+ skip=+\\'+ end=+'+ contains=specMacroIdentifier
|
|
135 syn region shQuote2 contained matchgroup=shQuoteDelim start=+"+ skip=+\\"+ end=+"+ contains=specVariables,specMacroIdentifier
|
|
136
|
|
137 syn match shOperator contained '[><|!&;]\|[!=]='
|
|
138 syn region shDo transparent matchgroup=specBlock start="\<do\>" end="\<done\>" contains=ALLBUT,shFunction,shDoError,shCase,specPreAmble,@specListedFiles
|
|
139
|
|
140 syn region specIf matchgroup=specBlock start="%ifosf\|%ifos\|%ifnos\|%ifarch\|%ifnarch\|%else" end='%endif' contains=ALLBUT, specIfError, shCase
|
|
141
|
|
142 syn region shIf transparent matchgroup=specBlock start="\<if\>" end="\<fi\>" contains=ALLBUT,shFunction,shIfError,shCase,@specListedFiles
|
|
143
|
|
144 syn region shFor matchgroup=specBlock start="\<for\>" end="\<in\>" contains=ALLBUT,shFunction,shInError,shCase,@specListedFiles
|
|
145
|
|
146 syn region shCaseEsac transparent matchgroup=specBlock start="\<case\>" matchgroup=NONE end="\<in\>"me=s-1 contains=ALLBUT,shFunction,shCaseError,@specListedFiles nextgroup=shCaseEsac
|
|
147 syn region shCaseEsac matchgroup=specBlock start="\<in\>" end="\<esac\>" contains=ALLBUT,shFunction,shCaseError,@specListedFilesBin
|
|
148 syn region shCase matchgroup=specBlock contained start=")" end=";;" contains=ALLBUT,shFunction,shCaseError,shCase,@specListedFiles
|
|
149
|
|
150 syn sync match shDoSync grouphere shDo "\<do\>"
|
|
151 syn sync match shDoSync groupthere shDo "\<done\>"
|
|
152 syn sync match shIfSync grouphere shIf "\<if\>"
|
|
153 syn sync match shIfSync groupthere shIf "\<fi\>"
|
|
154 syn sync match specIfSync grouphere specIf "%ifarch\|%ifos\|%ifnos"
|
|
155 syn sync match specIfSync groupthere specIf "%endIf"
|
|
156 syn sync match shForSync grouphere shFor "\<for\>"
|
|
157 syn sync match shForSync groupthere shFor "\<in\>"
|
|
158 syn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>"
|
|
159 syn 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
|
|
164 if 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
|
|
232 endif
|
|
233
|
|
234 let b:current_syntax = "spec"
|
|
235
|
|
236 " vim: ts=8
|