on master help sign in
Merge remote-tracking branch 'origin/master' into fix-1063
commit02e6ff4183f6b24ff4fe297195287b65bc66eaee authorMartin Nordholts <enselic@gmail.com> dateSun 10 Jan 2021, 11:56 (6 years ago) parentda10166e3b1142
22 files changed+323−106
.github/workflows/CICD.yml+35−48 .gitmodules+3 CHANGELOG.md+5−2 Cargo.lock+14−14 README.md+2−1 assets/syntaxes/02_Extra/gnuplot+1 assets/syntaxes/02_Extra/gnuplot.sublime-syntax+182 doc/README-ru.md+1−1 doc/assets.md+1−1 src/bin/bat/app.rs+3−3 src/bin/bat/input.rs+1−1 src/bin/bat/main.rs+3−2 src/input.rs+1−5 src/output.rs+2−6 src/pretty_printer.rs+6 src/printer.rs+1−1 src/wrapping.rs+3−2 tests/assets.rs+1−1 tests/snapshot_tests.rs+1−1 tests/syntax-tests/highlighted/gnuplot/test.gp+19 tests/syntax-tests/source/gnuplot/test.gp+19 tests/tester.rs+19−17
.github/workflows/CICD.yml+35−48
@@ -2,17 +2,18 @@ name: CICD
22
33env:
44 PROJECT_NAME: bat
5+ PROJECT_VERSION: "0.17.1"
56 PROJECT_DESC: "A `cat` clone with wings"
67 PROJECT_MAINTAINER: "David Peter <mail@david-peter.de>"
78 PROJECT_HOMEPAGE: "https://github.com/sharkdp/bat"
8− MIN_SUPPORTED_RUST_VERSION: "1.40.0"
9+ MIN_SUPPORTED_RUST_VERSION: "1.42.0"
910
1011on: [push, pull_request]
1112
1213jobs:
1314 min_version:
1415 name: Minimum supported rust version
15− runs-on: ubuntu-latest
16+ runs-on: ubuntu-18.04
1617 steps:
1718 - name: Git checkout
1819 uses: actions/checkout@v2
@@ -27,7 +28,7 @@ jobs:
2728 uses: actions-rs/cargo@v1
2829 with:
2930 command: clippy
30− args: --all-targets --all-features -- --allow clippy::style
31+ args: --all-targets --all-features
3132 - name: Test
3233 uses: actions-rs/cargo@v1
3334 with:
@@ -35,7 +36,7 @@ jobs:
3536
3637 test_with_new_syntaxes_and_themes:
3738 name: Test with new syntaxes and themes
38− runs-on: ubuntu-latest
39+ runs-on: ubuntu-18.04
3940 steps:
4041 - name: Git checkout
4142 uses: actions/checkout@v2
@@ -83,19 +84,17 @@ jobs:
8384 fail-fast: false
8485 matrix:
8586 job:
86− # { os, target, cargo-options, features, use-cross }
87− - { os: ubuntu-latest , target: arm-unknown-linux-gnueabihf , use-cross: true }
88− - { os: ubuntu-18.04 , target: aarch64-unknown-linux-gnu , use-cross: true }
89− - { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , use-cross: true }
90− - { os: ubuntu-18.04 , target: i686-unknown-linux-musl , use-cross: true }
91− - { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu }
92− - { os: ubuntu-18.04 , target: x86_64-unknown-linux-musl , use-cross: true }
93− - { os: ubuntu-16.04 , target: x86_64-unknown-linux-gnu }
94− - { os: macos-latest , target: x86_64-apple-darwin }
95− # - { os: windows-latest , target: i686-pc-windows-gnu } ## disabled; error: linker `i686-w64-mingw32-gcc` not found
96− - { os: windows-latest , target: i686-pc-windows-msvc }
97− - { os: windows-latest , target: x86_64-pc-windows-gnu }
98− - { os: windows-latest , target: x86_64-pc-windows-msvc }
87+ - { os: ubuntu-18.04 , target: arm-unknown-linux-gnueabihf , use-cross: true }
88+ - { os: ubuntu-18.04 , target: aarch64-unknown-linux-gnu , use-cross: true }
89+ - { os: ubuntu-18.04 , target: i686-unknown-linux-gnu , use-cross: true }
90+ - { os: ubuntu-18.04 , target: i686-unknown-linux-musl , use-cross: true }
91+ - { os: ubuntu-18.04 , target: x86_64-unknown-linux-gnu }
92+ - { os: ubuntu-18.04 , target: x86_64-unknown-linux-musl , use-cross: true }
93+ - { os: macos-10.15 , target: x86_64-apple-darwin }
94+ # - { os: windows-2019 , target: i686-pc-windows-gnu } ## disabled; error: linker `i686-w64-mingw32-gcc` not found
95+ - { os: windows-2019 , target: i686-pc-windows-msvc }
96+ - { os: windows-2019 , target: x86_64-pc-windows-gnu }
97+ - { os: windows-2019 , target: x86_64-pc-windows-msvc }
9998 steps:
10099 - name: Git checkout
101100 uses: actions/checkout@v2
@@ -116,26 +115,14 @@ jobs:
116115 # determine EXE suffix
117116 EXE_suffix="" ; case ${{ matrix.job.target }} in *-pc-windows-*) EXE_suffix=".exe" ;; esac;
118117 echo ::set-output name=EXE_suffix::${EXE_suffix}
119− # parse commit reference info
120− unset REF_TAG ; case ${GITHUB_REF} in refs/tags/*) REF_TAG=${GITHUB_REF#refs/tags/} ;; esac;
121− REF_SHAS=${GITHUB_SHA:0:8}
122− # parse target
123− unset TARGET_ARCH ; case ${{ matrix.job.target }} in arm-unknown-linux-gnueabihf) TARGET_ARCH=arm ;; i686-*) TARGET_ARCH=i686 ;; x86_64-*) TARGET_ARCH=x86_64 ;; esac;
124− echo ::set-output name=TARGET_ARCH::${TARGET_ARCH}
125− unset TARGET_OS ; case ${{ matrix.job.target }} in *-linux-*) TARGET_OS=linux ;; *-apple-*) TARGET_OS=macos ;; *-windows-*) TARGET_OS=windows ;; esac;
126− echo ::set-output name=TARGET_OS::${TARGET_OS}
127118 # package name
128119 PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
129− PKG_BASENAME=${PROJECT_NAME}-${REF_TAG:-$REF_SHAS}-${{ matrix.job.target }}
120+ PKG_BASENAME=${PROJECT_NAME}-v${PROJECT_VERSION}-${{ matrix.job.target }}
130121 PKG_NAME=${PKG_BASENAME}${PKG_suffix}
131− echo ::set-output name=PKG_suffix::${PKG_suffix}
132122 echo ::set-output name=PKG_BASENAME::${PKG_BASENAME}
133123 echo ::set-output name=PKG_NAME::${PKG_NAME}
134− # deployable tag? (ie, leading "vM" or "M"; M == version number)
135− unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
136− # unset deploy on ubuntu-18.04 x64 - we will deploy the tarball/deb built on ubuntu-16.04 x64
137− if [ "${{ matrix.job.os }}" = "ubuntu-18.04" ] && [ "${{ matrix.job.target }}" = "x86_64-unknown-linux-gnu" ]; then unset DEPLOY; fi
138− echo ::set-output name=DEPLOY::${DEPLOY}
124+ unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi
125+ echo ::set-output name=IS_RELEASE::${IS_RELEASE}
139126 # DPKG architecture?
140127 unset DPKG_ARCH
141128 case ${{ matrix.job.target }} in
@@ -145,8 +132,7 @@ jobs:
145132 x86_64-*-linux-*) DPKG_ARCH=amd64 ;;
146133 esac;
147134 echo ::set-output name=DPKG_ARCH::${DPKG_ARCH}
148− # DPKG version?
149− unset DPKG_VERSION ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DPKG_VERSION=${REF_TAG/#[vV]/} ; fi
135+ DPKG_VERSION=${PROJECT_VERSION}
150136 echo ::set-output name=DPKG_VERSION::${DPKG_VERSION}
151137 # DPKG base name/conflicts?
152138 DPKG_BASENAME=${PROJECT_NAME}
@@ -159,10 +145,6 @@ jobs:
159145 if [[ -n $DPKG_ARCH && -n $DPKG_VERSION ]]; then DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb" ; fi
160146 echo ::set-output name=DPKG_NAME::${DPKG_NAME}
161147 # target-specific options
162− # # * `arm` cannot be tested on ubuntu-* hosts (b/c testing is currently primarily done via comparison of target outputs with built-in outputs and the `arm` target is not executable on the host)
163− JOB_DO_TESTING="true"
164− case ${{ matrix.job.target }} in arm-*) unset JOB_DO_TESTING ;; esac;
165− echo ::set-output name=JOB_DO_TESTING::${JOB_DO_TESTING}
166148 # # * test only library unit tests and binary for arm-type targets
167149 unset CARGO_TEST_OPTIONS
168150 unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--lib --bin ${PROJECT_NAME}" ;; esac;
@@ -241,11 +223,6 @@ jobs:
241223 use-cross: ${{ matrix.job.use-cross }}
242224 command: check
243225 args: --target=${{ matrix.job.target }} --verbose --lib --no-default-features --features regex-onig,git,paging
244− - name: Upload build artifacts
245− uses: actions/upload-artifact@master
246− with:
247− name: ${{ env.PROJECT_NAME }}-${{ matrix.job.target }}
248− path: target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}
249226 - name: Package
250227 shell: bash
251228 run: |
@@ -358,9 +335,20 @@ jobs:
358335 # build dpkg
359336 fakeroot dpkg-deb --build "${DPKG_DIR}" "${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}"
360337 fi
338+ - name: Upload package artifact
339+ uses: actions/upload-artifact@master
340+ with:
341+ name: ${{ steps.vars.outputs.PKG_NAME }}
342+ path: ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
343+ - name: Upload Debian package artifact
344+ uses: actions/upload-artifact@master
345+ if: steps.vars.outputs.DPKG_NAME
346+ with:
347+ name: ${{ steps.vars.outputs.DPKG_NAME }}
348+ path: ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.DPKG_NAME }}
361349 - name: Publish archives and packages
362350 uses: softprops/action-gh-release@v1
363− if: steps.vars.outputs.DEPLOY
351+ if: steps.vars.outputs.IS_RELEASE
364352 with:
365353 files: |
366354 ${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_NAME }}
@@ -375,11 +363,10 @@ jobs:
375363 strategy:
376364 fail-fast: true
377365 matrix:
378− # job: [ { os: ubuntu-latest }, { os: macos-latest }, { os: windows-latest } ]
379366 job:
380− - { os: ubuntu-latest , toolchain: nightly-2020-04-29 }
381− - { os: macos-latest , toolchain: nightly-2020-04-29 }
382− - { os: windows-latest , toolchain: nightly-2020-04-29-x86_64-pc-windows-gnu }
367+ - { os: ubuntu-18.04 , toolchain: nightly-2020-04-29 }
368+ - { os: macos-10.15 , toolchain: nightly-2020-04-29 }
369+ - { os: windows-2019 , toolchain: nightly-2020-04-29-x86_64-pc-windows-gnu }
383370 steps:
384371 - uses: actions/checkout@v2
385372 - name: Initialize workflow variables
.gitmodules+3
@@ -213,3 +213,6 @@
213213[submodule "assets/syntaxes/02_Extra/Zig"]
214214 path = assets/syntaxes/02_Extra/Zig
215215 url = https://github.com/ziglang/sublime-zig-language.git
216+[submodule "assets/syntaxes/02_Extra/gnuplot"]
217+ path = assets/syntaxes/02_Extra/gnuplot
218+ url = https://github.com/hesstobi/sublime_gnuplot
CHANGELOG.md+5−2
@@ -12,23 +12,26 @@
1212- Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic)
1313- VimL syntax highlighting fix, see #1450 (@esensar)
1414- Print an 'Invalid syntax theme settings' error message if a custom theme is broken, see #614 (@Enselic)
15+- If plain mode is set and wrap is not explicitly opted in, long lines will no be truncated, see #1426
1516- If `PAGER` (but not `BAT_PAGER` or `--pager`) is `more` or `most`, silently use `less` instead to ensure support for colors, see #1063 (@Enselic)
1617
1718## Other
1819
1920- Performance improvements, see #1421 (@LovecraftianHorror)
2021- Added a new `--diagnostic` option to collect information for bug reports, see #1459 (@sharkdp)
22+- Upped min required Rust version to 1.42
2123
2224## Syntaxes
2325
2426- Added Zig syntax, see #1470 (@paulsmith)
2527- Added Lean syntax, see #1446 (@Julian)
2628- Added `.resource` extension for Robot Framework files, see #1386
29+- Added `gnuplot` syntax, see #1431 (@sharkdp)
2730
2831## New themes
2932
30−- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12)
31−- The Gruvbox theme has been updated, see #1291 (@j0hnmeow). **Breaking change:** users that were previously usuing `gruvbox` or `gruvbox-white` should update and use `gruvbox-dark`/`gruvbox-light` instead.
33+- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12). **Breaking change:** users that were previously using one of the `ansi-*` themes should switch to `ansi`.
34+- The Gruvbox theme has been updated, see #1291 (@j0hnmeow). **Breaking change:** users that were previously using `gruvbox` or `gruvbox-white` should update and use `gruvbox-dark`/`gruvbox-light` instead.
3235
3336## `bat` as a library
3437
Cargo.lock+14−14
@@ -186,9 +186,9 @@ dependencies = [
186186
187187[[package]]
188188name = "byteorder"
189−version = "1.3.4"
189+version = "1.4.2"
190190source = "registry+https://github.com/rust-lang/crates.io-index"
191−checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
191+checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
192192
193193[[package]]
194194name = "cc"
@@ -589,9 +589,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
589589
590590[[package]]
591591name = "libc"
592−version = "0.2.81"
592+version = "0.2.82"
593593source = "registry+https://github.com/rust-lang/crates.io-index"
594−checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
594+checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929"
595595
596596[[package]]
597597name = "libgit2-sys"
@@ -628,9 +628,9 @@ dependencies = [
628628
629629[[package]]
630630name = "linked-hash-map"
631−version = "0.5.3"
631+version = "0.5.4"
632632source = "registry+https://github.com/rust-lang/crates.io-index"
633−checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a"
633+checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
634634
635635[[package]]
636636name = "lock_api"
@@ -903,9 +903,9 @@ dependencies = [
903903
904904[[package]]
905905name = "regex"
906−version = "1.4.2"
906+version = "1.4.3"
907907source = "registry+https://github.com/rust-lang/crates.io-index"
908−checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
908+checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
909909dependencies = [
910910 "aho-corasick",
911911 "memchr",
@@ -915,9 +915,9 @@ dependencies = [
915915
916916[[package]]
917917name = "regex-syntax"
918−version = "0.6.21"
918+version = "0.6.22"
919919source = "registry+https://github.com/rust-lang/crates.io-index"
920−checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
920+checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
921921
922922[[package]]
923923name = "remove_dir_all"
@@ -1058,9 +1058,9 @@ checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074"
10581058
10591059[[package]]
10601060name = "smallvec"
1061−version = "1.6.0"
1061+version = "1.6.1"
10621062source = "registry+https://github.com/rust-lang/crates.io-index"
1063−checksum = "1a55ca5f3b68e41c979bf8c46a6f1da892ca4db8f94023ce0bd32407573b1ac0"
1063+checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
10641064
10651065[[package]]
10661066name = "snailquote"
@@ -1190,9 +1190,9 @@ dependencies = [
11901190
11911191[[package]]
11921192name = "thread_local"
1193−version = "1.0.1"
1193+version = "1.1.0"
11941194source = "registry+https://github.com/rust-lang/crates.io-index"
1195−checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
1195+checksum = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447"
11961196dependencies = [
11971197 "lazy_static",
11981198]
README.md+2−1
@@ -356,7 +356,7 @@ binaries are also available: look for archives with `musl` in the file name.
356356
357357### From source
358358
359−If you want to build `bat` from source, you need Rust 1.40 or
359+If you want to build `bat` from source, you need Rust 1.42 or
360360higher. You can then use `cargo` to build everything:
361361
362362```bash
@@ -700,6 +700,7 @@ Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide.
700700- [sharkdp](https://github.com/sharkdp)
701701- [eth-p](https://github.com/eth-p)
702702- [keith-hall](https://github.com/keith-hall)
703+- [Enselic](https://github.com/Enselic)
703704
704705## Project goals and alternatives
705706
assets/syntaxes/02_Extra/gnuplotnew file+1

Submodule changed.

assets/syntaxes/02_Extra/gnuplot.sublime-syntaxnew file+182
@@ -0,0 +1,182 @@
1+%YAML 1.2
2+---
3+# http://www.sublimetext.com/docs/3/syntax.html
4+name: gnuplot
5+file_extensions:
6+ - gp
7+ - gpl
8+ - gnuplot
9+ - gnu
10+ - plot
11+ - plt
12+scope: source.gnuplot
13+contexts:
14+ main:
15+ - include: number
16+ - include: string_single
17+ - include: string_double
18+ - match: '\b(for)\b\s*(\[)'
19+ comment: |
20+ gnuplot iteration statement.
21+ There are two forms:
22+ numeric [n = 1:2{:inc}]
23+ string based [str in "x y z"]
24+ but both can also iterate over lists etc, so this is kept loose.
25+ captures:
26+ 1: keyword.other.iteration.gnuplot
27+ 2: punctuation.definition.range.begin.gnuplot
28+ push:
29+ - meta_scope: meta.structure.iteration.gnuplot
30+ - match: '\]'
31+ captures:
32+ 0: punctuation.definition.range.end.gnuplot
33+ pop: true
34+ - include: number
35+ - include: operator
36+ - include: string_double
37+ - include: string_single
38+ - match: ":"
39+ scope: punctuation.separator.range.gnuplot
40+ - match: '\b([a-zA-Z]\w*)\b\s*(=|in)'
41+ scope: variable-assignment.range.gnuplot
42+ - match: '(?i:[^\s(pi|e)\]])'
43+ scope: invalid.illegal.expected-range-separator.gnuplot
44+ - match: '\['
45+ comment: "gnuplot range statement [a:b]. Lots of things are legal, still more make no sense!"
46+ captures:
47+ 0: punctuation.definition.range.begin.gnuplot
48+ push:
49+ - meta_scope: meta.structure.range.gnuplot
50+ - match: '\]'
51+ captures:
52+ 0: punctuation.definition.range.end.gnuplot
53+ pop: true
54+ - include: number
55+ - include: operator
56+ - match: ":"
57+ scope: punctuation.separator.range.gnuplot
58+ - match: '(?i:[^\s(pi|e)\]])'
59+ scope: invalid.illegal.expected-range-separator.gnuplot
60+ - match: \\.
61+ scope: constant.character.escape.gnuplot
62+ - match: '(?<!\$)(#)(?!\{).*$\n?'
63+ scope: comment.line.number-sign.gnuplot
64+ captures:
65+ 1: punctuation.definition.comment.gnuplot
66+ - match: for
67+ comment: introduce in gnuplot 4.3.
68+ scope: keyword.other.iteration.gnuplot
69+ - match: \b(angles|arrow|autoscale|bars|border|boxwidth|clabel|clip|cntrparam|colorbox|contour|decimalsign|dgrid3d|dummy|encoding|fit|format|grid|hidden3d|historysize|isosamples|key|label|locale|logscale|macros|bmargin|lmargin|rmargin|tmargin|mapping|mouse|multiplot|offsets|origin|output|palette|parametric|pm3d|pointsize|polar|print|rrange|trange|urange|vrange|samples|size|style|surface|tics|ticscale|ticslevel|timestamp|timefmt|title|view|xyplane|x2data|xdata|y2data|ydata|z2data|zdata|x2label|xlabel|y2label|ylabel|z2label|zlabel|x2range|xrange|y2range|yrange|z2range|zrange|mx2tics|mxtics|my2tics|mytics|mz2tics|mztics|nomx2tics|nomxtics|nomy2tics|nomytics|nomz2tics|nomztics|nox2tics|noxtics|noy2tics|noytics|noz2tics|noztics|x2tics|xtics|y2tics|ytics|z2tics|ztics|x2dtics|x2mtics|xdtics|xmtics|y2dtics|y2mtics|ydtics|ymtics|z2dtics|z2mtics|zdtics|zmtics|x2zeroaxis|xzeroaxis|y2zeroaxis|yzeroaxis|z2zeroaxis|zeroaxis|zzeroaxis|zero|)\b
70+ scope: keyword.other.setting.gnuplot
71+ - match: \b(cd|call|clear|exit|plot|splot|help|load|pause|quit|fit|replot|if|FIT_LIMIT|FIT_MAXITER|FIT_START_LAMBDA|FIT_LAMBDA_FACTOR|FIT_LOG|FIT_SCRIPT|print|pwd|reread|reset|save|show|test|!|functions|var)\b
72+ comment: missuse of scopes alert! Just for pretty colours
73+ scope: keyword.other.command.gnuplot
74+ - match: \b(abs|acos|acosh|arg|asin|asinh|atan|atan2|atanh|besj0|besj1|besy0|besy1|ceil|cos|cosh|erf|erfc|exp|floor|gamma|ibeta|igamma|imag|int|inverf|invnorm|lambertw|lgamma|log|log10|norm|rand|real|sgn|sin|sinh|sqrt|tan|tanh)\b
75+ scope: support.function.gnuplot
76+ - match: \b(gprintf|sprintf|strlen|strstrt|substr|system|word|words)\b
77+ scope: support.function.string.gnuplot
78+ - match: \b(on|off|default|inside|outside|lmargin|rmargin|tmargin|bmargin|at|left|right|center|top|bottom|center|vertical|horizontal|Left|Right|noreverse|noinvert|samplen|spacing|width|height|noautotitle|columnheader|title|noenhanced|nobox|linestyle|ls|linetype|lt|linewidth|lw)\b
79+ scope: constant.other.type.gnuplot
80+ - match: \b(aed512|aed767|aifm|aqua|bitgraph|cgm|corel|dumb|dxf|eepic|emf|emtex|epslatex|epson_180dpi|epson_60dpi|epson_lx800|fig|gif|gpic|hp2623A|hp2648|hp500c|hpdj|hpgl|hpljii|hppj|imagen|jpeg|kc_tek40xx|km_tek40xx|latex|mf|mif|mp|nec_cp6|okidata|pbm|pcl5|pdf|png|postscript|pslatex|pstex|pstricks|qms|regis|selanar|starc|svg|tandy_60dpi|tek40xx|tek410x|texdraw|tgif|tkcanvas|tpic|unknown|vttek)\b
81+ scope: constant.other.terminal.gnuplot
82+ - match: \b(u(sing)?|t(it(le)?)?|notit(le)?|w(i(th)?)?|steps|fs(teps)?|notitle|l(i(nes)?)?|linespoints|via)\b
83+ scope: keyword.modifier.gnuplot
84+ - match: |-
85+ (?x:
86+ \b # Start with a word boundary
87+ (?=\b[\w$]*(\(|.*=)) # Look-ahead for a bracket or equals
88+ (?![^(]*\)) # negative look ahead for a closing bracket without an opening one. This stops a from matching in f(a)
89+ ( # Group variable name
90+ [A-Za-z] # A letter
91+ [\w$]* # Any word chars or $
92+ ) # That is it for the name.
93+ )
94+ comment: user defined function / variable
95+ scope: variable.other.gnuplot
96+ - match: \b(if)\b
97+ scope: keyword.control.gnuplot
98+ - match: \b(show)\b
99+ captures:
100+ 0: keyword.other.command.gnuplot
101+ push:
102+ - meta_scope: keyword.line.show.gnuplot
103+ - meta_content_scope: keyword.line.show.gnuplot
104+ - match: (?!\#)($\n?)
105+ pop: true
106+ - include: main
107+ - match: \b(set)\b\s*\b(terminal|term)\b
108+ captures:
109+ 1: keyword.other.command.gnuplot
110+ 2: keyword.other.setting.gnuplot
111+ push:
112+ - meta_scope: keyword.line.set.terminal.gnuplot
113+ - match: (?!\#)($\n?)
114+ pop: true
115+ - include: main
116+ - match: \b(set)\b\s*\b(key)\b
117+ captures:
118+ 1: keyword.other.command.gnuplot
119+ 2: keyword.other.setting.gnuplot
120+ push:
121+ - meta_scope: keyword.line.set.key.gnuplot
122+ - match: (?!\#)($\n?)
123+ pop: true
124+ - include: main
125+ - match: \b(set|unset)\b\s*(?!\b(terminal|key|for)\b)
126+ captures:
127+ 1: keyword.other.command.gnuplot
128+ 2: keyword.other.setting.gnuplot
129+ push:
130+ - meta_scope: keyword.line.set.gnuplot
131+ - meta_content_scope: keyword.line.set.gnuplot
132+ - match: (?!\#)($\n?)
133+ pop: true
134+ - include: main
135+ number:
136+ - match: |-
137+ (?x: # turn on extended mode
138+ -? # an optional minus
139+ (?:
140+ 0 # a zero
141+ | # ...or...
142+ [1-9] # a 1-9 character
143+ \d* # followed by zero or more digits
144+ )
145+ (?:
146+ \. # a period
147+ \d+ # followed by one or more digits
148+ (?:
149+ [eE] # an e character
150+ [+-]? # followed by an option +/-
151+ \d+ # followed by one or more digits
152+ )? # make exponent optional
153+ )? # make decimal portion optional
154+ )
155+ comment: borrowed from textmate book
156+ scope: constant.numeric.gnuplot
157+ operator:
158+ - match: \s*(==|~=|>|>=|<|<=|&|&&|:|\||\|\||\+|-|\*|\.\*|/|\./|\\|\.\\|\^|\.\^)\s*
159+ comment: Operator symbols
160+ scope: keyword.operator.symbols.matlab
161+ string_double:
162+ - match: '"'
163+ captures:
164+ 0: punctuation.definition.string.begin.gnuplot
165+ push:
166+ - meta_scope: string.quoted.double.gnuplot
167+ - match: '"'
168+ captures:
169+ 0: punctuation.definition.string.end.gnuplot
170+ pop: true
171+ - match: '\\[\$`"\\\n]'
172+ scope: constant.character.escape.gnuplot
173+ string_single:
174+ - match: "'"
175+ captures:
176+ 0: punctuation.definition.string.begin.gnuplot
177+ push:
178+ - meta_scope: string.quoted.single.gnuplot
179+ - match: "'"
180+ captures:
181+ 0: punctuation.definition.string.end.gnuplot
182+ pop: true
doc/README-ru.md+1−1
@@ -341,7 +341,7 @@ ansible-galaxy install aeimer.install_bat
341341
342342### Из исходников
343343
344−Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.40 или выше. После этого используйте `cargo`, чтобы все скомпилировать:
344+Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.42 или выше. После этого используйте `cargo`, чтобы все скомпилировать:
345345
346346```bash
347347cargo install --locked bat
doc/assets.md+1−1
@@ -23,7 +23,7 @@ in the `.sublime-syntax` format.
2323
24245. Use `bat --list-languages` to check if the new languages are available.
2525
26−6. Add a syntax test for the new language. See [#Syntax-tests](below) for details.
26+6. Add a syntax test for the new language. See [below](#Syntax-tests) for details.
2727
28287. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin`
2929 file. A new binary cache file will be created once before every new release of `bat`.
src/bin/bat/app.rs+3−3
@@ -150,10 +150,10 @@ impl App {
150150 wrapping_mode: if self.interactive_output || maybe_term_width.is_some() {
151151 match self.matches.value_of("wrap") {
152152 Some("character") => WrappingMode::Character,
153− Some("never") => WrappingMode::NoWrapping,
153+ Some("never") => WrappingMode::NoWrapping(true),
154154 Some("auto") | None => {
155155 if style_components.plain() {
156− WrappingMode::NoWrapping
156+ WrappingMode::NoWrapping(false)
157157 } else {
158158 WrappingMode::Character
159159 }
@@ -163,7 +163,7 @@ impl App {
163163 } else {
164164 // We don't have the tty width when piping to another program.
165165 // There's no point in wrapping when this is the case.
166− WrappingMode::NoWrapping
166+ WrappingMode::NoWrapping(false)
167167 },
168168 colored_output: self.matches.is_present("force-colorization")
169169 || match self.matches.value_of("color") {
src/bin/bat/input.rs+1−1
@@ -2,7 +2,7 @@ use bat::input::Input;
22use std::ffi::OsStr;
33
44pub fn new_file_input<'a>(file: &'a OsStr, name: Option<&'a OsStr>) -> Input<'a> {
5− named(Input::ordinary_file(file), name.or_else(|| Some(file)))
5+ named(Input::ordinary_file(file), name.or(Some(file)))
66}
77
88pub fn new_stdin_input(name: Option<&OsStr>) -> Input {
src/bin/bat/main.rs+3−2
@@ -205,7 +205,7 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
205205 and are added to the cache with `bat cache --build`. \
206206 For more information, see:\n\n \
207207 https://github.com/sharkdp/bat#adding-new-themes",
208− config_file().join("themes").to_string_lossy()
208+ PROJECT_DIRS.config_dir().join("themes").to_string_lossy()
209209 )?;
210210 } else {
211211 for theme in assets.themes() {
@@ -237,10 +237,10 @@ fn run() -> Result<bool> {
237237 .info(EnvironmentVariables::list(&[
238238 "SHELL",
239239 "PAGER",
240+ "BAT_PAGER",
240241 "BAT_CACHE_PATH",
241242 "BAT_CONFIG_PATH",
242243 "BAT_OPTS",
243− "BAT_PAGER",
244244 "BAT_STYLE",
245245 "BAT_TABS",
246246 "BAT_THEME",
@@ -248,6 +248,7 @@ fn run() -> Result<bool> {
248248 "XDG_CACHE_HOME",
249249 "COLORTERM",
250250 "NO_COLOR",
251+ "MANPAGER",
251252 ]))
252253 .info(FileContent::new("Config file", config_file()))
253254 .info(CompileTimeInformation::default())
src/input.rs+1−5
@@ -137,11 +137,7 @@ impl<'a> Input<'a> {
137137 }
138138
139139 pub fn is_stdin(&self) -> bool {
140− if let InputKind::StdIn = self.kind {
141− true
142− } else {
143− false
144− }
140+ matches!(self.kind, InputKind::StdIn)
145141 }
146142
147143 pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self {
src/output.rs+2−6
@@ -81,7 +81,7 @@ impl OutputType {
8181 p.arg("--quit-if-one-screen");
8282 }
8383
84− if wrapping_mode == WrappingMode::NoWrapping {
84+ if wrapping_mode == WrappingMode::NoWrapping(true) {
8585 p.arg("--chop-long-lines");
8686 }
8787
@@ -121,11 +121,7 @@ impl OutputType {
121121
122122 #[cfg(feature = "paging")]
123123 pub(crate) fn is_pager(&self) -> bool {
124− if let OutputType::Pager(_) = self {
125− true
126− } else {
127− false
128− }
124+ matches!(self, OutputType::Pager(_))
129125 }
130126
131127 #[cfg(not(feature = "paging"))]
src/pretty_printer.rs+6
@@ -320,6 +320,12 @@ impl<'a> PrettyPrinter<'a> {
320320 }
321321}
322322
323+impl Default for PrettyPrinter<'_> {
324+ fn default() -> Self {
325+ Self::new()
326+ }
327+}
328+
323329/// An input source for the pretty printer.
324330pub struct Input<'a> {
325331 input: input::Input<'a>,
src/printer.rs+1−1
@@ -424,7 +424,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
424424 }
425425
426426 // Line contents.
427− if self.config.wrapping_mode == WrappingMode::NoWrapping {
427+ if matches!(self.config.wrapping_mode, WrappingMode::NoWrapping(_)) {
428428 let true_color = self.config.true_color;
429429 let colored_output = self.config.colored_output;
430430 let italics = self.config.use_italic_text;
src/wrapping.rs+3−2
@@ -1,11 +1,12 @@
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22pub enum WrappingMode {
33 Character,
4− NoWrapping,
4+ // The bool specifies whether wrapping has been explicitly disabled by the user via --wrap=never
5+ NoWrapping(bool),
56}
67
78impl Default for WrappingMode {
89 fn default() -> Self {
9− WrappingMode::NoWrapping
10+ WrappingMode::NoWrapping(false)
1011 }
1112}
tests/assets.rs+1−1
@@ -8,7 +8,7 @@ fn all_themes_are_present() {
88 let assets = HighlightingAssets::from_binary();
99
1010 let mut themes: Vec<_> = assets.themes().collect();
11− themes.sort();
11+ themes.sort_unstable();
1212
1313 assert_eq!(
1414 themes,
tests/snapshot_tests.rs+1−1
@@ -7,7 +7,7 @@ macro_rules! snapshot_tests {
77 $(
88 #[test]
99 fn $test_name() {
10− let bat_tester = BatTester::new();
10+ let bat_tester = BatTester::default();
1111 bat_tester.test_snapshot(stringify!($test_name), $style);
1212 }
1313 )*
tests/syntax-tests/highlighted/gnuplot/test.gpnew file+19
@@ -0,0 +1,19 @@
1+set terminal pngcairo enhanced
2+set output "/tmp/polynomial.png"
3+
4+set grid
5+
6+set xrange [-5:5]
7+set yrange [-5:10]
8+
9+set samples 10000
10+
11+set key bottom right
12+
13+f(x) = 1.0 / 14.0 * ((x+4) * (x+1) * (x-1) * (x-3)) + 0.5
14+
15+plot \
16+ f(x) title "polynomial of degree 4" \
17+ with lines \
18+ linewidth 2 \
19+ linetype rgb '#0077ff'
tests/syntax-tests/source/gnuplot/test.gpnew file+19
@@ -0,0 +1,19 @@
1+set terminal pngcairo enhanced
2+set output "/tmp/polynomial.png"
3+
4+set grid
5+
6+set xrange [-5:5]
7+set yrange [-5:10]
8+
9+set samples 10000
10+
11+set key bottom right
12+
13+f(x) = 1.0 / 14.0 * ((x+4) * (x+1) * (x-1) * (x-3)) + 0.5
14+
15+plot \
16+ f(x) title "polynomial of degree 4" \
17+ with lines \
18+ linewidth 2 \
19+ linetype rgb '#0077ff'
tests/tester.rs+19−17
@@ -19,23 +19,6 @@ pub struct BatTester {
1919}
2020
2121impl BatTester {
22− pub fn new() -> Self {
23− let temp_dir = create_sample_directory().expect("sample directory");
24−
25− let root = env::current_exe()
26− .expect("tests executable")
27− .parent()
28− .expect("tests executable directory")
29− .parent()
30− .expect("bat executable directory")
31− .to_path_buf();
32−
33− let exe_name = if cfg!(windows) { "bat.exe" } else { "bat" };
34− let exe = root.join(exe_name);
35−
36− BatTester { temp_dir, exe }
37− }
38−
3922 pub fn test_snapshot(&self, name: &str, style: &str) {
4023 let output = Command::new(&self.exe)
4124 .current_dir(self.temp_dir.path())
@@ -66,6 +49,25 @@ impl BatTester {
6649 }
6750}
6851
52+impl Default for BatTester {
53+ fn default() -> Self {
54+ let temp_dir = create_sample_directory().expect("sample directory");
55+
56+ let root = env::current_exe()
57+ .expect("tests executable")
58+ .parent()
59+ .expect("tests executable directory")
60+ .parent()
61+ .expect("bat executable directory")
62+ .to_path_buf();
63+
64+ let exe_name = if cfg!(windows) { "bat.exe" } else { "bat" };
65+ let exe = root.join(exe_name);
66+
67+ BatTester { temp_dir, exe }
68+ }
69+}
70+
6971fn create_sample_directory() -> Result<TempDir, git2::Error> {
7072 // Create temp directory and initialize repository
7173 let temp_dir = TempDir::new("bat-tests").expect("Temp directory");