robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
ab20681c52
master
1" Filename: spec.vim 2" Purpose: Vim syntax file 3" Language: SPEC: Build/install scripts for Linux RPM packages 4" Maintainer: Igor Gnatenko i.gnatenko.brain@gmail.com 5" Former Maintainer: Donovan Rebbechi elflord@panix.com (until March 2014) 6" Last Change: 2020 May 25 7" 2024 Sep 10 by Vim Project: add file triggers support, #15569 8" 2025 May 05 by Vim Project: update for rpm 4.2 #17258 9" 2025 Nov 09 by Vim Project: support for more distributions and tags #18703 10 11" quit when a syntax file was already loaded 12if exists ( "b:current_syntax" ) 13finish 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"specCommands 63syn match specConfigure contained '\./configure ' 64syn match specTarCommand contained '\<tar\s\+ [ cxvpzIjf ] \{,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 bzip2 bunzip2 gunzip 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 dist fedora rhel rocky rhl centos 74syn match specMacroNameOther contained '\<\(PATCH\|SOURCE\|el\|fc\)\d * \> ' 75 76"valid _macro names from /usr/lib/rpm/macros 77syn keyword specMacroNameLocal contained _arch _binary_payload _bindir _build _build_alias _build_cpu _build_os _build_vendor _builddir _buildshell _buildsubdir _bzip2bin _datadir _dbpath _dbpath_rebuild _defaultdocdir _defaultlicensedir _docdir _excludedocs _exec_prefix _fixgroup _fixowner _fixperms _ftpport _ftpproxy _gpg_path _group_path _gzipbin _host _host_alias _host_cpu _host_os _host_vendor _httpport _httpproxy _iconsdir _includedir _infodir _install_langs _install_script_path _instchangelog _keyring _keyringpath _langpatt _lib _libdir _libexecdir _localstatedir _mandir _netsharedpath _oldincludedir _os _passwd_path _pgp_path _pgpbin _preScriptEnvironment _prefix _provides _rpmconfigdir _rpmdir _rpmfilename _rpmformat _rpmluadir _rpmmacrodir _sbindir _sharedstatedir _signature _source_payload _sourcedir _specdir _srcrpmdir _sysconfdir _sysusersdir _target _target_alias _target_cpu _target_os _target_platform _target_vendor _timecheck _tmppath _topdir _unitdir _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 items on specScriptArea's skip section 86syn 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 87syn region specSectionMacroBracketArea oneline matchgroup = specSectionMacro start = '^%{\(configure\|GNUconfigure\|find_lang\|make_build\|makeinstall\|make_install\)} '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\|license\|verify\|ghost\|exclude\)\> 'end = '^% [ a-zA-Z ] 'me= e-2contains = specFilesOpts , specFilesDirective , @specListedFiles , specComment , specCommandSpecial , specMacroIdentifier 93"tip: remember to include new items in specFilesArea above 94syn match specFilesDirective contained '%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|license\|verify\|ghost\|exclude\)\> ' 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\|Recommends\|Suggests\|Supplements\|Enhances\|Icon\|URL\|SourceLicense\|Source\d * \|Patch\d * \|Prefix\|Packager\|Group\|License\|Release\|BuildRoot\|Distribution\|DistTag\|Vendor\|Provides\|ExclusiveArch\|ExcludeArch\|ExclusiveOS\|Obsoletes\|BuildArch\|BuildArchitectures\|BuildRequires\|BuildConflicts\|BuildPreReq\|Conflicts\|AutoRequires\|AutoReq\|AutoReqProv\|AutoProv\|Epoch\|ModularityLabel\) 'end = '$ 'contains = specEmail , specURL , specURLMacro , specLicense , specColon , specVariables , specSpecialChar , specMacroIdentifier 109 110"%% Description Section %% 111syn region specDescriptionArea matchgroup = specSection start = '^%description 'end = '^% 'me= e-1contains = specDescriptionOpts , specEmail , specURL , specNumber , specMacroIdentifier , specComment 112 113"%% Package Section %% 114syn region specPackageArea matchgroup = specSection start = '^%package 'end = '^% 'me= e-1contains = specPackageOpts , specPreAmble , specComment 115 116"%% Scripts Section %% 117syn 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-1contains = 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-1contains = 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 dnlComment matchgroup = specComment start = +%dnl +end = +$ + 135 136syn region shQuote1 contained matchgroup = shQuoteDelim start = +' +skip = +\\' +end = +' +contains = specMacroIdentifier 137syn region shQuote2 contained matchgroup = shQuoteDelim start = +" +skip = +\\" +end = +" +contains = specVariables , specMacroIdentifier 138 139syn match shOperator contained '[ ><|!&; ] \| [ != ] = ' 140syn region shDo transparent matchgroup = specBlock start = "\<do\> "end = "\<done\> "contains = ALLBUT , shFunction , shDoError , shCase , specPreAmble , @specListedFiles 141 142syn region specIf matchgroup = specBlock start = "%ifosf\|%ifos\|%ifnos\|%ifarch\|%ifnarch\|%else "end = '%endif 'contains = ALLBUT , specIfError , shCase 143 144syn region shIf transparent matchgroup = specBlock start = "\<if\> "end = "\<fi\> "contains = ALLBUT , shFunction , shIfError , shCase , @specListedFiles 145 146syn region shFor matchgroup = specBlock start = "\<for\> "end = "\<in\> "contains = ALLBUT , shFunction , shInError , shCase , @specListedFiles 147 148syn region shCaseEsac transparent matchgroup = specBlock start = "\<case\> "matchgroup = NONE end = "\<in\> "me= s-1contains = ALLBUT , shFunction , shCaseError , @specListedFiles nextgroup = shCaseEsac 149syn region shCaseEsac matchgroup = specBlock start = "\<in\> "end = "\<esac\> "contains = ALLBUT , shFunction , shCaseError , @specListedFilesBin 150syn region shCase matchgroup = specBlock contained start = ") "end = ";; "contains = ALLBUT , shFunction , shCaseError , shCase , @specListedFiles 151 152syn syncmatch shDoSync grouphereshDo "\<do\> " 153syn syncmatch shDoSync groupthereshDo "\<done\> " 154syn syncmatch shIfSync grouphereshIf "\<if\> " 155syn syncmatch shIfSync groupthereshIf "\<fi\> " 156syn syncmatch specIfSync groupherespecIf "%ifarch\|%ifos\|%ifnos " 157syn syncmatch specIfSync grouptherespecIf "%endIf " 158syn syncmatch shForSync grouphereshFor "\<for\> " 159syn syncmatch shForSync groupthereshFor "\<in\> " 160syn syncmatch shCaseEsacSync grouphereshCaseEsac "\<case\> " 161syn syncmatch shCaseEsacSync groupthereshCaseEsac "\<esac\> " 162 163" Define the default highlighting. 164" Only when an item doesn't have highlighting yet 165 166"main types color definitions 167hi def link specSection Structure 168hi def link specSectionMacro Macro 169hi def link specWWWlink PreProc 170hi def link specOpts Operator 171 172"yes, it's ugly, but white is sooo cool 173if & background == "dark" 174hi def specGlobalMacro ctermfg = white 175else 176hi def link specGlobalMacro Identifier 177endif 178 179"sh colors 180hi def link shComment Comment 181hi def link dnlComment Comment 182hi def link shIf Statement 183hi def link shOperator Special 184hi def link shQuote1 String 185hi def link shQuote2 String 186hi def link shQuoteDelim Statement 187 188"spec colors 189hi def link specBlock Function 190hi def link specColon Special 191hi def link specCommand Statement 192hi def link specCommandOpts specOpts 193hi def link specCommandSpecial Special 194hi def link specComment Comment 195hi def link specConfigure specCommand 196hi def link specDate String 197hi def link specDescriptionOpts specOpts 198hi def link specEmail specWWWlink 199hi def link specError Error 200hi def link specFilesDirective specSectionMacro 201hi def link specFilesOpts specOpts 202hi def link specLicense String 203hi def link specMacroNameLocal specGlobalMacro 204hi def link specMacroNameOther specGlobalMacro 205hi def link specManpageFile NONE 206hi def link specMonth specDate 207hi def link specNoNumberHilite NONE 208hi def link specNumber Number 209hi def link specPackageOpts specOpts 210hi def link specPercent Special 211hi def link specSpecialChar Special 212hi def link specSpecialVariables specGlobalMacro 213hi def link specSpecialVariablesNames specGlobalMacro 214hi def link specTarCommand specCommand 215hi def link specURL specWWWlink 216hi def link specURLMacro specWWWlink 217hi def link specVariables Identifier 218hi def link specWeekday specDate 219hi def link specListedFilesBin Statement 220hi def link specListedFilesDoc Statement 221hi def link specListedFilesEtc Statement 222hi def link specListedFilesLib Statement 223hi def link specListedFilesPrefix Statement 224hi def link specListedFilesShare Statement 225 226 227let b: current_syntax = "spec" 228 229" vim: ts=8