on master help sign in
Merge remote-tracking branch 'origin/master' into fix-1063
cc0f8caMartin Nordholts
.github/workflows/CICD.yml+21−8
@@ -22,6 +22,12 @@ jobs:
22 toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
22 toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
23 default: true
23 default: true
24 profile: minimal # minimal component installation (ie, no documentation)
24 profile: minimal # minimal component installation (ie, no documentation)
25+ components: clippy
26+ - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix)
27+ uses: actions-rs/cargo@v1
28+ with:
29+ command: clippy
30+ args: --all-targets --all-features
25 - name: Test
31 - name: Test
26 uses: actions-rs/cargo@v1
32 uses: actions-rs/cargo@v1
27 with:
33 with:
@@ -152,6 +158,8 @@ jobs:
152 echo ::set-output name=PKG_NAME::${PKG_NAME}
158 echo ::set-output name=PKG_NAME::${PKG_NAME}
153 # deployable tag? (ie, leading "vM" or "M"; M == version number)
159 # deployable tag? (ie, leading "vM" or "M"; M == version number)
154 unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
160 unset DEPLOY ; if [[ $REF_TAG =~ ^[vV]?[0-9].* ]]; then DEPLOY='true' ; fi
161+ # unset deploy on ubuntu-18.04 x64 - we will deploy the tarball/deb built on ubuntu-16.04 x64
162+ if [ "${{ matrix.job.os }}" = "ubuntu-18.04" ] && [ "${{ matrix.job.target }}" = "x86_64-unknown-linux-gnu" ]; then unset DEPLOY; fi
155 echo set-output name=DEPLOY::${DEPLOY:-<empty>/false}
163 echo set-output name=DEPLOY::${DEPLOY:-<empty>/false}
156 echo ::set-output name=DEPLOY::${DEPLOY}
164 echo ::set-output name=DEPLOY::${DEPLOY}
157 # DPKG architecture?
165 # DPKG architecture?
@@ -274,6 +282,7 @@ jobs:
274 shell: bash
282 shell: bash
275 run: |
283 run: |
276 ARCHIVE_DIR='${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
284 ARCHIVE_DIR='${{ steps.vars.outputs.STAGING }}/${{ steps.vars.outputs.PKG_BASENAME }}/'
285+ COPYRIGHT_YEARS="2018 - "$(date "+%Y")
277 # Binary
286 # Binary
278 cp 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "$ARCHIVE_DIR"
287 cp 'target/${{ matrix.job.target }}/release/${{ env.PROJECT_NAME }}${{ steps.vars.outputs.EXE_suffix }}' "$ARCHIVE_DIR"
279
288
@@ -283,8 +292,8 @@ jobs:
283 # Man page
292 # Man page
284 cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/manual/bat.1 "$ARCHIVE_DIR"
293 cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/manual/bat.1 "$ARCHIVE_DIR"
285
294
286− # README and LICENSE files
295+ # README, LICENSE and CHANGELOG files
287− cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "$ARCHIVE_DIR"
296+ cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "CHANGELOG.md" "$ARCHIVE_DIR"
288
297
289 # Autocompletion files
298 # Autocompletion files
290 cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.fish "$ARCHIVE_DIR/autocomplete/${{ env.PROJECT_NAME }}.fish"
299 cp 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.fish "$ARCHIVE_DIR/autocomplete/${{ env.PROJECT_NAME }}.fish"
@@ -308,24 +317,27 @@ jobs:
308
317
309 # Man page
318 # Man page
310 install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/manual/bat.1 "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"
319 install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/manual/bat.1 "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"
311− gzip --best "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"
320+ gzip -n --best "${DPKG_DIR}/usr/share/man/man1/${{ env.PROJECT_NAME }}.1"
312
321
313 # Autocompletion files
322 # Autocompletion files
314 install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.fish "${DPKG_DIR}/usr/share/fish/vendor_completions.d/${{ env.PROJECT_NAME }}.fish"
323 install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.fish "${DPKG_DIR}/usr/share/fish/vendor_completions.d/${{ env.PROJECT_NAME }}.fish"
315 install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.zsh "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ env.PROJECT_NAME }}"
324 install -Dm644 'target/${{ matrix.job.target }}/release/build/${{ env.PROJECT_NAME }}'-*/out/assets/completions/bat.zsh "${DPKG_DIR}/usr/share/zsh/vendor-completions/_${{ env.PROJECT_NAME }}"
316
325
317 # README and LICENSE
326 # README and LICENSE
318− install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/README.md"
327+ install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/README.md"
319− install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/LICENSE-MIT"
328+ install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/LICENSE-MIT"
320− install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/LICENSE-APACHE"
329+ install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/LICENSE-APACHE"
330+ install -Dm644 "CHANGELOG.md" "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/changelog"
331+ gzip -n --best "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/changelog"
321
332
322− cat > "${DPKG_DIR}/usr/share/doc/${{ env.PROJECT_NAME }}/copyright" <<EOF
333+ cat > "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/copyright" <<EOF
323 Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
334 Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
324 Upstream-Name: ${{ env.PROJECT_NAME }}
335 Upstream-Name: ${{ env.PROJECT_NAME }}
325 Source: ${{ env.PROJECT_HOMEPAGE }}
336 Source: ${{ env.PROJECT_HOMEPAGE }}
326
337
327 Files: *
338 Files: *
328 Copyright: ${{ env.PROJECT_MAINTAINER }}
339 Copyright: ${{ env.PROJECT_MAINTAINER }}
340+ Copyright: $COPYRIGHT_YEARS ${{ env.PROJECT_MAINTAINER }}
329 License: Apache-2.0 or MIT
341 License: Apache-2.0 or MIT
330
342
331 License: Apache-2.0
343 License: Apache-2.0
@@ -357,6 +369,7 @@ jobs:
357 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
369 IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
358 DEALINGS IN THE SOFTWARE.
370 DEALINGS IN THE SOFTWARE.
359 EOF
371 EOF
372+ chmod 644 "${DPKG_DIR}/usr/share/doc/${{ steps.vars.outputs.DPKG_BASENAME }}/copyright"
360
373
361 # control file
374 # control file
362 mkdir -p "${DPKG_DIR}/DEBIAN"
375 mkdir -p "${DPKG_DIR}/DEBIAN"
@@ -370,7 +383,7 @@ jobs:
370 Architecture: ${{ steps.vars.outputs.DPKG_ARCH }}
383 Architecture: ${{ steps.vars.outputs.DPKG_ARCH }}
371 Provides: ${{ env.PROJECT_NAME }}
384 Provides: ${{ env.PROJECT_NAME }}
372 Conflicts: ${{ steps.vars.outputs.DPKG_CONFLICTS }}
385 Conflicts: ${{ steps.vars.outputs.DPKG_CONFLICTS }}
373− Description: A cat(1) clone with wings.
386+ Description: cat(1) clone with wings.
374 A cat(1) clone with syntax highlighting and Git integration.
387 A cat(1) clone with syntax highlighting and Git integration.
375 EOF
388 EOF
376
389
.gitmodules+4−3
@@ -185,9 +185,6 @@
185[submodule "assets/syntaxes/02_Extra/AsciiDoc"]
185[submodule "assets/syntaxes/02_Extra/AsciiDoc"]
186 path = assets/syntaxes/02_Extra/AsciiDoc
186 path = assets/syntaxes/02_Extra/AsciiDoc
187 url = https://github.com/asciidoctor/sublimetext-asciidoc.git
187 url = https://github.com/asciidoctor/sublimetext-asciidoc.git
188−[submodule "assets/themes/gruvbox"]
189− path = assets/themes/gruvbox
190− url = https://github.com/peaceant/gruvbox.git
191[submodule "assets/syntaxes/02_Extra/GLSL"]
188[submodule "assets/syntaxes/02_Extra/GLSL"]
192 path = assets/syntaxes/02_Extra/GLSL
189 path = assets/syntaxes/02_Extra/GLSL
193 url = https://github.com/euler0/sublime-glsl
190 url = https://github.com/euler0/sublime-glsl
@@ -206,3 +203,7 @@
206[submodule "assets/themes/Coldark"]
203[submodule "assets/themes/Coldark"]
207 path = assets/themes/Coldark
204 path = assets/themes/Coldark
208 url = https://github.com/ArmandPhilippot/coldark-bat.git
205 url = https://github.com/ArmandPhilippot/coldark-bat.git
206+[submodule "assets/themes/gruvbox"]
207+ path = assets/themes/gruvbox
208+ url = https://github.com/subnut/gruvbox-tmTheme.git
209+ branch = bat-source
CHANGELOG.md+14
@@ -2,27 +2,41 @@
2
2
3
3
4## Features
4## Features
5+- Use a pager when `bat --list-languages` is called, see #1394 (@stku1985)
5
6
6## Bugfixes
7## Bugfixes
7
8
9+- If the last line doesn't end with a newline character, don't add it if `--style=plain`, see #1438 (@Enselic)
10+- Only print themes hint in interactive mode (`bat --list-themes`), see #1439 (@rsteube)
11+- Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic)
12+- VimL syntax highlighting fix, see #1450 (@esensar)
8- Ignore PAGER=most by default with a warning to stderr, but allow override with BAT_PAGER or --config, see #1063 (@Enselic)
13- Ignore PAGER=most by default with a warning to stderr, but allow override with BAT_PAGER or --config, see #1063 (@Enselic)
9
14
10## Other
15## Other
11
16
17+- Performance improvements, see #1421 (@LovecraftianHorror)
18+
12## Syntaxes
19## Syntaxes
13
20
14## New themes
21## New themes
15
22
23+- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12)
24+- 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.
25+
16## `bat` as a library
26## `bat` as a library
17
27
18## Packaging
28## Packaging
19
29
30+- `bat` is now available on snapstore with package name called `batcat`, see #1401 (@purveshpatel511)
31+
32+
20# v0.17.1
33# v0.17.1
21
34
22## Bugfixes
35## Bugfixes
23
36
24- Running `bat` without arguments fails ("output file is also an input"), see #1396
37- Running `bat` without arguments fails ("output file is also an input"), see #1396
25
38
39+
26# v0.17.0
40# v0.17.0
27
41
28## Features
42## Features
CONTRIBUTING.md+2−2
@@ -8,12 +8,12 @@ Thank you for considering to contribute to `bat`!
8
8
9If your contribution changes the behavior of `bat` (as opposed to a typo-fix
9If your contribution changes the behavior of `bat` (as opposed to a typo-fix
10in the documentation), please update the [`CHANGELOG.md`](CHANGELOG.md) file
10in the documentation), please update the [`CHANGELOG.md`](CHANGELOG.md) file
11−and describe your changes. This makes the release proess much easier and
11+and describe your changes. This makes the release process much easier and
12therefore helps to get your changes into a new `bat` release faster.
12therefore helps to get your changes into a new `bat` release faster.
13
13
14The top of the `CHANGELOG` contains a *"unreleased"* section with a few
14The top of the `CHANGELOG` contains a *"unreleased"* section with a few
15subsections (Features, Bugfixes, …). Please add your entry to the subsection
15subsections (Features, Bugfixes, …). Please add your entry to the subsection
16−that best describes your change
16+that best describes your change.
17
17
18Entries follow this format:
18Entries follow this format:
19```
19```
Cargo.lock+2−2
@@ -56,9 +56,9 @@ checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
56
56
57[[package]]
57[[package]]
58name = "assert_cmd"
58name = "assert_cmd"
59−version = "1.0.1"
59+version = "1.0.2"
60source = "registry+https://github.com/rust-lang/crates.io-index"
60source = "registry+https://github.com/rust-lang/crates.io-index"
61−checksum = "c88b9ca26f9c16ec830350d309397e74ee9abdfd8eb1f71cb6ecc71a3fc818da"
61+checksum = "3dc1679af9a1ab4bea16f228b05d18f8363f8327b1fa8db00d2760cfafc6b61e"
62dependencies = [
62dependencies = [
63 "doc-comment",
63 "doc-comment",
64 "predicates",
64 "predicates",
Cargo.toml+1−2
@@ -5,7 +5,6 @@ description="A cat(1) clone with wings."
5homepage = "https://github.com/sharkdp/bat"
5homepage = "https://github.com/sharkdp/bat"
6license = "MIT/Apache-2.0"
6license = "MIT/Apache-2.0"
7name = "bat"
7name = "bat"
8−readme = "README.md"
9repository = "https://github.com/sharkdp/bat"
8repository = "https://github.com/sharkdp/bat"
10version = "0.17.1"
9version = "0.17.1"
11exclude = [
10exclude = [
@@ -74,7 +73,7 @@ default-features = false
74
73
75[dev-dependencies]
74[dev-dependencies]
76tempdir = "0.3"
75tempdir = "0.3"
77−assert_cmd = "1.0.1"
76+assert_cmd = "1.0.2"
78predicates = "1.0.5"
77predicates = "1.0.5"
79
78
80[build-dependencies]
79[build-dependencies]
README.md+20−5
@@ -196,7 +196,7 @@ If your Ubuntu/Debian installation is new enough you can simply run:
196apt install bat
196apt install bat
197```
197```
198
198
199−If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name
199+**Important**: If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name
200clash with another package](https://github.com/sharkdp/bat/issues/982)). You can set up a `bat -> batcat` symlink or alias to prevent any issues that may come up because of this and to be consistent with other distributions:
200clash with another package](https://github.com/sharkdp/bat/issues/982)). You can set up a `bat -> batcat` symlink or alias to prevent any issues that may come up because of this and to be consistent with other distributions:
201``` bash
201``` bash
202mkdir -p ~/.local/bin
202mkdir -p ~/.local/bin
@@ -256,6 +256,13 @@ You can install `bat` via xbps-install:
256xbps-install -S bat
256xbps-install -S bat
257```
257```
258
258
259+### On Termux
260+
261+You can install `bat` via pkg:
262+```bash
263+pkg install bat
264+```
265+
259### On FreeBSD
266### On FreeBSD
260
267
261You can install a precompiled [`bat` package](https://www.freshports.org/textproc/bat) with pkg:
268You can install a precompiled [`bat` package](https://www.freshports.org/textproc/bat) with pkg:
@@ -287,6 +294,15 @@ You can install `bat` with zypper:
287zypper install bat
294zypper install bat
288```
295```
289
296
297+### Via snap package
298+
299+```
300+sudo snap install batcat
301+```
302+
303+[Get it from the Snap Store](https://snapcraft.io/batcat)
304+
305+
290### On macOS (or Linux) via Homebrew
306### On macOS (or Linux) via Homebrew
291
307
292You can install `bat` with [Homebrew on MacOS](https://formulae.brew.sh/formula/bat) or [Homebrew on Linux](https://formulae.brew.sh/formula-linux/bat):
308You can install `bat` with [Homebrew on MacOS](https://formulae.brew.sh/formula/bat) or [Homebrew on Linux](https://formulae.brew.sh/formula-linux/bat):
@@ -374,12 +390,11 @@ You can also use a custom theme by following the
374
390
375### 8-bit themes
391### 8-bit themes
376
392
377−`bat` has four themes that always use [8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors),
393+`bat` has three themes that always use [8-bit colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors),
378even when truecolor support is available:
394even when truecolor support is available:
379
395
380−- `ansi-dark` looks decent on any terminal with a dark background. It uses 3-bit colors: black, red,
396+- `ansi` looks decent on any terminal. It uses 3-bit colors: black, red, green,
381− green, yellow, blue, magenta, cyan, and white.
397+ yellow, blue, magenta, cyan, and white.
382−- `ansi-light` is like `ansi-dark`, but for terminals with a light background.
383- `base16` is designed for [base16](https://github.com/chriskempson/base16) terminal themes. It uses
398- `base16` is designed for [base16](https://github.com/chriskempson/base16) terminal themes. It uses
384 4-bit colors (3-bit colors plus bright variants) in accordance with the
399 4-bit colors (3-bit colors plus bright variants) in accordance with the
385 [base16 styling guidelines](https://github.com/chriskempson/base16/blob/master/styling.md).
400 [base16 styling guidelines](https://github.com/chriskempson/base16/blob/master/styling.md).
assets/syntaxes.bin

Binary file not shown.

assets/syntaxes/02_Extra/AWK+1−1

Submodule changed.

assets/syntaxes/02_Extra/GraphQL+1−1

Submodule changed.

assets/syntaxes/02_Extra/Svelte+1−1

Submodule changed.

assets/syntaxes/02_Extra/VimL+1−1

Submodule changed.

assets/syntaxes/02_Extra/VimL.sublime-syntax+2−2
@@ -75,10 +75,10 @@ contexts:
75 - match: '''(''''|\n[^\S\n]*\\|[^\n''])*'''
75 - match: '''(''''|\n[^\S\n]*\\|[^\n''])*'''
76 scope: string.quoted.single.viml
76 scope: string.quoted.single.viml
77 string_regex:
77 string_regex:
78− - match: '/(\\\\|\\/|\n[^\S\n]*\\|[^\n/])*/'
78+ - match: '[gvs]{1}/(\\\\|\\/|\n[^\S\n]*\\|[^\n/])*/'
79 scope: string.regexp.viml
79 scope: string.regexp.viml
80 support_function:
80 support_function:
81− - match: \b(set(local|global)?|let|command|filetype|colorscheme|\w*map|\w*a(b|brev)?|syn|exe(c|cute)?|ec(ho|)?|au(tocmd|)?)\b
81+ - match: \b(set(local|global)?|let|command|filetype|syntax|colorscheme|\w*map|\w*a(b|brev)?|syn|exe(c|cute)?|ec(ho|)?|au(tocmd|)?)\b
82 scope: support.function.viml
82 scope: support.function.viml
83 support_type:
83 support_type:
84 - match: <.*?>
84 - match: <.*?>
assets/syntaxes/02_Extra/ssh-config+1−1

Submodule changed.

assets/themes.bin

Binary file not shown.

assets/themes/Coldark+1−1

Submodule changed.

assets/themes/ansi-light.tmThemedeleted−504
@@ -1,504 +0,0 @@
1−<?xml version="1.0" encoding="UTF-8"?>
2−<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3−<plist version="1.0">
4− <dict>
5− <!--
6− The colors in this theme are encoded as #RRGGBBAA where RR is an ANSI
7− palette number from 00 to 0f, and AA is the special value 00 to indicate
8− that this encoding is being used.
9− -->
10− <key>author</key>
11− <string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
12− <key>name</key>
13− <string>ANSI Light</string>
14− <key>colorSpaceName</key>
15− <string>sRGB</string>
16− <key>settings</key>
17− <array>
18− <dict>
19− <key>settings</key>
20− <dict>
21− <key>background</key>
22− <string>#07000000</string>
23− <key>caret</key>
24− <string>#00000000</string>
25− <key>foreground</key>
26− <string>#00000000</string>
27− <key>invisibles</key>
28− <string>#00000000</string>
29− <key>lineHighlight</key>
30− <string>#00000000</string>
31− <key>selection</key>
32− <string>#00000000</string>
33− <key>gutter</key>
34− <string>#07000000</string>
35− <key>gutterForeground</key>
36− <string>#00000000</string>
37− </dict>
38− </dict>
39− <dict>
40− <key>name</key>
41− <string>Text</string>
42− <key>scope</key>
43− <string>variable.parameter.function</string>
44− <key>settings</key>
45− <dict>
46− <key>foreground</key>
47− <string>#00000000</string>
48− </dict>
49− </dict>
50− <dict>
51− <key>name</key>
52− <string>Comments</string>
53− <key>scope</key>
54− <string>comment, punctuation.definition.comment</string>
55− <key>settings</key>
56− <dict>
57− <key>foreground</key>
58− <string>#02000000</string>
59− </dict>
60− </dict>
61− <dict>
62− <key>name</key>
63− <string>Punctuation</string>
64− <key>scope</key>
65− <string>punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array</string>
66− <key>settings</key>
67− <dict>
68− <key>foreground</key>
69− <string>#00000000</string>
70− </dict>
71− </dict>
72− <dict>
73− <key>name</key>
74− <string>Delimiters</string>
75− <key>scope</key>
76− <string>none</string>
77− <key>settings</key>
78− <dict>
79− <key>foreground</key>
80− <string>#00000000</string>
81− </dict>
82− </dict>
83− <dict>
84− <key>name</key>
85− <string>Operators</string>
86− <key>scope</key>
87− <string>keyword.operator</string>
88− <key>settings</key>
89− <dict>
90− <key>foreground</key>
91− <string>#00000000</string>
92− </dict>
93− </dict>
94− <dict>
95− <key>name</key>
96− <string>Keywords</string>
97− <key>scope</key>
98− <string>keyword</string>
99− <key>settings</key>
100− <dict>
101− <key>foreground</key>
102− <string>#05000000</string>
103− </dict>
104− </dict>
105− <dict>
106− <key>name</key>
107− <string>Variables</string>
108− <key>scope</key>
109− <string>variable</string>
110− <key>settings</key>
111− <dict>
112− <key>foreground</key>
113− <string>#00000000</string>
114− </dict>
115− </dict>
116− <dict>
117− <key>name</key>
118− <string>Functions</string>
119− <key>scope</key>
120− <string>entity.name.function, meta.require, support.function.any-method</string>
121− <key>settings</key>
122− <dict>
123− <key>foreground</key>
124− <string>#04000000</string>
125− </dict>
126− </dict>
127− <dict>
128− <key>name</key>
129− <string>Labels</string>
130− <key>scope</key>
131− <string>entity.name.label</string>
132− <key>settings</key>
133− <dict>
134− <key>foreground</key>
135− <string>#06000000</string>
136− </dict>
137− </dict>
138− <dict>
139− <key>name</key>
140− <string>Classes</string>
141− <key>scope</key>
142− <string>support.class, entity.name.class, entity.name.type.class</string>
143− <key>settings</key>
144− <dict>
145− <key>foreground</key>
146− <string>#03000000</string>
147− </dict>
148− </dict>
149− <dict>
150− <key>name</key>
151− <string>Classes</string>
152− <key>scope</key>
153− <string>meta.class</string>
154− <key>settings</key>
155− <dict>
156− <key>foreground</key>
157− <string>#00000000</string>
158− </dict>
159− </dict>
160− <dict>
161− <key>name</key>
162− <string>Methods</string>
163− <key>scope</key>
164− <string>keyword.other.special-method</string>
165− <key>settings</key>
166− <dict>
167− <key>foreground</key>
168− <string>#04000000</string>
169− </dict>
170− </dict>
171− <dict>
172− <key>name</key>
173− <string>Storage</string>
174− <key>scope</key>
175− <string>storage</string>
176− <key>settings</key>
177− <dict>
178− <key>foreground</key>
179− <string>#05000000</string>
180− </dict>
181− </dict>
182− <dict>
183− <key>name</key>
184− <string>Support</string>
185− <key>scope</key>
186− <string>support.function</string>
187− <key>settings</key>
188− <dict>
189− <key>foreground</key>
190− <string>#06000000</string>
191− </dict>
192− </dict>
193− <dict>
194− <key>name</key>
195− <string>Strings, Inherited Class</string>
196− <key>scope</key>
197− <string>string, constant.other.symbol, entity.other.inherited-class</string>
198− <key>settings</key>
199− <dict>
200− <key>foreground</key>
201− <string>#02000000</string>
202− </dict>
203− </dict>
204− <dict>
205− <key>name</key>
206− <string>Integers</string>
207− <key>scope</key>
208− <string>constant.numeric</string>
209− <key>settings</key>
210− <dict>
211− <key>foreground</key>
212− <string>#03000000</string>
213− </dict>
214− </dict>
215− <dict>
216− <key>name</key>
217− <string>Floats</string>
218− <key>scope</key>
219− <string>none</string>
220− <key>settings</key>
221− <dict>
222− <key>foreground</key>
223− <string>#03000000</string>
224− </dict>
225− </dict>
226− <dict>
227− <key>name</key>
228− <string>Boolean</string>
229− <key>scope</key>
230− <string>none</string>
231− <key>settings</key>
232− <dict>
233− <key>foreground</key>
234− <string>#03000000</string>
235− </dict>
236− </dict>
237− <dict>
238− <key>name</key>
239− <string>Constants</string>
240− <key>scope</key>
241− <string>constant</string>
242− <key>settings</key>
243− <dict>
244− <key>foreground</key>
245− <string>#03000000</string>
246− </dict>
247− </dict>
248− <dict>
249− <key>name</key>
250− <string>Tags</string>
251− <key>scope</key>
252− <string>entity.name.tag</string>
253− <key>settings</key>
254− <dict>
255− <key>foreground</key>
256− <string>#01000000</string>
257− </dict>
258− </dict>
259− <dict>
260− <key>name</key>
261− <string>Attributes</string>
262− <key>scope</key>
263− <string>entity.other.attribute-name</string>
264− <key>settings</key>
265− <dict>
266− <key>foreground</key>
267− <string>#03000000</string>
268− </dict>
269− </dict>
270− <dict>
271− <key>name</key>
272− <string>Attribute IDs</string>
273− <key>scope</key>
274− <string>entity.other.attribute-name.id, punctuation.definition.entity</string>
275− <key>settings</key>
276− <dict>
277− <key>foreground</key>
278− <string>#04000000</string>
279− </dict>
280− </dict>
281− <dict>
282− <key>name</key>
283− <string>Selector</string>
284− <key>scope</key>
285− <string>meta.selector</string>
286− <key>settings</key>
287− <dict>
288− <key>foreground</key>
289− <string>#05000000</string>
290− </dict>
291− </dict>
292− <dict>
293− <key>name</key>
294− <string>Values</string>
295− <key>scope</key>
296− <string>none</string>
297− <key>settings</key>
298− <dict>
299− <key>foreground</key>
300− <string>#03000000</string>
301− </dict>
302− </dict>
303− <dict>
304− <key>name</key>
305− <string>Headings</string>
306− <key>scope</key>
307− <string>markup.heading punctuation.definition.heading, entity.name.section</string>
308− <key>settings</key>
309− <dict>
310− <key>fontStyle</key>
311− <string></string>
312− <key>foreground</key>
313− <string>#04000000</string>
314− </dict>
315− </dict>
316− <dict>
317− <key>name</key>
318− <string>Units</string>
319− <key>scope</key>
320− <string>keyword.other.unit</string>
321− <key>settings</key>
322− <dict>
323− <key>foreground</key>
324− <string>#03000000</string>
325− </dict>
326− </dict>
327− <dict>
328− <key>name</key>
329− <string>Bold</string>
330− <key>scope</key>
331− <string>markup.bold, punctuation.definition.bold</string>
332− <key>settings</key>
333− <dict>
334− <key>fontStyle</key>
335− <string>bold</string>
336− <key>foreground</key>
337− <string>#03000000</string>
338− </dict>
339− </dict>
340− <dict>
341− <key>name</key>
342− <string>Italic</string>
343− <key>scope</key>
344− <string>markup.italic, punctuation.definition.italic</string>
345− <key>settings</key>
346− <dict>
347− <key>fontStyle</key>
348− <string>italic</string>
349− <key>foreground</key>
350− <string>#05000000</string>
351− </dict>
352− </dict>
353− <dict>
354− <key>name</key>
355− <string>Code</string>
356− <key>scope</key>
357− <string>markup.raw.inline</string>
358− <key>settings</key>
359− <dict>
360− <key>foreground</key>
361− <string>#02000000</string>
362− </dict>
363− </dict>
364− <dict>
365− <key>name</key>
366− <string>Link Text</string>
367− <key>scope</key>
368− <string>string.other.link, punctuation.definition.string.end.markdown, punctuation.definition.string.begin.markdown</string>
369− <key>settings</key>
370− <dict>
371− <key>foreground</key>
372− <string>#01000000</string>
373− </dict>
374− </dict>
375− <dict>
376− <key>name</key>
377− <string>Link Url</string>
378− <key>scope</key>
379− <string>meta.link</string>
380− <key>settings</key>
381− <dict>
382− <key>foreground</key>
383− <string>#03000000</string>
384− </dict>
385− </dict>
386− <dict>
387− <key>name</key>
388− <string>Quotes</string>
389− <key>scope</key>
390− <string>markup.quote</string>
391− <key>settings</key>
392− <dict>
393− <key>foreground</key>
394− <string>#03000000</string>
395− </dict>
396− </dict>
397− <dict>
398− <key>name</key>
399− <string>Inserted</string>
400− <key>scope</key>
401− <string>markup.inserted</string>
402− <key>settings</key>
403− <dict>
404− <key>foreground</key>
405− <string>#02000000</string>
406− </dict>
407− </dict>
408− <dict>
409− <key>name</key>
410− <string>Deleted</string>
411− <key>scope</key>
412− <string>markup.deleted</string>
413− <key>settings</key>
414− <dict>
415− <key>foreground</key>
416− <string>#01000000</string>
417− </dict>
418− </dict>
419− <dict>
420− <key>name</key>
421− <string>Changed</string>
422− <key>scope</key>
423− <string>markup.changed</string>
424− <key>settings</key>
425− <dict>
426− <key>foreground</key>
427− <string>#05000000</string>
428− </dict>
429− </dict>
430− <dict>
431− <key>name</key>
432− <string>Colors</string>
433− <key>scope</key>
434− <string>constant.other.color</string>
435− <key>settings</key>
436− <dict>
437− <key>foreground</key>
438− <string>#06000000</string>
439− </dict>
440− </dict>
441− <dict>
442− <key>name</key>
443− <string>Regular Expressions</string>
444− <key>scope</key>
445− <string>string.regexp</string>
446− <key>settings</key>
447− <dict>
448− <key>foreground</key>
449− <string>#06000000</string>
450− </dict>
451− </dict>
452− <dict>
453− <key>name</key>
454− <string>Escape Characters</string>
455− <key>scope</key>
456− <string>constant.character.escape</string>
457− <key>settings</key>
458− <dict>
459− <key>foreground</key>
460− <string>#06000000</string>
461− </dict>
462− </dict>
463− <dict>
464− <key>name</key>
465− <string>Embedded</string>
466− <key>scope</key>
467− <string>punctuation.section.embedded, variable.interpolation</string>
468− <key>settings</key>
469− <dict>
470− <key>foreground</key>
471− <string>#05000000</string>
472− </dict>
473− </dict>
474− <dict>
475− <key>name</key>
476− <string>Illegal</string>
477− <key>scope</key>
478− <string>invalid.illegal</string>
479− <key>settings</key>
480− <dict>
481− <key>background</key>
482− <string>#01000000</string>
483− <key>foreground</key>
484− <string>#00000000</string>
485− </dict>
486− </dict>
487− <dict>
488− <key>name</key>
489− <string>Broken</string>
490− <key>scope</key>
491− <string>invalid.broken</string>
492− <key>settings</key>
493− <dict>
494− <key>background</key>
495− <string>#03000000</string>
496− <key>foreground</key>
497− <string>#07000000</string>
498− </dict>
499− </dict>
500− </array>
501− <key>uuid</key>
502− <string>uuid</string>
503− </dict>
504−</plist>
assets/themes/ansi-dark.tmTheme → assets/themes/ansi.tmThemerenamed+13−87
@@ -3,14 +3,14 @@
3<plist version="1.0">
3<plist version="1.0">
4 <dict>
4 <dict>
5 <!--
5 <!--
6− The colors in this theme are encoded as #RRGGBBAA where RR is an ANSI
6+ The colors in this theme are encoded as #RRGGBBAA where:
7− palette number from 00 to 0f, and AA is the special value 00 to indicate
7+ * If AA is 00, then RR is an ANSI palette number from 00 to 07.
8− that this encoding is being used.
8+ * If AA is 01, the terminal's default fg/bg color is used.
9 -->
9 -->
10 <key>author</key>
10 <key>author</key>
11 <string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
11 <string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
12 <key>name</key>
12 <key>name</key>
13− <string>ANSI Dark</string>
13+ <string>ANSI</string>
14 <key>colorSpaceName</key>
14 <key>colorSpaceName</key>
15 <string>sRGB</string>
15 <string>sRGB</string>
16 <key>settings</key>
16 <key>settings</key>
@@ -19,32 +19,17 @@
19 <key>settings</key>
19 <key>settings</key>
20 <dict>
20 <dict>
21 <key>background</key>
21 <key>background</key>
22− <string>#00000000</string>
22+ <string>#00000001</string>
23− <key>caret</key>
24− <string>#07000000</string>
25− <key>foreground</key>
23+ <key>foreground</key>
26− <string>#07000000</string>
24+ <string>#00000001</string>
27− <key>invisibles</key>
25+ <!--
28− <string>#07000000</string>
26+ Explicitly set the gutter color since bat falls back to a
29− <key>lineHighlight</key>
27+ hardcoded DEFAULT_GUTTER_COLOR otherwise.
30− <string>#07000000</string>
28+ -->
31− <key>selection</key>
32− <string>#07000000</string>
33 <key>gutter</key>
29 <key>gutter</key>
34− <string>#00000000</string>
30+ <string>#00000001</string>
35 <key>gutterForeground</key>
31 <key>gutterForeground</key>
36− <string>#07000000</string>
32+ <string>#00000001</string>
37− </dict>
38− </dict>
39− <dict>
40− <key>name</key>
41− <string>Text</string>
42− <key>scope</key>
43− <string>variable.parameter.function</string>
44− <key>settings</key>
45− <dict>
46− <key>foreground</key>
47− <string>#07000000</string>
48 </dict>
33 </dict>
49 </dict>
34 </dict>
50 <dict>
35 <dict>
@@ -58,39 +43,6 @@
58 <string>#02000000</string>
43 <string>#02000000</string>
59 </dict>
44 </dict>
60 </dict>
45 </dict>
61− <dict>
62− <key>name</key>
63− <string>Punctuation</string>
64− <key>scope</key>
65− <string>punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array</string>
66− <key>settings</key>
67− <dict>
68− <key>foreground</key>
69− <string>#07000000</string>
70− </dict>
71− </dict>
72− <dict>
73− <key>name</key>
74− <string>Delimiters</string>
75− <key>scope</key>
76− <string>none</string>
77− <key>settings</key>
78− <dict>
79− <key>foreground</key>
80− <string>#07000000</string>
81− </dict>
82− </dict>
83− <dict>
84− <key>name</key>
85− <string>Operators</string>
86− <key>scope</key>
87− <string>keyword.operator</string>
88− <key>settings</key>
89− <dict>
90− <key>foreground</key>
91− <string>#07000000</string>
92− </dict>
93− </dict>
94 <dict>
46 <dict>
95 <key>name</key>
47 <key>name</key>
96 <string>Keywords</string>
48 <string>Keywords</string>
@@ -102,17 +54,6 @@
102 <string>#05000000</string>
54 <string>#05000000</string>
103 </dict>
55 </dict>
104 </dict>
56 </dict>
105− <dict>
106− <key>name</key>
107− <string>Variables</string>
108− <key>scope</key>
109− <string>variable</string>
110− <key>settings</key>
111− <dict>
112− <key>foreground</key>
113− <string>#07000000</string>
114− </dict>
115− </dict>
116 <dict>
57 <dict>
117 <key>name</key>
58 <key>name</key>
118 <string>Functions</string>
59 <string>Functions</string>
@@ -146,17 +87,6 @@
146 <string>#03000000</string>
87 <string>#03000000</string>
147 </dict>
88 </dict>
148 </dict>
89 </dict>
149− <dict>
150− <key>name</key>
151− <string>Classes</string>
152− <key>scope</key>
153− <string>meta.class</string>
154− <key>settings</key>
155− <dict>
156− <key>foreground</key>
157− <string>#07000000</string>
158− </dict>
159− </dict>
160 <dict>
90 <dict>
161 <key>name</key>
91 <key>name</key>
162 <string>Methods</string>
92 <string>Methods</string>
@@ -480,8 +410,6 @@
480 <dict>
410 <dict>
481 <key>background</key>
411 <key>background</key>
482 <string>#01000000</string>
412 <string>#01000000</string>
483− <key>foreground</key>
484− <string>#07000000</string>
485 </dict>
413 </dict>
486 </dict>
414 </dict>
487 <dict>
415 <dict>
@@ -493,8 +421,6 @@
493 <dict>
421 <dict>
494 <key>background</key>
422 <key>background</key>
495 <string>#03000000</string>
423 <string>#03000000</string>
496− <key>foreground</key>
497− <string>#00000000</string>
498 </dict>
424 </dict>
499 </dict>
425 </dict>
500 </array>
426 </array>
assets/themes/gruvbox+1−1

Submodule changed.

diagnostics/info.sh+6−4
@@ -58,7 +58,8 @@ _bat_:run() {
58 _out "$BAT" --version
58 _out "$BAT" --version
59 _out env | grep '^BAT_\|^PAGER='
59 _out env | grep '^BAT_\|^PAGER='
60
60
61− local cache_dir="$($BAT --cache-dir)"
61+ local cache_dir
62+ cache_dir="$($BAT --cache-dir)"
62 if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
63 if [[ -f "${cache_dir}/syntaxes.bin" ]]; then
63 _print_command "$BAT" "--list-languages"
64 _print_command "$BAT" "--list-languages"
64 echo "Found custom syntax set."
65 echo "Found custom syntax set."
@@ -79,8 +80,8 @@ _bat_config_:run() {
79_bat_wrapper_:run() {
80_bat_wrapper_:run() {
80 _bat_wrapper_:detect_wrapper() {
81 _bat_wrapper_:detect_wrapper() {
81 local bat="$1"
82 local bat="$1"
82− if file "$(which "${bat}")" | grep "text executable" &> /dev/null; then
83+ if file "$(command -v "${bat}")" | grep "text executable" &> /dev/null; then
83− _out_fence cat "$(which "${bat}")"
84+ _out_fence cat "$(command -v "${bat}")"
84 return
85 return
85 fi
86 fi
86
87
@@ -104,7 +105,8 @@ _bat_wrapper_function_:run() {
104 fi ;;
105 fi ;;
105
106
106 *bash* | *zsh*)
107 *bash* | *zsh*)
108+ local type
107− local type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
109+ type="$("$SHELL" --login -i -c "type ${command}" 2>&1)"
108 if grep 'function' <<< "$type" &> /dev/null; then
110 if grep 'function' <<< "$type" &> /dev/null; then
109 _out_fence "$SHELL" --login -i -c "declare -f ${command}"
111 _out_fence "$SHELL" --login -i -c "declare -f ${command}"
110 return
112 return
src/assets.rs+6−6
@@ -11,6 +11,7 @@ use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder};
11use path_abs::PathAbs;
11use path_abs::PathAbs;
12
12
13use crate::assets_metadata::AssetsMetadata;
13use crate::assets_metadata::AssetsMetadata;
14+use crate::bat_warning;
14use crate::error::*;
15use crate::error::*;
15use crate::input::{InputReader, OpenedInput, OpenedInputKind};
16use crate::input::{InputReader, OpenedInput, OpenedInputKind};
16use crate::syntax_mapping::{MappingTarget, SyntaxMapping};
17use crate::syntax_mapping::{MappingTarget, SyntaxMapping};
@@ -189,13 +190,12 @@ impl HighlightingAssets {
189 match self.theme_set.themes.get(theme) {
190 match self.theme_set.themes.get(theme) {
190 Some(theme) => theme,
191 Some(theme) => theme,
191 None => {
192 None => {
193+ if theme == "ansi-light" || theme == "ansi-dark" {
194+ bat_warning!("Theme '{}' is deprecated, using 'ansi' instead.", theme);
195+ return self.get_theme("ansi");
196+ }
192 if theme != "" {
197 if theme != "" {
193− use ansi_term::Colour::Yellow;
194− eprintln!(
195− "{}: Unknown theme '{}', using default.",
198+ bat_warning!("Unknown theme '{}', using default.", theme)
196− Yellow.paint("[bat warning]"),
197− theme
198− );
199 }
199 }
200 &self.theme_set.themes[self.fallback_theme.unwrap_or_else(|| Self::default_theme())]
200 &self.theme_set.themes[self.fallback_theme.unwrap_or_else(|| Self::default_theme())]
201 }
201 }
src/bin/bat/app.rs+5−9
@@ -16,6 +16,7 @@ use console::Term;
16use crate::input::{new_file_input, new_stdin_input};
16use crate::input::{new_file_input, new_stdin_input};
17use bat::{
17use bat::{
18 assets::HighlightingAssets,
18 assets::HighlightingAssets,
19+ bat_warning,
19 config::{Config, VisibleLines},
20 config::{Config, VisibleLines},
20 error::*,
21 error::*,
21 input::Input,
22 input::Input,
@@ -82,10 +83,9 @@ impl App {
82 Some("always") => PagingMode::Always,
83 Some("always") => PagingMode::Always,
83 Some("never") => PagingMode::Never,
84 Some("never") => PagingMode::Never,
84 Some("auto") | None => {
85 Some("auto") | None => {
85− if self.matches.occurrences_of("plain") > 1 {
86− // If we have -pp as an option when in auto mode, the pager should be disabled.
86+ // If we have -pp as an option when in auto mode, the pager should be disabled.
87− PagingMode::Never
87+ let extra_plain = self.matches.occurrences_of("plain") > 1;
88− } else if self.matches.is_present("no-paging") {
88+ if extra_plain || self.matches.is_present("no-paging") {
89 PagingMode::Never
89 PagingMode::Never
90 } else if inputs.iter().any(Input::is_stdin) {
90 } else if inputs.iter().any(Input::is_stdin) {
91 // If we are reading from stdin, only enable paging if we write to an
91 // If we are reading from stdin, only enable paging if we write to an
@@ -323,11 +323,7 @@ impl App {
323
323
324 // If `grid` is set, remove `rule` as it is a subset of `grid`, and print a warning.
324 // If `grid` is set, remove `rule` as it is a subset of `grid`, and print a warning.
325 if styled_components.grid() && styled_components.0.remove(&StyleComponent::Rule) {
325 if styled_components.grid() && styled_components.0.remove(&StyleComponent::Rule) {
326− use ansi_term::Colour::Yellow;
327− eprintln!(
328− "{}: Style 'rule' is a subset of style 'grid', 'rule' will not be visible.",
326+ bat_warning!("Style 'rule' is a subset of style 'grid', 'rule' will not be visible.");
329− Yellow.paint("[bat warning]"),
330− );
331 }
327 }
332
328
333 Ok(styled_components)
329 Ok(styled_components)
src/bin/bat/main.rs+27−21
@@ -36,6 +36,7 @@ use bat::{
36 input::Input,
36 input::Input,
37 style::{StyleComponent, StyleComponents},
37 style::{StyleComponent, StyleComponents},
38 MappingTarget,
38 MappingTarget,
39+ PagingMode,
39};
40};
40
41
41const THEME_PREVIEW_DATA: &[u8] = include_bytes!("../../../assets/theme_preview.rs");
42const THEME_PREVIEW_DATA: &[u8] = include_bytes!("../../../assets/theme_preview.rs");
@@ -78,7 +79,9 @@ fn get_syntax_mapping_to_paths<'a>(
78 map
79 map
79}
80}
80
81
81−pub fn list_languages(config: &Config) -> Result<()> {
82+pub fn get_languages(config: &Config) -> Result<String> {
83+ let mut result: String = String::new();
84+
82 let assets = assets_from_cache_or_binary()?;
85 let assets = assets_from_cache_or_binary()?;
83 let mut languages = assets
86 let mut languages = assets
84 .syntaxes()
87 .syntaxes()
@@ -119,12 +122,9 @@ pub fn list_languages(config: &Config) -> Result<()> {
119 }
122 }
120 }
123 }
121
124
122− let stdout = io::stdout();
123− let mut stdout = stdout.lock();
124−
125 if config.loop_through {
125 if config.loop_through {
126 for lang in languages {
126 for lang in languages {
127− writeln!(stdout, "{}:{}", lang.name, lang.file_extensions.join(","))?;
127+ result += &format!("{}:{}\n", lang.name, lang.file_extensions.join(","));
128 }
128 }
129 } else {
129 } else {
130 let longest = languages
130 let longest = languages
@@ -145,7 +145,7 @@ pub fn list_languages(config: &Config) -> Result<()> {
145 };
145 };
146
146
147 for lang in languages {
147 for lang in languages {
148− write!(stdout, "{:width$}{}", lang.name, separator, width = longest)?;
148+ result += &format!("{:width$}{}", lang.name, separator, width = longest);
149
149
150 // Number of characters on this line so far, wrap before `desired_width`
150 // Number of characters on this line so far, wrap before `desired_width`
151 let mut num_chars = 0;
151 let mut num_chars = 0;
@@ -156,20 +156,20 @@ pub fn list_languages(config: &Config) -> Result<()> {
156 let new_chars = word.len() + comma_separator.len();
156 let new_chars = word.len() + comma_separator.len();
157 if num_chars + new_chars >= desired_width {
157 if num_chars + new_chars >= desired_width {
158 num_chars = 0;
158 num_chars = 0;
159− write!(stdout, "\n{:width$}{}", "", separator, width = longest)?;
159+ result += &format!("\n{:width$}{}", "", separator, width = longest);
160 }
160 }
161
161
162 num_chars += new_chars;
162 num_chars += new_chars;
163− write!(stdout, "{}", style.paint(&word[..]))?;
163+ result += &format!("{}", style.paint(&word[..]));
164 if extension.peek().is_some() {
164 if extension.peek().is_some() {
165− write!(stdout, "{}", comma_separator)?;
165+ result += comma_separator;
166 }
166 }
167 }
167 }
168− writeln!(stdout)?;
168+ result += "\n";
169 }
169 }
170 }
170 }
171
171
172− Ok(())
172+ Ok(result)
173}
173}
174
174
175fn theme_preview_file<'a>() -> Input<'a> {
175fn theme_preview_file<'a>() -> Input<'a> {
@@ -200,19 +200,19 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
200 .ok();
200 .ok();
201 writeln!(stdout)?;
201 writeln!(stdout)?;
202 }
202 }
203+ writeln!(
204+ stdout,
205+ "Further themes can be installed to '{}', \
206+ and are added to the cache with `bat cache --build`. \
207+ For more information, see:\n\n \
208+ https://github.com/sharkdp/bat#adding-new-themes",
209+ config_file().join("themes").to_string_lossy()
210+ )?;
203 } else {
211 } else {
204 for theme in assets.themes() {
212 for theme in assets.themes() {
205 writeln!(stdout, "{}", theme)?;
213 writeln!(stdout, "{}", theme)?;
206 }
214 }
207 }
215 }
208− writeln!(
209− stdout,
210− "Further themes can be installed to '{}', \
211− and are added to the cache with `bat cache --build`. \
212− For more information, see:\n\n \
213− https://github.com/sharkdp/bat#adding-new-themes",
214− config_file().join("themes").to_string_lossy()
215− )?;
216
216
217 Ok(())
217 Ok(())
218}
218}
@@ -248,8 +248,14 @@ fn run() -> Result<bool> {
248 let config = app.config(&inputs)?;
248 let config = app.config(&inputs)?;
249
249
250 if app.matches.is_present("list-languages") {
250 if app.matches.is_present("list-languages") {
251− list_languages(&config)?;
251+ let languages: String = get_languages(&config)?;
252− Ok(true)
252+ let inputs: Vec<Input> = vec![Input::from_reader(Box::new(languages.as_bytes()))];
253+ let plain_config = Config {
254+ style_components: StyleComponents::new(StyleComponent::Plain.components(false)),
255+ paging_mode: PagingMode::QuitIfOneScreen,
256+ ..Default::default()
257+ };
258+ run_controller(inputs, &plain_config)
253 } else if app.matches.is_present("list-themes") {
259 } else if app.matches.is_present("list-themes") {
254 list_themes(&config)?;
260 list_themes(&config)?;
255 Ok(true)
261 Ok(true)
src/controller.rs+3−1
@@ -197,6 +197,8 @@ impl<'b> Controller<'b> {
197 let mut first_range: bool = true;
197 let mut first_range: bool = true;
198 let mut mid_range: bool = false;
198 let mut mid_range: bool = false;
199
199
200+ let style_snip = self.config.style_components.snip();
201+
200 while reader.read_line(&mut line_buffer)? {
202 while reader.read_line(&mut line_buffer)? {
201 match line_ranges.check(line_number) {
203 match line_ranges.check(line_number) {
202 RangeCheckResult::BeforeOrBetweenRanges => {
204 RangeCheckResult::BeforeOrBetweenRanges => {
@@ -207,7 +209,7 @@ impl<'b> Controller<'b> {
207 }
209 }
208
210
209 RangeCheckResult::InRange => {
211 RangeCheckResult::InRange => {
210− if self.config.style_components.snip() {
212+ if style_snip {
211 if first_range {
213 if first_range {
212 first_range = false;
214 first_range = false;
213 mid_range = true;
215 mid_range = true;
src/lib.rs+2
@@ -19,6 +19,8 @@
19//! .unwrap();
19//! .unwrap();
20//! ```
20//! ```
21
21
22+mod macros;
23+
22pub mod assets;
24pub mod assets;
23pub mod assets_metadata;
25pub mod assets_metadata;
24pub mod config;
26pub mod config;
src/macros.rsnew file+7
@@ -0,0 +1,7 @@
1+#[macro_export]
2+macro_rules! bat_warning {
3+ ($($arg:tt)*) => ({
4+ use ansi_term::Colour::Yellow;
5+ eprintln!("{}: {}", Yellow.paint("[bat warning]"), format!($($arg)*));
6+ })
7+}
src/preprocessor.rs+1−1
@@ -72,7 +72,7 @@ pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String {
72 }
72 }
73 }
73 }
74 // line feed
74 // line feed
75− '\x0A' => output.push('␊'),
75+ '\x0A' => output.push_str("␊\x0A"),
76 // carriage return
76 // carriage return
77 '\x0D' => output.push('␍'),
77 '\x0D' => output.push('␍'),
78 // null
78 // null
src/printer.rs+18−15
@@ -91,9 +91,6 @@ impl<'a> Printer for SimplePrinter<'a> {
91 if self.config.show_nonprintable {
91 if self.config.show_nonprintable {
92 let line = replace_nonprintable(line_buffer, self.config.tab_width);
92 let line = replace_nonprintable(line_buffer, self.config.tab_width);
93 write!(handle, "{}", line)?;
93 write!(handle, "{}", line)?;
94− if line_buffer.last() == Some(&b'\n') {
95− writeln!(handle)?;
96− }
97 } else {
94 } else {
98 handle.write_all(line_buffer)?
95 handle.write_all(line_buffer)?
99 };
96 };
@@ -451,7 +448,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
451 if text.len() != text_trimmed.len() {
448 if text.len() != text_trimmed.len() {
452 if let Some(background_color) = background_color {
449 if let Some(background_color) = background_color {
453 let mut ansi_style = Style::default();
450 let mut ansi_style = Style::default();
454− ansi_style.background = Some(to_ansi_color(background_color, true_color));
451+ ansi_style.background = to_ansi_color(background_color, true_color);
455 let width = if cursor_total <= cursor_max {
452 let width = if cursor_total <= cursor_max {
456 cursor_max - cursor_total + 1
453 cursor_max - cursor_total + 1
457 } else {
454 } else {
@@ -463,7 +460,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
463 }
460 }
464 }
461 }
465
462
466− if line.bytes().next_back() != Some(b'\n') {
463+ if !self.config.style_components.plain() && line.bytes().next_back() != Some(b'\n') {
467 writeln!(handle)?;
464 writeln!(handle)?;
468 }
465 }
469 } else {
466 } else {
@@ -592,8 +589,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
592
589
593 if let Some(background_color) = background_color {
590 if let Some(background_color) = background_color {
594 let mut ansi_style = Style::default();
591 let mut ansi_style = Style::default();
595− ansi_style.background =
596− Some(to_ansi_color(background_color, self.config.true_color));
592+ ansi_style.background = to_ansi_color(background_color, self.config.true_color);
597
593
598 write!(
594 write!(
599 handle,
595 handle,
@@ -627,20 +623,27 @@ impl Colors {
627 }
623 }
628
624
629 fn colored(theme: &Theme, true_color: bool) -> Self {
625 fn colored(theme: &Theme, true_color: bool) -> Self {
630− let gutter_color = theme
626+ let gutter_style = Style {
631− .settings
632− .gutter_foreground
627+ foreground: match theme.settings.gutter_foreground {
628+ // If the theme provides a gutter foreground color, use it.
629+ // Note: It might be the special value #00000001, in which case
630+ // to_ansi_color returns None and we use an empty Style
631+ // (resulting in the terminal's default foreground color).
633− .map(|c| to_ansi_color(c, true_color))
632+ Some(c) => to_ansi_color(c, true_color),
633+ // Otherwise, use a specific fallback color.
634− .unwrap_or(Fixed(DEFAULT_GUTTER_COLOR));
634+ None => Some(Fixed(DEFAULT_GUTTER_COLOR)),
635+ },
636+ ..Style::default()
637+ };
635
638
636 Colors {
639 Colors {
637− grid: gutter_color.normal(),
640+ grid: gutter_style,
638− rule: gutter_color.normal(),
641+ rule: gutter_style,
639 filename: Style::new().bold(),
642 filename: Style::new().bold(),
640 git_added: Green.normal(),
643 git_added: Green.normal(),
641 git_removed: Red.normal(),
644 git_removed: Red.normal(),
642 git_modified: Yellow.normal(),
645 git_modified: Yellow.normal(),
643− line_number: gutter_color.normal(),
646+ line_number: gutter_style,
644 }
647 }
645 }
648 }
646}
649}
src/terminal.rs+19−9
@@ -3,13 +3,13 @@ use ansi_term::{self, Style};
3
3
4use syntect::highlighting::{self, FontStyle};
4use syntect::highlighting::{self, FontStyle};
5
5
6−pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term::Color {
6+pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> Option<ansi_term::Color> {
7 if color.a == 0 {
7 if color.a == 0 {
8 // Themes can specify one of the user-configurable terminal colors by
8 // Themes can specify one of the user-configurable terminal colors by
9 // encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set
9 // encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set
10− // to the 8-bit color palette number. The built-in themes ansi-light,
10+ // to the 8-bit color palette number. The built-in themes ansi, base16,
11− // ansi-dark, base16, and base16-256 use this.
11+ // and base16-256 use this.
12− match color.r {
12+ Some(match color.r {
13 // For the first 8 colors, use the Color enum to produce ANSI escape
13 // For the first 8 colors, use the Color enum to produce ANSI escape
14 // sequences using codes 30-37 (foreground) and 40-47 (background).
14 // sequences using codes 30-37 (foreground) and 40-47 (background).
15 // For example, red foreground is \x1b[31m. This works on terminals
15 // For example, red foreground is \x1b[31m. This works on terminals
@@ -31,11 +31,18 @@ pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term:
31 // 90-97 (foreground) and 100-107 (background), we should use those
31 // 90-97 (foreground) and 100-107 (background), we should use those
32 // for values 0x08 to 0x0f and only use Fixed for 0x10 to 0xff.
32 // for values 0x08 to 0x0f and only use Fixed for 0x10 to 0xff.
33 n => Fixed(n),
33 n => Fixed(n),
34− }
34+ })
35+ } else if color.a == 1 {
36+ // Themes can specify the terminal's default foreground/background color
37+ // (i.e. no escape sequence) using the encoding #RRGGBBAA with AA set to
38+ // 01. The built-in theme ansi uses this.
39+ None
35 } else if true_color {
40 } else if true_color {
36− RGB(color.r, color.g, color.b)
41+ Some(RGB(color.r, color.g, color.b))
37 } else {
42 } else {
38− Fixed(ansi_colours::ansi256_from_rgb((color.r, color.g, color.b)))
43+ Some(Fixed(ansi_colours::ansi256_from_rgb((
44+ color.r, color.g, color.b,
45+ ))))
39 }
46 }
40}
47}
41
48
@@ -54,7 +61,10 @@ pub fn as_terminal_escaped(
54 let mut style = if !colored {
61 let mut style = if !colored {
55 Style::default()
62 Style::default()
56 } else {
63 } else {
64+ let mut color = Style {
57− let mut color = Style::from(to_ansi_color(style.foreground, true_color));
65+ foreground: to_ansi_color(style.foreground, true_color),
66+ ..Style::default()
67+ };
58 if style.font_style.contains(FontStyle::BOLD) {
68 if style.font_style.contains(FontStyle::BOLD) {
59 color = color.bold();
69 color = color.bold();
60 }
70 }
@@ -67,6 +77,6 @@ pub fn as_terminal_escaped(
67 color
77 color
68 };
78 };
69
79
70− style.background = background_color.map(|c| to_ansi_color(c, true_color));
80+ style.background = background_color.and_then(|c| to_ansi_color(c, true_color));
71 style.paint(text).to_string()
81 style.paint(text).to_string()
72}
82}
tests/assets.rs+2−4
@@ -30,13 +30,11 @@ fn all_themes_are_present() {
30 "Solarized (light)",
30 "Solarized (light)",
31 "Sublime Snazzy",
31 "Sublime Snazzy",
32 "TwoDark",
32 "TwoDark",
33− "ansi-dark",
33+ "ansi",
34− "ansi-light",
35 "base16",
34 "base16",
36 "base16-256",
35 "base16-256",
37− "gruvbox",
36+ "gruvbox-dark",
38 "gruvbox-light",
37 "gruvbox-light",
39− "gruvbox-white",
40 "zenburn"
38 "zenburn"
41 ]
39 ]
42 );
40 );
tests/benchmarks/comparison.sh+2−2
@@ -1,8 +1,8 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
2
2
3−cd "$(dirname "${BASH_SOURCE[0]}")"
3+cd "$(dirname "${BASH_SOURCE[0]}")" || exit
4
4
5−if ! which hyperfine > /dev/null 2>&1; then
5+if ! command -v hyperfine > /dev/null 2>&1; then
6 echo "'hyperfine' does not seem to be installed."
6 echo "'hyperfine' does not seem to be installed."
7 echo "You can get it here: https://github.com/sharkdp/hyperfine"
7 echo "You can get it here: https://github.com/sharkdp/hyperfine"
8 exit 1
8 exit 1
tests/benchmarks/run-benchmarks.sh+2−2
@@ -1,8 +1,8 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
2
2
3−cd "$(dirname "${BASH_SOURCE[0]}")"
3+cd "$(dirname "${BASH_SOURCE[0]}")" || exit
4
4
5−if ! which hyperfine > /dev/null 2>&1; then
5+if ! command -v hyperfine > /dev/null 2>&1; then
6 echo "'hyperfine' does not seem to be installed."
6 echo "'hyperfine' does not seem to be installed."
7 echo "You can get it here: https://github.com/sharkdp/hyperfine"
7 echo "You can get it here: https://github.com/sharkdp/hyperfine"
8 exit 1
8 exit 1
tests/integration_tests.rs+38
@@ -837,3 +837,41 @@ fn show_all_mode() {
837 .stdout("hello·world␊\n├──┤␍␀␇␈␛")
837 .stdout("hello·world␊\n├──┤␍␀␇␈␛")
838 .stderr("");
838 .stderr("");
839}
839}
840+
841+#[test]
842+fn plain_mode_does_not_add_nonexisting_newline() {
843+ bat()
844+ .arg("--paging=never")
845+ .arg("--color=never")
846+ .arg("--decorations=always")
847+ .arg("--style=plain")
848+ .arg("single-line.txt")
849+ .assert()
850+ .success()
851+ .stdout("Single Line");
852+}
853+
854+// Regression test for https://github.com/sharkdp/bat/issues/299
855+#[test]
856+fn grid_for_file_without_newline() {
857+ bat()
858+ .arg("--paging=never")
859+ .arg("--color=never")
860+ .arg("--terminal-width=80")
861+ .arg("--wrap=never")
862+ .arg("--decorations=always")
863+ .arg("--style=full")
864+ .arg("single-line.txt")
865+ .assert()
866+ .success()
867+ .stdout(
868+ "\
869+───────┬────────────────────────────────────────────────────────────────────────
870+ │ File: single-line.txt
871+───────┼────────────────────────────────────────────────────────────────────────
872+ 1 │ Single Line
873+───────┴────────────────────────────────────────────────────────────────────────
874+",
875+ )
876+ .stderr("");
877+}
tests/syntax-tests/highlighted/Plaintext/plaintext.txt+1−1
@@ -175,4 +175,4 @@
175\u{ad}␊
175\u{ad}␊
176\u{ae}␊
176\u{ae}␊
177␊
177␊
178−Here's·a·line·with·multiple·characters.
178+Here's·a·line·with·multiple·characters.␊
tests/syntax-tests/highlighted/VimL/source.vimnew file+92
@@ -0,0 +1,92 @@
1+if &compatible
2+ set nocompatible
3+endif
4+
5+if has('win32') || has ('win64')
6+ let $VIMHOME = $HOME . "/vimfiles"
7+elseif v:false && v:true
8+ echo "Can't get here"
9+else
10+ let $VIMHOME = $HOME . "/.vim"
11+endif
12+
13+" show existing tab with 2 spaces width
14+set tabstop=2
15+" when indenting with '>', use 2 spaces width
16+set shiftwidth=2
17+" always set autoindenting on
18+set autoindent
19+
20+autocmd VimEnter * echo "Hello Vim"
21+
22+" Allow :W and :Wq to save too
23+command! Wq :wq
24+command! W :w
25+
26+augroup vimrc
27+ autocmd!
28+ autocmd FileType * echo "New filetype"
29+augroup END
30+
31+function! s:echo(what)
32+ return a:what
33+endfunction
34+
35+function! HelloWorld(name)
36+ let l:function_local = "function_local_var"
37+ let l:parts = split(l:function_local, "_")
38+ let l:greeting = "Hello " . a:name
39+ return s:echo(l:greeting)
40+endfunction
41+
42+function! source#Hello()
43+ return "Hello from namespace"
44+endfunction
45+
46+function! EchoFunc(...)
47+ for s in a:000
48+ echon ' ' . s
49+ endfor
50+endfunction
51+
52+imap <C-h> <C-r>=HelloWorld("World")<CR>
53+
54+command! -nargs=? Echo :call EchoFunc(<args>)
55+
56+" TODO test stuff
57+let g:global = "global var"
58+let s:script_var = "script var"
59+let w:window_var = "window war"
60+let b:buffer_var = "buffer war"
61+let t:tab_var = "tab war"
62+echo v:false
63+
64+3 + 5
65+
66+echo "Hello" ==# "Hello2"
67+echo "Hello" ==? "Hello2"
68+echo "Hello" == "Hello2"
69+echo "Hello" is "Hello2"
70+echo "Hello" isnot "Hello2"
71+echo "Hello" =~ 'xx*'
72+echo "Hello" !~ "Hello2"
73+echo "Hello" !~ "Hello2"
74+
75+echo "/This/should/not/be/a/regex"
76+
77+" Error case from issue #1604 (https://github.com/sharkdp/bat/issues/1064)
78+set runtimepath=~/foo/bar
79+
80+silent g/Aap/p
81+
82+let g:dict = {}
83+let g:dict.item = ['l1', 'l2']
84+
85+let g:dict2 = {'dict_item': ['l1', 'l2'], 'di2': 'x'}
86+
87+silent g/regex/
88+silent v/regex/
89+silent %s/regex/not_regex/
90+
91+filetype plugin indent on
92+syntax enable
tests/syntax-tests/regression_test.sh+1−1
@@ -4,7 +4,7 @@ set -eou pipefail
4
4
5script_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
5script_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6
6
7−output_directory=$(mktemp -d --suffix=.bat-syntax-regression-test)
7+output_directory=$(mktemp -d)
8
8
9"$script_directory"/create_highlighted_versions.py --output="$output_directory"
9"$script_directory"/create_highlighted_versions.py --output="$output_directory"
10
10
tests/syntax-tests/source/ActionScript/test.as+1−1
@@ -72,4 +72,4 @@ package TestSyntax {
72 var sndChannel:SoundChannel = mySound.play();
72 var sndChannel:SoundChannel = mySound.play();
73 }
73 }
74 }
74 }
75−}
75+}
tests/syntax-tests/source/Batch/build.bat+1−1
@@ -56,4 +56,4 @@ set LDLIBS= ^
56 @set "LINK_FILES=%LINK_FILES% %%~f"
56 @set "LINK_FILES=%LINK_FILES% %%~f"
57)
57)
58
58
59−lld-link.exe %LINK_FILES% -out:"%OUTPUT%" %LDFLAGS% %LDLIBS%
59+lld-link.exe %LINK_FILES% -out:"%OUTPUT%" %LDFLAGS% %LDLIBS%
tests/syntax-tests/source/Clojure/test.clj+1−1
@@ -55,4 +55,4 @@
55 (println (factorial 5))
55 (println (factorial 5))
56 (log)
56 (log)
57 (log "Message"))
57 (log "Message"))
58−
58+
tests/syntax-tests/source/Dockerfile/Dockerfile+1−1
@@ -16,4 +16,4 @@ EXPOSE 80/tcp
16
16
17VOLUME [/var/lib/mysql/data]
17VOLUME [/var/lib/mysql/data]
18
18
19−ENTRYPOINT ["/usr/bin/entrypoint.sh"]
19+ENTRYPOINT ["/usr/bin/entrypoint.sh"]
tests/syntax-tests/source/Git Attributes/example.gitattributes+1−1
@@ -13,4 +13,4 @@
13*.patch -text
13*.patch -text
14
14
15.gitattributes linguist-language=gitattributes
15.gitattributes linguist-language=gitattributes
16−.gitkeep export-ignore
16+.gitkeep export-ignore
tests/syntax-tests/source/Git Config/text.gitconfig+1−1
@@ -104,4 +104,4 @@
104[user]
104[user]
105 email = f.nord@example.com
105 email = f.nord@example.com
106 name = Frank Nord
106 name = Frank Nord
107− signingkey = AAAAAAAAAAAAAAAA
107+ signingkey = AAAAAAAAAAAAAAAA
tests/syntax-tests/source/Hosts/hosts+1−1
@@ -5,4 +5,4 @@
5192.160.0.200 try.sample.test try #another comment
5192.160.0.200 try.sample.test try #another comment
6216.58.223.238 google.com
6216.58.223.238 google.com
7
7
8−::1 localhost.try ip6-localhost
8+::1 localhost.try ip6-localhost
tests/syntax-tests/source/Makefile/Makefile+1−1
@@ -382,4 +382,4 @@ install: all
382 @ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_SENTINEL_NAME)
382 @ln -sf $(REDIS_SERVER_NAME) $(INSTALL_BIN)/$(REDIS_SENTINEL_NAME)
383
383
384uninstall:
384uninstall:
385− rm -f $(INSTALL_BIN)/{$(REDIS_SERVER_NAME),$(REDIS_BENCHMARK_NAME),$(REDIS_CLI_NAME),$(REDIS_CHECK_RDB_NAME),$(REDIS_CHECK_AOF_NAME),$(REDIS_SENTINEL_NAME)}
385+ rm -f $(INSTALL_BIN)/{$(REDIS_SERVER_NAME),$(REDIS_BENCHMARK_NAME),$(REDIS_CLI_NAME),$(REDIS_CHECK_RDB_NAME),$(REDIS_CHECK_AOF_NAME),$(REDIS_SENTINEL_NAME)}
tests/syntax-tests/source/PHP/test.php+1−1
@@ -108,4 +108,4 @@ $doe->setName('John Doe');
108
108
109$ending = 2 > 3 ? "yep" : "nah";
109$ending = 2 > 3 ? "yep" : "nah";
110
110
111−?>
111+?>
tests/syntax-tests/source/Plaintext/plaintext.txt

Binary file not shown.

tests/syntax-tests/source/PowerShell/test.ps1

Binary file not shown.

tests/syntax-tests/source/RequirementsTXT/requirements.txt+1−1
@@ -5,4 +5,4 @@ pywheels>=12.4 #a whitespace followed by comments
5Nuitka<0.6.8.4
5Nuitka<0.6.8.4
6wxPython>=1.0, <=2.1
6wxPython>=1.0, <=2.1
7
7
8−#this is another comment
8+#this is another comment
tests/syntax-tests/source/VimL/source.vimnew file+92
@@ -0,0 +1,92 @@
1+if &compatible
2+ set nocompatible
3+endif
4+
5+if has('win32') || has ('win64')
6+ let $VIMHOME = $HOME . "/vimfiles"
7+elseif v:false && v:true
8+ echo "Can't get here"
9+else
10+ let $VIMHOME = $HOME . "/.vim"
11+endif
12+
13+" show existing tab with 2 spaces width
14+set tabstop=2
15+" when indenting with '>', use 2 spaces width
16+set shiftwidth=2
17+" always set autoindenting on
18+set autoindent
19+
20+autocmd VimEnter * echo "Hello Vim"
21+
22+" Allow :W and :Wq to save too
23+command! Wq :wq
24+command! W :w
25+
26+augroup vimrc
27+ autocmd!
28+ autocmd FileType * echo "New filetype"
29+augroup END
30+
31+function! s:echo(what)
32+ return a:what
33+endfunction
34+
35+function! HelloWorld(name)
36+ let l:function_local = "function_local_var"
37+ let l:parts = split(l:function_local, "_")
38+ let l:greeting = "Hello " . a:name
39+ return s:echo(l:greeting)
40+endfunction
41+
42+function! source#Hello()
43+ return "Hello from namespace"
44+endfunction
45+
46+function! EchoFunc(...)
47+ for s in a:000
48+ echon ' ' . s
49+ endfor
50+endfunction
51+
52+imap <C-h> <C-r>=HelloWorld("World")<CR>
53+
54+command! -nargs=? Echo :call EchoFunc(<args>)
55+
56+" TODO test stuff
57+let g:global = "global var"
58+let s:script_var = "script var"
59+let w:window_var = "window war"
60+let b:buffer_var = "buffer war"
61+let t:tab_var = "tab war"
62+echo v:false
63+
64+3 + 5
65+
66+echo "Hello" ==# "Hello2"
67+echo "Hello" ==? "Hello2"
68+echo "Hello" == "Hello2"
69+echo "Hello" is "Hello2"
70+echo "Hello" isnot "Hello2"
71+echo "Hello" =~ 'xx*'
72+echo "Hello" !~ "Hello2"
73+echo "Hello" !~ "Hello2"
74+
75+echo "/This/should/not/be/a/regex"
76+
77+" Error case from issue #1604 (https://github.com/sharkdp/bat/issues/1064)
78+set runtimepath=~/foo/bar
79+
80+silent g/Aap/p
81+
82+let g:dict = {}
83+let g:dict.item = ['l1', 'l2']
84+
85+let g:dict2 = {'dict_item': ['l1', 'l2'], 'di2': 'x'}
86+
87+silent g/regex/
88+silent v/regex/
89+silent %s/regex/not_regex/
90+
91+filetype plugin indent on
92+syntax enable
tests/syntax-tests/source/YAML/example.yaml+1−1
@@ -31,4 +31,4 @@ emails:
31 - bob@example.com
31 - bob@example.com
32 - bill@example.com
32 - bill@example.com
33 supervisors:
33 supervisors:
34− - george@example.com
34+ - george@example.com
tests/syntax-tests/source/reStructuredText/reference.rst+1−1
@@ -317,4 +317,4 @@ blank lines before and after.)
317..
317..
318
318
319 So this block is not "lost",
319 So this block is not "lost",
320− despite its indentation.
320+ despite its indentation.
tests/syntax-tests/update.sh+1−1
@@ -1,6 +1,6 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
2
2
3−cd "$(dirname "${BASH_SOURCE[0]}")"
3+cd "$(dirname "${BASH_SOURCE[0]}")" || exit
4
4
5python="python3"
5python="python3"
6if ! command -v python3 &>/dev/null; then python="python"; fi
6if ! command -v python3 &>/dev/null; then python="python"; fi