Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
spec.vim230 linesDownload Raw Back to syntax
1" Filename:    spec.vim2" Purpose:     Vim syntax file3" Language:    SPEC: Build/install scripts for Linux RPM packages4" Maintainer:  Igor Gnatenko i.gnatenko.brain@gmail.com5" Former Maintainer:  Donovan Rebbechi elflord@panix.com (until March 2014)6" Last Change: 2020 May 257"  2024 Sep 10 by Vim Project: add file triggers support, #155698"  2025 May 05 by Vim Project: update for rpm 4.2 #172589"  2025 Nov 09 by Vim Project: support for more distributions and tags #1870310 11" quit when a syntax file was already loaded12if exists("b:current_syntax")13  finish14endif15 16syn sync minlines=100017 18syn match specSpecialChar contained '[][!$()\\|>^;:{}]'19syn match specColon       contained ':'20syn match specPercent     contained '%'21 22syn match specVariables   contained '\$\h\w*' contains=specSpecialVariablesNames,specSpecialChar23syn match specVariables   contained '\${\w*}' contains=specSpecialVariablesNames,specSpecialChar24 25syn match specMacroIdentifier contained '%\h\w*' contains=specMacroNameLocal,specMacroNameOther,specPercent26syn match specMacroIdentifier contained '%{?\?\w*}' contains=specMacroNameLocal,specMacroNameOther,specPercent,specSpecialChar27 28syn match specSpecialVariables contained '\$[0-9]\|\${[0-9]}'29syn match specCommandOpts      contained '\s\(-\w\+\|--\w[a-zA-Z_-]\+\)'ms=s+130syn match specComment '^\s*#.*$'31 32 33syn case match34 35 36"matches with no highlight37syn 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 acronyms41syn keyword specLicense contained GPL LGPL BSD MIT GNU42syn keyword specWeekday contained Mon Tue Wed Thu Fri Sat Sun43syn keyword specMonth   contained Jan Feb Mar Apr Jun Jul Aug Sep Oct Nov Dec44syn keyword specMonth   contained January February March April May June July August September October November December45 46"#, @, www47syn 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=specMacroIdentifier51 52"TODO take specSpecialVariables out of the cluster for the sh* contains (ALLBUT)53"Special system directories54syn match specListedFilesPrefix contained '/\(usr\|local\|opt\|X11R6\|X11\)/'me=e-155syn match specListedFilesBin    contained '/s\=bin/'me=e-156syn match specListedFilesLib    contained '/\(lib\|include\)/'me=e-157syn match specListedFilesDoc    contained '/\(man\d*\|doc\|info\)\>'58syn match specListedFilesEtc    contained '/etc/'me=e-159syn match specListedFilesShare  contained '/share/'me=e-160syn cluster specListedFiles contains=specListedFilesBin,specListedFilesLib,specListedFilesDoc,specListedFilesEtc,specListedFilesShare,specListedFilesPrefix,specVariables,specSpecialChar61 62"specCommands63syn match   specConfigure  contained '\./configure'64syn match   specTarCommand contained '\<tar\s\+[cxvpzIjf]\{,5}\s*'65syn keyword specCommandSpecial contained root66syn 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 gunzip67syn cluster specCommands contains=specCommand,specTarCommand,specConfigure,specCommandSpecial68 69"frequently used rpm env vars70syn keyword specSpecialVariablesNames contained RPM_BUILD_ROOT RPM_BUILD_DIR RPM_SOURCE_DIR RPM_OPT_FLAGS LDFLAGS CC CC_FLAGS CPPNAME CFLAGS CXX CXXFLAGS CPPFLAGS71 72"valid macro names from /usr/lib/rpm/macros73syn keyword specMacroNameOther contained buildroot buildsubdir distribution disturl ix86 name nil optflags perl_sitearch release requires_eq vendor version dist fedora rhel rocky rhl centos74syn match   specMacroNameOther contained '\<\(PATCH\|SOURCE\|el\|fc\)\d*\>'75 76"valid _macro names from /usr/lib/rpm/macros77syn 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 _vendor78 79 80"------------------------------------------------------------------------------81" here's is all the spec sections definitions: PreAmble, Description, Package,82"   Scripts, Files and Changelog83 84"One line macros - valid in all ScriptAreas85"tip: remember do include new items on specScriptArea's skip section86syn 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,specMacroIdentifier87syn region specSectionMacroBracketArea oneline matchgroup=specSectionMacro start='^%{\(configure\|GNUconfigure\|find_lang\|make_build\|makeinstall\|make_install\)}' end='$' contains=specCommandOpts,specMacroIdentifier88 89"%% Files Section %%90"TODO %config valid parameters: missingok\|noreplace91"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-2 contains=specFilesOpts,specFilesDirective,@specListedFiles,specComment,specCommandSpecial,specMacroIdentifier93"tip: remember to include new items in specFilesArea above94syn match  specFilesDirective contained '%\(attrib\|defattr\|attr\|dir\|config\|docdir\|doc\|lang\|license\|verify\|ghost\|exclude\)\>'95 96"valid options for certain section headers97syn match specDescriptionOpts contained '\s-[ln]\s*\a'ms=s+1,me=e-198syn match specPackageOpts     contained    '\s-n\s*\w'ms=s+1,me=e-199syn match specFilesOpts       contained    '\s-f\s*\w'ms=s+1,me=e-1100 101 102syn case ignore103 104 105"%% PreAmble Section %%106"Copyright and Serial were deprecated by License and Epoch107syn region specPreAmbleDeprecated oneline matchgroup=specError start='^\(Copyright\|Serial\)' end='$' contains=specEmail,specURL,specURLMacro,specLicense,specColon,specVariables,specSpecialChar,specMacroIdentifier108syn 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,specMacroIdentifier109 110"%% Description Section %%111syn region specDescriptionArea matchgroup=specSection start='^%description' end='^%'me=e-1 contains=specDescriptionOpts,specEmail,specURL,specNumber,specMacroIdentifier,specComment112 113"%% Package Section %%114syn region specPackageArea matchgroup=specSection start='^%package' end='^%'me=e-1 contains=specPackageOpts,specPreAmble,specComment115 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-1 contains=specSpecialVariables,specVariables,@specCommands,specVariables,shDo,shFor,shCaseEsac,specNoNumberHilite,specCommandOpts,shComment,shIf,specSpecialChar,specMacroIdentifier,specSectionMacroArea,specSectionMacroBracketArea,shOperator,shQuote1,shQuote2118 119"%% Changelog Section %%120syn region specChangelogArea matchgroup=specSection start='^%changelog' end='^%'me=e-1 contains=specEmail,specURL,specWeekday,specMonth,specNumber,specComment,specLicense121 122 123 124"------------------------------------------------------------------------------125"here's the shell syntax for all the Script Sections126 127 128syn case match129 130 131"sh-like comment stile, only valid in script part132syn match shComment contained '#.*$'133 134syn region dnlComment matchgroup=specComment start=+%dnl+ end=+$+135 136syn region shQuote1 contained matchgroup=shQuoteDelim start=+'+ skip=+\\'+ end=+'+ contains=specMacroIdentifier137syn region shQuote2 contained matchgroup=shQuoteDelim start=+"+ skip=+\\"+ end=+"+ contains=specVariables,specMacroIdentifier138 139syn match shOperator contained '[><|!&;]\|[!=]='140syn region shDo transparent matchgroup=specBlock start="\<do\>" end="\<done\>" contains=ALLBUT,shFunction,shDoError,shCase,specPreAmble,@specListedFiles141 142syn region specIf  matchgroup=specBlock start="%ifosf\|%ifos\|%ifnos\|%ifarch\|%ifnarch\|%else"  end='%endif'  contains=ALLBUT, specIfError, shCase143 144syn region  shIf transparent matchgroup=specBlock start="\<if\>" end="\<fi\>" contains=ALLBUT,shFunction,shIfError,shCase,@specListedFiles145 146syn region  shFor  matchgroup=specBlock start="\<for\>" end="\<in\>" contains=ALLBUT,shFunction,shInError,shCase,@specListedFiles147 148syn region shCaseEsac transparent matchgroup=specBlock start="\<case\>" matchgroup=NONE end="\<in\>"me=s-1 contains=ALLBUT,shFunction,shCaseError,@specListedFiles nextgroup=shCaseEsac149syn region shCaseEsac matchgroup=specBlock start="\<in\>" end="\<esac\>" contains=ALLBUT,shFunction,shCaseError,@specListedFilesBin150syn region shCase matchgroup=specBlock contained start=")"  end=";;" contains=ALLBUT,shFunction,shCaseError,shCase,@specListedFiles151 152syn sync match shDoSync       grouphere  shDo       "\<do\>"153syn sync match shDoSync       groupthere shDo       "\<done\>"154syn sync match shIfSync       grouphere  shIf       "\<if\>"155syn sync match shIfSync       groupthere shIf       "\<fi\>"156syn sync match specIfSync     grouphere  specIf     "%ifarch\|%ifos\|%ifnos"157syn sync match specIfSync     groupthere specIf     "%endIf"158syn sync match shForSync      grouphere  shFor      "\<for\>"159syn sync match shForSync      groupthere shFor      "\<in\>"160syn sync match shCaseEsacSync grouphere  shCaseEsac "\<case\>"161syn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>"162 163" Define the default highlighting.164" Only when an item doesn't have highlighting yet165 166"main types color definitions167hi def link specSection			Structure168hi def link specSectionMacro		Macro169hi def link specWWWlink			PreProc170hi def link specOpts			Operator171 172"yes, it's ugly, but white is sooo cool173if &background == "dark"174hi def specGlobalMacro		ctermfg=white175else176hi def link specGlobalMacro		Identifier177endif178 179"sh colors180hi def link shComment			Comment181hi def link dnlComment			Comment182hi def link shIf				Statement183hi def link shOperator			Special184hi def link shQuote1			String185hi def link shQuote2			String186hi def link shQuoteDelim			Statement187 188"spec colors189hi def link specBlock			Function190hi def link specColon			Special191hi def link specCommand			Statement192hi def link specCommandOpts		specOpts193hi def link specCommandSpecial		Special194hi def link specComment			Comment195hi def link specConfigure			specCommand196hi def link specDate			String197hi def link specDescriptionOpts		specOpts198hi def link specEmail			specWWWlink199hi def link specError			Error200hi def link specFilesDirective		specSectionMacro201hi def link specFilesOpts			specOpts202hi def link specLicense			String203hi def link specMacroNameLocal		specGlobalMacro204hi def link specMacroNameOther		specGlobalMacro205hi def link specManpageFile		NONE206hi def link specMonth			specDate207hi def link specNoNumberHilite		NONE208hi def link specNumber			Number209hi def link specPackageOpts		specOpts210hi def link specPercent			Special211hi def link specSpecialChar		Special212hi def link specSpecialVariables		specGlobalMacro213hi def link specSpecialVariablesNames	specGlobalMacro214hi def link specTarCommand			specCommand215hi def link specURL			specWWWlink216hi def link specURLMacro			specWWWlink217hi def link specVariables			Identifier218hi def link specWeekday			specDate219hi def link specListedFilesBin		Statement220hi def link specListedFilesDoc		Statement221hi def link specListedFilesEtc		Statement222hi def link specListedFilesLib		Statement223hi def link specListedFilesPrefix		Statement224hi def link specListedFilesShare		Statement225 226 227let b:current_syntax = "spec"228 229" vim: ts=8230 
codekingpro/portable-devtools · Team Ai