xref: /vim-8.2.3635/runtime/syntax/spec.vim (revision 388a5d4f)
1071d4279SBram Moolenaar" Filename:    spec.vim
2071d4279SBram Moolenaar" Purpose:     Vim syntax file
3071d4279SBram Moolenaar" Language:    SPEC: Build/install scripts for Linux RPM packages
40858917eSBram Moolenaar" Maintainer:  Igor Gnatenko [email protected]
50858917eSBram Moolenaar" Former Maintainer:  Donovan Rebbechi [email protected] (until March 2014)
6*388a5d4fSBram Moolenaar" Last Change: 2020 May 25
7071d4279SBram Moolenaar
889bcfda6SBram Moolenaar" quit when a syntax file was already loaded
989bcfda6SBram Moolenaarif exists("b:current_syntax")
10071d4279SBram Moolenaar  finish
11071d4279SBram Moolenaarendif
12071d4279SBram Moolenaar
13071d4279SBram Moolenaarsyn sync minlines=1000
14071d4279SBram Moolenaar
15071d4279SBram Moolenaarsyn match specSpecialChar contained '[][!$()\\|>^;:{}]'
16071d4279SBram Moolenaarsyn match specColon       contained ':'
17071d4279SBram Moolenaarsyn match specPercent     contained '%'
18071d4279SBram Moolenaar
19071d4279SBram Moolenaarsyn match specVariables   contained '\$\h\w*' contains=specSpecialVariablesNames,specSpecialChar
20071d4279SBram Moolenaarsyn match specVariables   contained '\${\w*}' contains=specSpecialVariablesNames,specSpecialChar
21071d4279SBram Moolenaar
22071d4279SBram Moolenaarsyn match specMacroIdentifier contained '%\h\w*' contains=specMacroNameLocal,specMacroNameOther,specPercent
23071d4279SBram Moolenaarsyn match specMacroIdentifier contained '%{\w*}' contains=specMacroNameLocal,specMacroNameOther,specPercent,specSpecialChar
24071d4279SBram Moolenaar
25071d4279SBram Moolenaarsyn match specSpecialVariables contained '\$[0-9]\|\${[0-9]}'
26071d4279SBram Moolenaarsyn match specCommandOpts      contained '\s\(-\w\+\|--\w[a-zA-Z_-]\+\)'ms=s+1
27071d4279SBram Moolenaarsyn match specComment '^\s*#.*$'
28071d4279SBram Moolenaar
29071d4279SBram Moolenaar
30071d4279SBram Moolenaarsyn case match
31071d4279SBram Moolenaar
32071d4279SBram Moolenaar
33071d4279SBram Moolenaar"matches with no highlight
34071d4279SBram Moolenaarsyn match specNoNumberHilite 'X11\|X11R6\|[a-zA-Z]*\.\d\|[a-zA-Z][-/]\d'
35071d4279SBram Moolenaarsyn match specManpageFile '[a-zA-Z]\.1'
36071d4279SBram Moolenaar
37071d4279SBram Moolenaar"Day, Month and most used license acronyms
38071d4279SBram Moolenaarsyn keyword specLicense contained GPL LGPL BSD MIT GNU
39071d4279SBram Moolenaarsyn keyword specWeekday contained Mon Tue Wed Thu Fri Sat Sun
40071d4279SBram Moolenaarsyn keyword specMonth   contained Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec
41071d4279SBram Moolenaarsyn keyword specMonth   contained January February March April May June July August September October November December
42071d4279SBram Moolenaar
43071d4279SBram Moolenaar"#, @, www
44071d4279SBram Moolenaarsyn match specNumber '\(^-\=\|[ \t]-\=\|-\)[0-9.-]*[0-9]'
45071d4279SBram Moolenaarsyn match specEmail contained "<\=\<[A-Za-z0-9_.-]\+@\([A-Za-z0-9_-]\+\.\)\+[A-Za-z]\+\>>\="
46071d4279SBram Moolenaarsyn match specURL      contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#-]\+\>'
47071d4279SBram Moolenaarsyn match specURLMacro contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#%{}-]\+\>' contains=specMacroIdentifier
48071d4279SBram Moolenaar
49071d4279SBram Moolenaar"TODO take specSpecialVariables out of the cluster for the sh* contains (ALLBUT)
50071d4279SBram Moolenaar"Special system directories
51071d4279SBram Moolenaarsyn match specListedFilesPrefix contained '/\(usr\|local\|opt\|X11R6\|X11\)/'me=e-1
52071d4279SBram Moolenaarsyn match specListedFilesBin    contained '/s\=bin/'me=e-1
53071d4279SBram Moolenaarsyn match specListedFilesLib    contained '/\(lib\|include\)/'me=e-1
54071d4279SBram Moolenaarsyn match specListedFilesDoc    contained '/\(man\d*\|doc\|info\)\>'
55071d4279SBram Moolenaarsyn match specListedFilesEtc    contained '/etc/'me=e-1
56071d4279SBram Moolenaarsyn match specListedFilesShare  contained '/share/'me=e-1
57071d4279SBram Moolenaarsyn cluster specListedFiles contains=specListedFilesBin,specListedFilesLib,specListedFilesDoc,specListedFilesEtc,specListedFilesShare,specListedFilesPrefix,specVariables,specSpecialChar
58071d4279SBram Moolenaar
59071d4279SBram Moolenaar"specComands
60071d4279SBram Moolenaarsyn match   specConfigure  contained '\./configure'
61071d4279SBram Moolenaarsyn match   specTarCommand contained '\<tar\s\+[cxvpzIf]\{,5}\s*'
62071d4279SBram Moolenaarsyn keyword specCommandSpecial contained root
63071d4279SBram Moolenaarsyn 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
64071d4279SBram Moolenaarsyn cluster specCommands contains=specCommand,specTarCommand,specConfigure,specCommandSpecial
65071d4279SBram Moolenaar
66071d4279SBram Moolenaar"frequently used rpm env vars
67071d4279SBram Moolenaarsyn keyword specSpecialVariablesNames contained RPM_BUILD_ROOT RPM_BUILD_DIR RPM_SOURCE_DIR RPM_OPT_FLAGS LDFLAGS CC CC_FLAGS CPPNAME CFLAGS CXX CXXFLAGS CPPFLAGS
68071d4279SBram Moolenaar
69071d4279SBram Moolenaar"valid macro names from /usr/lib/rpm/macros
70071d4279SBram Moolenaarsyn keyword specMacroNameOther contained buildroot buildsubdir distribution disturl ix86 name nil optflags perl_sitearch release requires_eq vendor version
71071d4279SBram Moolenaarsyn match   specMacroNameOther contained '\<\(PATCH\|SOURCE\)\d*\>'
72071d4279SBram Moolenaar
73071d4279SBram Moolenaar"valid _macro names from /usr/lib/rpm/macros
745be4ceecSBram Moolenaarsyn 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 _unitdir _usrsrc _var _vendor
75071d4279SBram Moolenaar
76071d4279SBram Moolenaar
77071d4279SBram Moolenaar"------------------------------------------------------------------------------
78071d4279SBram Moolenaar" here's is all the spec sections definitions: PreAmble, Description, Package,
79071d4279SBram Moolenaar"   Scripts, Files and Changelog
80071d4279SBram Moolenaar
81071d4279SBram Moolenaar"One line macros - valid in all ScriptAreas
82def9e829SBram Moolenaar"tip: remember do include new items on specScriptArea's skip section
8382af8710SBram Moolenaarsyn region specSectionMacroArea oneline matchgroup=specSectionMacro start='^%\(define\|global\|patch\d*\|setup\|autosetup\|autopatch\|configure\|GNUconfigure\|find_lang\|make_build\|makeinstall\|make_install\|include\)\>' end='$' contains=specCommandOpts,specMacroIdentifier
8482af8710SBram Moolenaarsyn region specSectionMacroBracketArea oneline matchgroup=specSectionMacro start='^%{\(configure\|GNUconfigure\|find_lang\|make_build\|makeinstall\|make_install\)}' end='$' contains=specCommandOpts,specMacroIdentifier
85071d4279SBram Moolenaar
86071d4279SBram Moolenaar"%% Files Section %%
87071d4279SBram Moolenaar"TODO %config valid parameters: missingok\|noreplace
88071d4279SBram Moolenaar"TODO %verify valid parameters: \(not\)\= \(md5\|atime\|...\)
89a6c27c47SBram Moolenaarsyn region specFilesArea matchgroup=specSection start='^%[Ff][Ii][Ll][Ee][Ss]\>' skip='%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|license\|verify\|ghost\|exclude\)\>' end='^%[a-zA-Z]'me=e-2 contains=specFilesOpts,specFilesDirective,@specListedFiles,specComment,specCommandSpecial,specMacroIdentifier
90071d4279SBram Moolenaar"tip: remember to include new itens in specFilesArea above
91a6c27c47SBram Moolenaarsyn match  specFilesDirective contained '%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|license\|verify\|ghost\|exclude\)\>'
92071d4279SBram Moolenaar
93071d4279SBram Moolenaar"valid options for certain section headers
94071d4279SBram Moolenaarsyn match specDescriptionOpts contained '\s-[ln]\s*\a'ms=s+1,me=e-1
95071d4279SBram Moolenaarsyn match specPackageOpts     contained    '\s-n\s*\w'ms=s+1,me=e-1
96071d4279SBram Moolenaarsyn match specFilesOpts       contained    '\s-f\s*\w'ms=s+1,me=e-1
97071d4279SBram Moolenaar
98071d4279SBram Moolenaar
99071d4279SBram Moolenaarsyn case ignore
100071d4279SBram Moolenaar
101071d4279SBram Moolenaar
102071d4279SBram Moolenaar"%% PreAmble Section %%
103071d4279SBram Moolenaar"Copyright and Serial were deprecated by License and Epoch
104071d4279SBram Moolenaarsyn region specPreAmbleDeprecated oneline matchgroup=specError start='^\(Copyright\|Serial\)' end='$' contains=specEmail,specURL,specURLMacro,specLicense,specColon,specVariables,specSpecialChar,specMacroIdentifier
10582af8710SBram Moolenaarsyn region specPreAmble oneline matchgroup=specCommand start='^\(Prereq\|Summary\|Name\|Version\|Packager\|Requires\|Recommends\|Suggests\|Supplements\|Enhances\|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
106071d4279SBram Moolenaar
107071d4279SBram Moolenaar"%% Description Section %%
108071d4279SBram Moolenaarsyn region specDescriptionArea matchgroup=specSection start='^%description' end='^%'me=e-1 contains=specDescriptionOpts,specEmail,specURL,specNumber,specMacroIdentifier,specComment
109071d4279SBram Moolenaar
110071d4279SBram Moolenaar"%% Package Section %%
111071d4279SBram Moolenaarsyn region specPackageArea matchgroup=specSection start='^%package' end='^%'me=e-1 contains=specPackageOpts,specPreAmble,specComment
112071d4279SBram Moolenaar
113071d4279SBram Moolenaar"%% Scripts Section %%
114ebdf3c96SBram Moolenaarsyn region specScriptArea matchgroup=specSection start='^%\(prep\|build\|install\|clean\|check\|pre\|postun\|preun\|post\|posttrans\)\>' skip='^%{\|^%\(define\|patch\d*\|configure\|GNUconfigure\|setup\|autosetup\|autopatch\|find_lang\|make_build\|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
115071d4279SBram Moolenaar
116071d4279SBram Moolenaar"%% Changelog Section %%
117071d4279SBram Moolenaarsyn region specChangelogArea matchgroup=specSection start='^%changelog' end='^%'me=e-1 contains=specEmail,specURL,specWeekday,specMonth,specNumber,specComment,specLicense
118071d4279SBram Moolenaar
119071d4279SBram Moolenaar
120071d4279SBram Moolenaar
121071d4279SBram Moolenaar"------------------------------------------------------------------------------
122071d4279SBram Moolenaar"here's the shell syntax for all the Script Sections
123071d4279SBram Moolenaar
124071d4279SBram Moolenaar
125071d4279SBram Moolenaarsyn case match
126071d4279SBram Moolenaar
127071d4279SBram Moolenaar
128071d4279SBram Moolenaar"sh-like comment stile, only valid in script part
129071d4279SBram Moolenaarsyn match shComment contained '#.*$'
130071d4279SBram Moolenaar
131*388a5d4fSBram Moolenaarsyn region dnlComment matchgroup=specComment start=+%dnl+ end=+$+
132*388a5d4fSBram Moolenaar
133071d4279SBram Moolenaarsyn region shQuote1 contained matchgroup=shQuoteDelim start=+'+ skip=+\\'+ end=+'+ contains=specMacroIdentifier
134071d4279SBram Moolenaarsyn region shQuote2 contained matchgroup=shQuoteDelim start=+"+ skip=+\\"+ end=+"+ contains=specVariables,specMacroIdentifier
135071d4279SBram Moolenaar
136071d4279SBram Moolenaarsyn match shOperator contained '[><|!&;]\|[!=]='
137071d4279SBram Moolenaarsyn region shDo transparent matchgroup=specBlock start="\<do\>" end="\<done\>" contains=ALLBUT,shFunction,shDoError,shCase,specPreAmble,@specListedFiles
138071d4279SBram Moolenaar
139071d4279SBram Moolenaarsyn region specIf  matchgroup=specBlock start="%ifosf\|%ifos\|%ifnos\|%ifarch\|%ifnarch\|%else"  end='%endif'  contains=ALLBUT, specIfError, shCase
140071d4279SBram Moolenaar
141071d4279SBram Moolenaarsyn region  shIf transparent matchgroup=specBlock start="\<if\>" end="\<fi\>" contains=ALLBUT,shFunction,shIfError,shCase,@specListedFiles
142071d4279SBram Moolenaar
143071d4279SBram Moolenaarsyn region  shFor  matchgroup=specBlock start="\<for\>" end="\<in\>" contains=ALLBUT,shFunction,shInError,shCase,@specListedFiles
144071d4279SBram Moolenaar
145071d4279SBram Moolenaarsyn region shCaseEsac transparent matchgroup=specBlock start="\<case\>" matchgroup=NONE end="\<in\>"me=s-1 contains=ALLBUT,shFunction,shCaseError,@specListedFiles nextgroup=shCaseEsac
146071d4279SBram Moolenaarsyn region shCaseEsac matchgroup=specBlock start="\<in\>" end="\<esac\>" contains=ALLBUT,shFunction,shCaseError,@specListedFilesBin
147071d4279SBram Moolenaarsyn region shCase matchgroup=specBlock contained start=")"  end=";;" contains=ALLBUT,shFunction,shCaseError,shCase,@specListedFiles
148071d4279SBram Moolenaar
149071d4279SBram Moolenaarsyn sync match shDoSync       grouphere  shDo       "\<do\>"
150071d4279SBram Moolenaarsyn sync match shDoSync       groupthere shDo       "\<done\>"
151071d4279SBram Moolenaarsyn sync match shIfSync       grouphere  shIf       "\<if\>"
152071d4279SBram Moolenaarsyn sync match shIfSync       groupthere shIf       "\<fi\>"
153071d4279SBram Moolenaarsyn sync match specIfSync     grouphere  specIf     "%ifarch\|%ifos\|%ifnos"
154071d4279SBram Moolenaarsyn sync match specIfSync     groupthere specIf     "%endIf"
155071d4279SBram Moolenaarsyn sync match shForSync      grouphere  shFor      "\<for\>"
156071d4279SBram Moolenaarsyn sync match shForSync      groupthere shFor      "\<in\>"
157071d4279SBram Moolenaarsyn sync match shCaseEsacSync grouphere  shCaseEsac "\<case\>"
158071d4279SBram Moolenaarsyn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>"
159071d4279SBram Moolenaar
160071d4279SBram Moolenaar" Define the default highlighting.
16189bcfda6SBram Moolenaar" Only when an item doesn't have highlighting yet
162071d4279SBram Moolenaar
163071d4279SBram Moolenaar"main types color definitions
164f37506f6SBram Moolenaarhi def link specSection			Structure
165f37506f6SBram Moolenaarhi def link specSectionMacro		Macro
166f37506f6SBram Moolenaarhi def link specWWWlink			PreProc
167f37506f6SBram Moolenaarhi def link specOpts			Operator
168071d4279SBram Moolenaar
169071d4279SBram Moolenaar"yes, it's ugly, but white is sooo cool
170071d4279SBram Moolenaarif &background == "dark"
171071d4279SBram Moolenaarhi def specGlobalMacro		ctermfg=white
172071d4279SBram Moolenaarelse
173f37506f6SBram Moolenaarhi def link specGlobalMacro		Identifier
174071d4279SBram Moolenaarendif
175071d4279SBram Moolenaar
176071d4279SBram Moolenaar"sh colors
177f37506f6SBram Moolenaarhi def link shComment			Comment
178*388a5d4fSBram Moolenaarhi def link dnlComment			Comment
179f37506f6SBram Moolenaarhi def link shIf				Statement
180f37506f6SBram Moolenaarhi def link shOperator			Special
181f37506f6SBram Moolenaarhi def link shQuote1			String
182f37506f6SBram Moolenaarhi def link shQuote2			String
183f37506f6SBram Moolenaarhi def link shQuoteDelim			Statement
184071d4279SBram Moolenaar
185071d4279SBram Moolenaar"spec colors
186f37506f6SBram Moolenaarhi def link specBlock			Function
187f37506f6SBram Moolenaarhi def link specColon			Special
188f37506f6SBram Moolenaarhi def link specCommand			Statement
189f37506f6SBram Moolenaarhi def link specCommandOpts		specOpts
190f37506f6SBram Moolenaarhi def link specCommandSpecial		Special
191f37506f6SBram Moolenaarhi def link specComment			Comment
192f37506f6SBram Moolenaarhi def link specConfigure			specCommand
193f37506f6SBram Moolenaarhi def link specDate			String
194f37506f6SBram Moolenaarhi def link specDescriptionOpts		specOpts
195f37506f6SBram Moolenaarhi def link specEmail			specWWWlink
196f37506f6SBram Moolenaarhi def link specError			Error
197f37506f6SBram Moolenaarhi def link specFilesDirective		specSectionMacro
198f37506f6SBram Moolenaarhi def link specFilesOpts			specOpts
199f37506f6SBram Moolenaarhi def link specLicense			String
200f37506f6SBram Moolenaarhi def link specMacroNameLocal		specGlobalMacro
201f37506f6SBram Moolenaarhi def link specMacroNameOther		specGlobalMacro
202f37506f6SBram Moolenaarhi def link specManpageFile		NONE
203f37506f6SBram Moolenaarhi def link specMonth			specDate
204f37506f6SBram Moolenaarhi def link specNoNumberHilite		NONE
205f37506f6SBram Moolenaarhi def link specNumber			Number
206f37506f6SBram Moolenaarhi def link specPackageOpts		specOpts
207f37506f6SBram Moolenaarhi def link specPercent			Special
208f37506f6SBram Moolenaarhi def link specSpecialChar		Special
209f37506f6SBram Moolenaarhi def link specSpecialVariables		specGlobalMacro
210f37506f6SBram Moolenaarhi def link specSpecialVariablesNames	specGlobalMacro
211f37506f6SBram Moolenaarhi def link specTarCommand			specCommand
212f37506f6SBram Moolenaarhi def link specURL			specWWWlink
213f37506f6SBram Moolenaarhi def link specURLMacro			specWWWlink
214f37506f6SBram Moolenaarhi def link specVariables			Identifier
215f37506f6SBram Moolenaarhi def link specWeekday			specDate
216f37506f6SBram Moolenaarhi def link specListedFilesBin		Statement
217f37506f6SBram Moolenaarhi def link specListedFilesDoc		Statement
218f37506f6SBram Moolenaarhi def link specListedFilesEtc		Statement
219f37506f6SBram Moolenaarhi def link specListedFilesLib		Statement
220f37506f6SBram Moolenaarhi def link specListedFilesPrefix		Statement
221f37506f6SBram Moolenaarhi def link specListedFilesShare		Statement
222071d4279SBram Moolenaar
223071d4279SBram Moolenaar
224071d4279SBram Moolenaarlet b:current_syntax = "spec"
225071d4279SBram Moolenaar
226071d4279SBram Moolenaar" vim: ts=8
227