%YAML 1.2 --- # https://www.sublimetext.com/docs/syntax.html # https://kaos.sh/blackhole-theme-sublime name: RPM Spec file_extensions: - spec - .rpmmacros first_line_match: "-[*]-( Mode:)? RPM Spec -[*]-" scope: source.spec contexts: main: - include: comments - include: strings - include: definitions - include: bash-variables - include: keywords - include: scriptlets - include: functions - include: directives - include: macroses - include: changelogs macroses: - match: (\%\{)([a-zA-Z_0-9 ?:!_-]{1,})(\}) captures: 0: variable.other.spec 1: variable.other.name.spec - match: \%(?!(global|define|package|description|prep|setup|autosetup|conf|build|install|clean|pre|post|preun|postun|pretrans|posttrans|verify|triggerprein|triggerin|triggerun|triggerpostun|filetriggerin|filetriggerun|filetriggerpostun|transfiletriggerin|transfiletriggerun|transfiletriggerpostun|verify|interp|meta|files|defattr|doc|config|artifact|ghost|license|dir|readme|changelog))([a-zA-Z_0-9_-]+) captures: 0: variable.other.spec 1: variable.other.name.spec strings: - match: '"' scope: punctuation.definition.string.begin.spec push: - meta_scope: string.quoted.double.spec - match: '"' scope: punctuation.definition.string.end.spec pop: true - match: $ scope: punctuation.definition.string.end.spec pop: true - include: string-placeholder - include: macroses - include: bash-variables - match: "'" scope: punctuation.definition.string.begin.spec push: - meta_scope: string.quoted.single.spec - match: "'" scope: punctuation.definition.string.end.spec pop: true - match: $ scope: punctuation.definition.string.end.spec pop: true - include: string-placeholder - include: macroses - include: bash-variables bash-variables: - match: \$([a-zA-Z_0-9])*\b scope: variable.other.bash keywords: - match: \%(ifarch|then|fi|endif|elif|else|if)\b scope: keyword.control.conditional.spec - match: '\b([0-9]+\.[0-9]*|\.[0-9]+)([eE][+-]?\d+)?\b' scope: constant.numeric.float.decimal.spec - match: '\b\d+\b' scope: constant.numeric.integer.decimal.spec - match: '(?:^[ \t]{0,}|\ \|\| | \&\& )(cat|cd|chmod|chown|chrpath|cmake|cp|echo|env|exit|export|find|getconf|getent|git|grep|groupadd|groupadd|head|iconv|install|ldconfig|ln|ls|make|mkdir|mv|patch|popd|printenv|pushd|pwd|rename|rm|sed|service|sha[\d]+hmac|sha[\d]+sum|sort|strip|svn|systemctl|systemd-[\w\d_-]+|tail|touch|tr|truncate|update-alternatives|useradd|wc|yes)\b' captures: 1: variable.function.spec - match: '(?:^[ \t]{0,}|\ \|\| | \&\& )(\/(bin|sbin|usr\/bin|usr\/sbin)\/([\w\d_-]+))\b' captures: 1: variable.function.spec - match: (&1>|&2>|&>|&>>|1>|2>) scope: keyword.operator - match: \b(?>[\t ]*)(if|else|fi|elif|while|done|-eq|-gt|-lt|-ge|-le)\b captures: 1: keyword.other - match: (?>\;) *(do|then) captures: 1: keyword.other scriptlets: - match: '\%(package|description|prep|setup|build|install|files|clean|pretrans|posttrans|preun|postun|changelog|post|pre|check|triggerun|triggerin|triggerpostun|verifyscript) ?(-[a-z]{1,4})? ?([a-zA-Z_\-0-9\.]*)?' captures: 0: keyword.other.spec 1: keyword.other.name.spec 2: keyword.other.options.spec 3: keyword.other.target.spec functions: - match: \%(defattr|attr|dir|config|ghost|doc|verify|exclude)\b scope: support.function.spec definitions: - match: '(\%define|\%global|\%bcond_[\w]+) +([\d\w\S]+)' captures: 0: spec.definition 1: support.function.spec 2: entity.name.type directives: - match: '^(Summary|Name|Version|Release|Group|License|URL|Epoch|Source[0-9]{0,9}|Patch[0-9]{0,9}|Build(Root|Requires|Conflicts|PreReq)|Requires|Requires\(.*\)|Provides|Obsoletes|Conflicts|Vendor|BuildArch|ExclusiveArch|Auto(Req|ReqProv|Prov)|Recommends|Suggests|Packager):' scope: support.directive.spec changelogs: - match: (\*) +([a-zA-Z]{3} +[a-zA-Z]{3} +[0-9]{1,2} +[0-9]{4}) +([^<]+)([^ ]+)?(?>[ \-]+)(.*) captures: 0: spec.changelog.header 1: spec.changelog.header.bullet 2: spec.changelog.header.date 3: spec.changelog.header.author 4: spec.changelog.header.mail 5: spec.changelog.header.version set: changelog-comments changelog-comments: - match: '^([- ])?.*' captures: 0: spec.changelog.comment 1: spec.changelog.comment.bullet - match: '^ ?$' pop: true comments: - match: (?=^\s*#) push: - match: \# scope: punctuation.definition.comment.spec set: - meta_scope: comment.line.number-sign.spec - include: pop-on-line-end - match: \# scope: punctuation.definition.comment.spec push: - meta_scope: comment.line.number-sign.spec - include: pop-on-line-end pop-on-line-end: - match: $ pop: true string-placeholder: - match: |- (?x)% [#0\- +']* # flags (\[\d+\])? # field (argument #) [,;:_]? # separator character (AltiVec) ((-?\d+)|(\[\d+\])?\*)? # minimum field width (\.((-?\d+)|(\[\d+\])?\*)?)? # precision [diouxXDOUeEfFgGaAcCsSpqnvtTbyYhHmMzZ%] # conversion type scope: constant.other.placeholder.spec