diff --git a/CHANGELOG.md b/CHANGELOG.md index c7ebdc55..c4cca27c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - `bat --squeeze-blank`/`bat -s` will now squeeze consecutive empty lines, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815) - `bat --squeeze-limit` to set the maximum number of empty consecutive when using `--squeeze-blank`, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815) - `PrettyPrinter::squeeze_empty_lines` to support line squeezing for bat as a library, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815) +- Provide syntax highlighting for .spec files #2931 (@rtczza) ## Bugfixes diff --git a/assets/syntaxes/02_Extra/RPMSpec.sublime-syntax b/assets/syntaxes/02_Extra/RPMSpec.sublime-syntax new file mode 100644 index 00000000..7e97f4fc --- /dev/null +++ b/assets/syntaxes/02_Extra/RPMSpec.sublime-syntax @@ -0,0 +1,66 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/syntax.html +name: RPM Spec +file_extensions: + - spec +scope: source.spec +contexts: + main: + - match: '(Icon|ExclusiveOs|ExcludeOs):' + scope: keyword.spec + - match: '(BuildArch|BuildArchitectures|ExclusiveArch|ExcludeArch):' + captures: + 0: keyword.spec + push: + - match: $ + pop: true + - include: archs + - match: '[^\s,]+' + scope: invalid.spec + - match: '(Conflicts|Obsoletes|Provides|Requires|Requires\(.*\)|Enhances|Suggests|BuildConflicts|BuildRequires|Recommends|PreReq|Supplements):' + scope: keyword.spec + - match: '(Epoch|Serial|Nosource|Nopatch):' + scope: keyword.spec + - match: '(AutoReq|AutoProv|AutoReqProv):' + scope: keyword.spec + - match: '(Copyright|License|Summary|Summary\(.*\)|Distribution|Vendor|Packager|Group|Source\d*|Patch\d*|BuildRoot|Prefix):' + scope: keyword.spec + - match: '(Name|Version|Release|Url|URL):' + scope: keyword.spec + - match: ^(Source|Patch) + push: + - meta_scope: keyword.spec + - match: ':' + pop: true + - match: '^# norootforbuild' + scope: keyword.spec + - match: '%(ifarch|ifnarch)' + captures: + 0: keyword.control.spec + push: + - match: $ + pop: true + - include: archs + - match: '[^\s,]+' + scope: invalid.spec + - match: ^%(changelog|check$|description|files|package) + scope: keyword.control.spec + - match: ^(%(prep$|build$|install$|clean$|(pre|post)(un|trans)?|trigger(in|un|postun)|verifyscript)) + scope: keyword.control.spec + - match: '%(if|else|endif|define|global|undefine|ifos|ifnos)' + scope: keyword.control.spec + - match: '%\{' + push: + - meta_scope: variable.other.spec + - match: '\}' + pop: true + - match: '%([A-Za-z0-9_]+)' + scope: variable.other.spec + - match: ^\s*#.*$ + scope: comment.line.spec + - match: ^\* .*\)$ + scope: meta.documentation.spec + archs: + - match: \b(i386|i486|i586|i686|athlon|ia64|alpha|alphaev5|alphaev56|alphapca56|alphaev6|alphaev67|sparc|sparcv9|sparc64armv3l|armv4b|armv4lm|ips|mipsel|ppc|ppc|iseries|ppcpseries|ppc64|m68k|m68kmint|Sgi|rs6000|i370|s390x|s390|noarch)\b + scope: constant.other diff --git a/tests/syntax-tests/source/RPMSpec/bat.spec b/tests/syntax-tests/source/RPMSpec/bat.spec new file mode 100644 index 00000000..88adfecb --- /dev/null +++ b/tests/syntax-tests/source/RPMSpec/bat.spec @@ -0,0 +1,108 @@ +# +# spec file for package bat +# +# Copyright (c) 2023 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +Name: bat +Version: 0.24.0 +Release: 0 +Summary: A cat(1) clone with syntax highlighting and Git integration +License: Apache-2.0 OR MIT +Group: Productivity/Text/Utilities +URL: https://github.com/sharkdp/bat +Source0: %{name}-%{version}.tar.xz +Source1: vendor.tar.xz +Source2: cargo_config +BuildRequires: cargo-packaging +# weak-dep-features introduced in 1.60 and already used by libgit2-sys +# https://github.com/rust-lang/git2-rs/commit/d8ee105a8f3ce4d5c57cd091b67943aab86b176a +BuildRequires: rust >= 1.60 +ExclusiveArch: %{rust_arches} + +%description +A cat(1) clone which supports syntax highlighting for a large number of +programming and markup languages. It has git integration and automatic paging. + +%package bash-completion +Summary: Bash completion for %{name} +Requires: %{name} = %{version} +Supplements: (%{name} and bash-completion) +BuildArch: noarch + +%description bash-completion +Bash command line completion support for %{name}. + +%package fish-completion +Summary: Fish completion for %{name} +Requires: %{name} = %{version} +Supplements: (%{name} and fish) +BuildArch: noarch + +%description fish-completion +Fish command line completion support for %{name}. + +%package zsh-completion +Summary: Zsh completion for %{name} +Requires: %{name} = %{version} +Supplements: (%{name} and zsh) +BuildArch: noarch + +%description zsh-completion +Zsh command line completion support for %{name}. + +%prep +%setup -qa1 +mkdir .cargo +cp %{SOURCE2} .cargo/config + +%build +%{cargo_build} + +%install +install -D -m 0755 target/release/%{name} %{buildroot}%{_bindir}/%{name} + +install -D -m 0644 $(find target/release/build -name "%{name}.1") "%{buildroot}/%{_mandir}/man1/%{name}.1" + +install -D -m 0644 $(find target/release/build -name "%{name}.bash") "%{buildroot}/%{_datadir}/bash-completion/completions/%{name}" +install -D -m 0644 $(find target/release/build -name "%{name}.fish") "%{buildroot}/%{_datadir}/fish/vendor_completions.d/%{name}.fish" +install -D -m 0644 $(find target/release/build -name "%{name}.zsh") "%{buildroot}/%{_datadir}/zsh/site-functions/_%{name}" + +%if %{with check} +%check +%{cargo_test} +%endif + +%files +%doc README.md CONTRIBUTING.md CHANGELOG.md +%license LICENSE-MIT LICENSE-APACHE +%{_bindir}/%{name} +%{_mandir}/man1/%{name}.1%{ext_man} + +%files bash-completion +%{_datadir}/bash-completion/completions/%{name} + +%files fish-completion +%dir %{_datadir}/fish +%dir %{_datadir}/fish/vendor_completions.d +%{_datadir}/fish/vendor_completions.d/%{name}.fish + +%files zsh-completion +%dir %{_datadir}/zsh +%dir %{_datadir}/zsh/site-functions +%{_datadir}/zsh/site-functions/_%{name} + +%changelog +