blob: aed04bc9008da13b82b69d21399f72bb58547b01 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Filename: spec.vim
2" Purpose: Vim syntax file
3" Language: SPEC: Build/install scripts for Linux RPM packages
Bram Moolenaar08589172014-03-08 18:38:28 +01004" Maintainer: Igor Gnatenko i.gnatenko.brain@gmail.com
5" Former Maintainer: Donovan Rebbechi elflord@panix.com (until March 2014)
Bram Moolenaar388a5d42020-05-26 21:20:45 +02006" Last Change: 2020 May 25
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
Bram Moolenaar89bcfda2016-08-30 23:26:57 +02008" quit when a syntax file was already loaded
9if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000010 finish
11endif
12
13syn sync minlines=1000
14
15syn match specSpecialChar contained '[][!$()\\|>^;:{}]'
16syn match specColon contained ':'
17syn match specPercent contained '%'
18
19syn match specVariables contained '\$\h\w*' contains=specSpecialVariablesNames,specSpecialChar
20syn match specVariables contained '\${\w*}' contains=specSpecialVariablesNames,specSpecialChar
21
22syn match specMacroIdentifier contained '%\h\w*' contains=specMacroNameLocal,specMacroNameOther,specPercent
23syn match specMacroIdentifier contained '%{\w*}' contains=specMacroNameLocal,specMacroNameOther,specPercent,specSpecialChar
24
25syn match specSpecialVariables contained '\$[0-9]\|\${[0-9]}'
26syn match specCommandOpts contained '\s\(-\w\+\|--\w[a-zA-Z_-]\+\)'ms=s+1
27syn match specComment '^\s*#.*$'
28
29
30syn case match
31
32
33"matches with no highlight
34syn match specNoNumberHilite 'X11\|X11R6\|[a-zA-Z]*\.\d\|[a-zA-Z][-/]\d'
35syn match specManpageFile '[a-zA-Z]\.1'
36
37"Day, Month and most used license acronyms
38syn keyword specLicense contained GPL LGPL BSD MIT GNU
39syn keyword specWeekday contained Mon Tue Wed Thu Fri Sat Sun
40syn keyword specMonth contained Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec
41syn keyword specMonth contained January February March April May June July August September October November December
42
43"#, @, www
44syn match specNumber '\(^-\=\|[ \t]-\=\|-\)[0-9.-]*[0-9]'
45syn match specEmail contained "<\=\<[A-Za-z0-9_.-]\+@\([A-Za-z0-9_-]\+\.\)\+[A-Za-z]\+\>>\="
46syn match specURL contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#-]\+\>'
47syn match specURLMacro contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#%{}-]\+\>' contains=specMacroIdentifier
48
49"TODO take specSpecialVariables out of the cluster for the sh* contains (ALLBUT)
50"Special system directories
51syn match specListedFilesPrefix contained '/\(usr\|local\|opt\|X11R6\|X11\)/'me=e-1
52syn match specListedFilesBin contained '/s\=bin/'me=e-1
53syn match specListedFilesLib contained '/\(lib\|include\)/'me=e-1
54syn match specListedFilesDoc contained '/\(man\d*\|doc\|info\)\>'
55syn match specListedFilesEtc contained '/etc/'me=e-1
56syn match specListedFilesShare contained '/share/'me=e-1
57syn cluster specListedFiles contains=specListedFilesBin,specListedFilesLib,specListedFilesDoc,specListedFilesEtc,specListedFilesShare,specListedFilesPrefix,specVariables,specSpecialChar
58
Viktor Szépe3fc7a7e2023-08-23 21:20:00 +020059"specCommands
Bram Moolenaar071d4272004-06-13 20:20:40 +000060syn match specConfigure contained '\./configure'
61syn match specTarCommand contained '\<tar\s\+[cxvpzIf]\{,5}\s*'
62syn keyword specCommandSpecial contained root
63syn 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
64syn cluster specCommands contains=specCommand,specTarCommand,specConfigure,specCommandSpecial
65
66"frequently used rpm env vars
67syn keyword specSpecialVariablesNames contained RPM_BUILD_ROOT RPM_BUILD_DIR RPM_SOURCE_DIR RPM_OPT_FLAGS LDFLAGS CC CC_FLAGS CPPNAME CFLAGS CXX CXXFLAGS CPPFLAGS
68
69"valid macro names from /usr/lib/rpm/macros
70syn keyword specMacroNameOther contained buildroot buildsubdir distribution disturl ix86 name nil optflags perl_sitearch release requires_eq vendor version
71syn match specMacroNameOther contained '\<\(PATCH\|SOURCE\)\d*\>'
72
73"valid _macro names from /usr/lib/rpm/macros
Bram Moolenaar5be4cee2019-09-27 19:34:08 +020074syn 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
Bram Moolenaar071d4272004-06-13 20:20:40 +000075
76
77"------------------------------------------------------------------------------
78" here's is all the spec sections definitions: PreAmble, Description, Package,
79" Scripts, Files and Changelog
80
81"One line macros - valid in all ScriptAreas
Bram Moolenaardef9e822004-12-31 20:58:58 +000082"tip: remember do include new items on specScriptArea's skip section
Bram Moolenaar82af8712016-06-04 20:20:29 +020083syn 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
84syn region specSectionMacroBracketArea oneline matchgroup=specSectionMacro start='^%{\(configure\|GNUconfigure\|find_lang\|make_build\|makeinstall\|make_install\)}' end='$' contains=specCommandOpts,specMacroIdentifier
Bram Moolenaar071d4272004-06-13 20:20:40 +000085
86"%% Files Section %%
87"TODO %config valid parameters: missingok\|noreplace
88"TODO %verify valid parameters: \(not\)\= \(md5\|atime\|...\)
Bram Moolenaara6c27c42019-05-09 19:16:22 +020089syn 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
Viktor Szépe3fc7a7e2023-08-23 21:20:00 +020090"tip: remember to include new items in specFilesArea above
Bram Moolenaara6c27c42019-05-09 19:16:22 +020091syn match specFilesDirective contained '%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|license\|verify\|ghost\|exclude\)\>'
Bram Moolenaar071d4272004-06-13 20:20:40 +000092
93"valid options for certain section headers
94syn match specDescriptionOpts contained '\s-[ln]\s*\a'ms=s+1,me=e-1
95syn match specPackageOpts contained '\s-n\s*\w'ms=s+1,me=e-1
96syn match specFilesOpts contained '\s-f\s*\w'ms=s+1,me=e-1
97
98
99syn case ignore
100
101
102"%% PreAmble Section %%
103"Copyright and Serial were deprecated by License and Epoch
104syn region specPreAmbleDeprecated oneline matchgroup=specError start='^\(Copyright\|Serial\)' end='$' contains=specEmail,specURL,specURLMacro,specLicense,specColon,specVariables,specSpecialChar,specMacroIdentifier
Bram Moolenaar82af8712016-06-04 20:20:29 +0200105syn 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000106
107"%% Description Section %%
108syn region specDescriptionArea matchgroup=specSection start='^%description' end='^%'me=e-1 contains=specDescriptionOpts,specEmail,specURL,specNumber,specMacroIdentifier,specComment
109
110"%% Package Section %%
111syn region specPackageArea matchgroup=specSection start='^%package' end='^%'me=e-1 contains=specPackageOpts,specPreAmble,specComment
112
113"%% Scripts Section %%
Bram Moolenaarebdf3c92020-02-15 21:41:42 +0100114syn 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
Bram Moolenaar071d4272004-06-13 20:20:40 +0000115
116"%% Changelog Section %%
117syn region specChangelogArea matchgroup=specSection start='^%changelog' end='^%'me=e-1 contains=specEmail,specURL,specWeekday,specMonth,specNumber,specComment,specLicense
118
119
120
121"------------------------------------------------------------------------------
122"here's the shell syntax for all the Script Sections
123
124
125syn case match
126
127
128"sh-like comment stile, only valid in script part
129syn match shComment contained '#.*$'
130
Bram Moolenaar388a5d42020-05-26 21:20:45 +0200131syn region dnlComment matchgroup=specComment start=+%dnl+ end=+$+
132
Bram Moolenaar071d4272004-06-13 20:20:40 +0000133syn region shQuote1 contained matchgroup=shQuoteDelim start=+'+ skip=+\\'+ end=+'+ contains=specMacroIdentifier
134syn region shQuote2 contained matchgroup=shQuoteDelim start=+"+ skip=+\\"+ end=+"+ contains=specVariables,specMacroIdentifier
135
136syn match shOperator contained '[><|!&;]\|[!=]='
137syn region shDo transparent matchgroup=specBlock start="\<do\>" end="\<done\>" contains=ALLBUT,shFunction,shDoError,shCase,specPreAmble,@specListedFiles
138
139syn region specIf matchgroup=specBlock start="%ifosf\|%ifos\|%ifnos\|%ifarch\|%ifnarch\|%else" end='%endif' contains=ALLBUT, specIfError, shCase
140
141syn region shIf transparent matchgroup=specBlock start="\<if\>" end="\<fi\>" contains=ALLBUT,shFunction,shIfError,shCase,@specListedFiles
142
143syn region shFor matchgroup=specBlock start="\<for\>" end="\<in\>" contains=ALLBUT,shFunction,shInError,shCase,@specListedFiles
144
145syn region shCaseEsac transparent matchgroup=specBlock start="\<case\>" matchgroup=NONE end="\<in\>"me=s-1 contains=ALLBUT,shFunction,shCaseError,@specListedFiles nextgroup=shCaseEsac
146syn region shCaseEsac matchgroup=specBlock start="\<in\>" end="\<esac\>" contains=ALLBUT,shFunction,shCaseError,@specListedFilesBin
147syn region shCase matchgroup=specBlock contained start=")" end=";;" contains=ALLBUT,shFunction,shCaseError,shCase,@specListedFiles
148
149syn sync match shDoSync grouphere shDo "\<do\>"
150syn sync match shDoSync groupthere shDo "\<done\>"
151syn sync match shIfSync grouphere shIf "\<if\>"
152syn sync match shIfSync groupthere shIf "\<fi\>"
153syn sync match specIfSync grouphere specIf "%ifarch\|%ifos\|%ifnos"
154syn sync match specIfSync groupthere specIf "%endIf"
155syn sync match shForSync grouphere shFor "\<for\>"
156syn sync match shForSync groupthere shFor "\<in\>"
157syn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>"
158syn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>"
159
160" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200161" Only when an item doesn't have highlighting yet
Bram Moolenaar071d4272004-06-13 20:20:40 +0000162
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200163"main types color definitions
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200164hi def link specSection Structure
165hi def link specSectionMacro Macro
166hi def link specWWWlink PreProc
167hi def link specOpts Operator
Bram Moolenaar071d4272004-06-13 20:20:40 +0000168
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200169"yes, it's ugly, but white is sooo cool
170if &background == "dark"
171hi def specGlobalMacro ctermfg=white
172else
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200173hi def link specGlobalMacro Identifier
Bram Moolenaar071d4272004-06-13 20:20:40 +0000174endif
175
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200176"sh colors
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200177hi def link shComment Comment
Bram Moolenaar388a5d42020-05-26 21:20:45 +0200178hi def link dnlComment Comment
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200179hi def link shIf Statement
180hi def link shOperator Special
181hi def link shQuote1 String
182hi def link shQuote2 String
183hi def link shQuoteDelim Statement
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200184
185"spec colors
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200186hi def link specBlock Function
187hi def link specColon Special
188hi def link specCommand Statement
189hi def link specCommandOpts specOpts
190hi def link specCommandSpecial Special
191hi def link specComment Comment
192hi def link specConfigure specCommand
193hi def link specDate String
194hi def link specDescriptionOpts specOpts
195hi def link specEmail specWWWlink
196hi def link specError Error
197hi def link specFilesDirective specSectionMacro
198hi def link specFilesOpts specOpts
199hi def link specLicense String
200hi def link specMacroNameLocal specGlobalMacro
201hi def link specMacroNameOther specGlobalMacro
202hi def link specManpageFile NONE
203hi def link specMonth specDate
204hi def link specNoNumberHilite NONE
205hi def link specNumber Number
206hi def link specPackageOpts specOpts
207hi def link specPercent Special
208hi def link specSpecialChar Special
209hi def link specSpecialVariables specGlobalMacro
210hi def link specSpecialVariablesNames specGlobalMacro
211hi def link specTarCommand specCommand
212hi def link specURL specWWWlink
213hi def link specURLMacro specWWWlink
214hi def link specVariables Identifier
215hi def link specWeekday specDate
216hi def link specListedFilesBin Statement
217hi def link specListedFilesDoc Statement
218hi def link specListedFilesEtc Statement
219hi def link specListedFilesLib Statement
220hi def link specListedFilesPrefix Statement
221hi def link specListedFilesShare Statement
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200222
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200223
Bram Moolenaar071d4272004-06-13 20:20:40 +0000224let b:current_syntax = "spec"
225
226" vim: ts=8