blob: 730a0b8cc5d0a54c45e0bd81aea5d88a5a5d19bb [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
fundawang2241f082024-09-10 21:31:49 +02007" 2024 Sep 10 by Vim Project: add file triggers support, #15569
Bram Moolenaar071d4272004-06-13 20:20:40 +00008
Bram Moolenaar89bcfda2016-08-30 23:26:57 +02009" quit when a syntax file was already loaded
10if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000011 finish
12endif
13
14syn sync minlines=1000
15
16syn match specSpecialChar contained '[][!$()\\|>^;:{}]'
17syn match specColon contained ':'
18syn match specPercent contained '%'
19
20syn match specVariables contained '\$\h\w*' contains=specSpecialVariablesNames,specSpecialChar
21syn match specVariables contained '\${\w*}' contains=specSpecialVariablesNames,specSpecialChar
22
23syn match specMacroIdentifier contained '%\h\w*' contains=specMacroNameLocal,specMacroNameOther,specPercent
24syn match specMacroIdentifier contained '%{\w*}' contains=specMacroNameLocal,specMacroNameOther,specPercent,specSpecialChar
25
26syn match specSpecialVariables contained '\$[0-9]\|\${[0-9]}'
27syn match specCommandOpts contained '\s\(-\w\+\|--\w[a-zA-Z_-]\+\)'ms=s+1
28syn match specComment '^\s*#.*$'
29
30
31syn case match
32
33
34"matches with no highlight
35syn match specNoNumberHilite 'X11\|X11R6\|[a-zA-Z]*\.\d\|[a-zA-Z][-/]\d'
36syn match specManpageFile '[a-zA-Z]\.1'
37
38"Day, Month and most used license acronyms
39syn keyword specLicense contained GPL LGPL BSD MIT GNU
40syn keyword specWeekday contained Mon Tue Wed Thu Fri Sat Sun
41syn keyword specMonth contained Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec
42syn keyword specMonth contained January February March April May June July August September October November December
43
44"#, @, www
45syn match specNumber '\(^-\=\|[ \t]-\=\|-\)[0-9.-]*[0-9]'
46syn match specEmail contained "<\=\<[A-Za-z0-9_.-]\+@\([A-Za-z0-9_-]\+\.\)\+[A-Za-z]\+\>>\="
47syn match specURL contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#-]\+\>'
48syn match specURLMacro contained '\<\(\(https\{0,1}\|ftp\)://\|\(www[23]\{0,1}\.\|ftp\.\)\)[A-Za-z0-9._/~:,#%{}-]\+\>' contains=specMacroIdentifier
49
50"TODO take specSpecialVariables out of the cluster for the sh* contains (ALLBUT)
51"Special system directories
52syn match specListedFilesPrefix contained '/\(usr\|local\|opt\|X11R6\|X11\)/'me=e-1
53syn match specListedFilesBin contained '/s\=bin/'me=e-1
54syn match specListedFilesLib contained '/\(lib\|include\)/'me=e-1
55syn match specListedFilesDoc contained '/\(man\d*\|doc\|info\)\>'
56syn match specListedFilesEtc contained '/etc/'me=e-1
57syn match specListedFilesShare contained '/share/'me=e-1
58syn cluster specListedFiles contains=specListedFilesBin,specListedFilesLib,specListedFilesDoc,specListedFilesEtc,specListedFilesShare,specListedFilesPrefix,specVariables,specSpecialChar
59
Viktor Szépe3fc7a7e2023-08-23 21:20:00 +020060"specCommands
Bram Moolenaar071d4272004-06-13 20:20:40 +000061syn match specConfigure contained '\./configure'
62syn match specTarCommand contained '\<tar\s\+[cxvpzIf]\{,5}\s*'
63syn keyword specCommandSpecial contained root
64syn 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
65syn cluster specCommands contains=specCommand,specTarCommand,specConfigure,specCommandSpecial
66
67"frequently used rpm env vars
68syn keyword specSpecialVariablesNames contained RPM_BUILD_ROOT RPM_BUILD_DIR RPM_SOURCE_DIR RPM_OPT_FLAGS LDFLAGS CC CC_FLAGS CPPNAME CFLAGS CXX CXXFLAGS CPPFLAGS
69
70"valid macro names from /usr/lib/rpm/macros
71syn keyword specMacroNameOther contained buildroot buildsubdir distribution disturl ix86 name nil optflags perl_sitearch release requires_eq vendor version
72syn match specMacroNameOther contained '\<\(PATCH\|SOURCE\)\d*\>'
73
74"valid _macro names from /usr/lib/rpm/macros
Bram Moolenaar5be4cee2019-09-27 19:34:08 +020075syn 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 +000076
77
78"------------------------------------------------------------------------------
79" here's is all the spec sections definitions: PreAmble, Description, Package,
80" Scripts, Files and Changelog
81
82"One line macros - valid in all ScriptAreas
Bram Moolenaardef9e822004-12-31 20:58:58 +000083"tip: remember do include new items on specScriptArea's skip section
Bram Moolenaar82af8712016-06-04 20:20:29 +020084syn 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
85syn 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 +000086
87"%% Files Section %%
88"TODO %config valid parameters: missingok\|noreplace
89"TODO %verify valid parameters: \(not\)\= \(md5\|atime\|...\)
Bram Moolenaara6c27c42019-05-09 19:16:22 +020090syn 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 +020091"tip: remember to include new items in specFilesArea above
Bram Moolenaara6c27c42019-05-09 19:16:22 +020092syn match specFilesDirective contained '%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|license\|verify\|ghost\|exclude\)\>'
Bram Moolenaar071d4272004-06-13 20:20:40 +000093
94"valid options for certain section headers
95syn match specDescriptionOpts contained '\s-[ln]\s*\a'ms=s+1,me=e-1
96syn match specPackageOpts contained '\s-n\s*\w'ms=s+1,me=e-1
97syn match specFilesOpts contained '\s-f\s*\w'ms=s+1,me=e-1
98
99
100syn case ignore
101
102
103"%% PreAmble Section %%
104"Copyright and Serial were deprecated by License and Epoch
105syn region specPreAmbleDeprecated oneline matchgroup=specError start='^\(Copyright\|Serial\)' end='$' contains=specEmail,specURL,specURLMacro,specLicense,specColon,specVariables,specSpecialChar,specMacroIdentifier
Petr Pisar315cd1f2024-02-22 20:39:09 +0100106syn region specPreAmble oneline matchgroup=specCommand start='^\(Prereq\|Summary\|Name\|Version\|Packager\|Requires\|Recommends\|Suggests\|Supplements\|Enhances\|Icon\|URL\|SourceLicense\|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 +0000107
108"%% Description Section %%
109syn region specDescriptionArea matchgroup=specSection start='^%description' end='^%'me=e-1 contains=specDescriptionOpts,specEmail,specURL,specNumber,specMacroIdentifier,specComment
110
111"%% Package Section %%
112syn region specPackageArea matchgroup=specSection start='^%package' end='^%'me=e-1 contains=specPackageOpts,specPreAmble,specComment
113
114"%% Scripts Section %%
fundawang2241f082024-09-10 21:31:49 +0200115syn region specScriptArea matchgroup=specSection start='^%\(prep\|generate_buildrequires\|conf\|build\|install\|clean\|check\|pre\|postun\|preun\|post\|posttrans\|filetriggerin\|filetriggerun\|filetriggerpostun\|transfiletriggerin\|transfiletriggerun\|transfiletriggerpostun\)\>' 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 +0000116
117"%% Changelog Section %%
118syn region specChangelogArea matchgroup=specSection start='^%changelog' end='^%'me=e-1 contains=specEmail,specURL,specWeekday,specMonth,specNumber,specComment,specLicense
119
120
121
122"------------------------------------------------------------------------------
123"here's the shell syntax for all the Script Sections
124
125
126syn case match
127
128
129"sh-like comment stile, only valid in script part
130syn match shComment contained '#.*$'
131
Bram Moolenaar388a5d42020-05-26 21:20:45 +0200132syn region dnlComment matchgroup=specComment start=+%dnl+ end=+$+
133
Bram Moolenaar071d4272004-06-13 20:20:40 +0000134syn 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.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200162" Only when an item doesn't have highlighting yet
Bram Moolenaar071d4272004-06-13 20:20:40 +0000163
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200164"main types color definitions
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200165hi def link specSection Structure
166hi def link specSectionMacro Macro
167hi def link specWWWlink PreProc
168hi def link specOpts Operator
Bram Moolenaar071d4272004-06-13 20:20:40 +0000169
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200170"yes, it's ugly, but white is sooo cool
171if &background == "dark"
172hi def specGlobalMacro ctermfg=white
173else
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200174hi def link specGlobalMacro Identifier
Bram Moolenaar071d4272004-06-13 20:20:40 +0000175endif
176
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200177"sh colors
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200178hi def link shComment Comment
Bram Moolenaar388a5d42020-05-26 21:20:45 +0200179hi def link dnlComment Comment
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200180hi def link shIf Statement
181hi def link shOperator Special
182hi def link shQuote1 String
183hi def link shQuote2 String
184hi def link shQuoteDelim Statement
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200185
186"spec colors
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200187hi def link specBlock Function
188hi def link specColon Special
189hi def link specCommand Statement
190hi def link specCommandOpts specOpts
191hi def link specCommandSpecial Special
192hi def link specComment Comment
193hi def link specConfigure specCommand
194hi def link specDate String
195hi def link specDescriptionOpts specOpts
196hi def link specEmail specWWWlink
197hi def link specError Error
198hi def link specFilesDirective specSectionMacro
199hi def link specFilesOpts specOpts
200hi def link specLicense String
201hi def link specMacroNameLocal specGlobalMacro
202hi def link specMacroNameOther specGlobalMacro
203hi def link specManpageFile NONE
204hi def link specMonth specDate
205hi def link specNoNumberHilite NONE
206hi def link specNumber Number
207hi def link specPackageOpts specOpts
208hi def link specPercent Special
209hi def link specSpecialChar Special
210hi def link specSpecialVariables specGlobalMacro
211hi def link specSpecialVariablesNames specGlobalMacro
212hi def link specTarCommand specCommand
213hi def link specURL specWWWlink
214hi def link specURLMacro specWWWlink
215hi def link specVariables Identifier
216hi def link specWeekday specDate
217hi def link specListedFilesBin Statement
218hi def link specListedFilesDoc Statement
219hi def link specListedFilesEtc Statement
220hi def link specListedFilesLib Statement
221hi def link specListedFilesPrefix Statement
222hi def link specListedFilesShare Statement
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200223
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200224
Bram Moolenaar071d4272004-06-13 20:20:40 +0000225let b:current_syntax = "spec"
226
227" vim: ts=8