on master help sign in
Merge remote-tracking branch 'origin/master' into fix-1063
478233fMartin Nordholts
.github/ISSUE_TEMPLATE/bug_report.md+23−15
@@ -7,33 +7,41 @@ assignees: ''
7
7
8---
8---
9
9
10−<!--
11−Hey there, thanks for creating an issue!
10+<!-- Hey there, thank you for creating an issue! -->
12−
13−In order to reproduce your issue, we might need to know a little bit more about the environment
14−which you're running `bat` on.
15
11
16−If you're on Linux or MacOS:
12+**What version of `bat` are you using?**
17− Please run the script at https://github.com/sharkdp/bat/blob/master/diagnostics/info.sh and
18− paste the output at the bottom of the bug report.
19
13
20−If you're on Windows:
14+<!-- Output of `bat --version` -->
21− Please tell us about your Windows Version (e.g. "Windows 10 1908") at the
22− bottom of the bug report.
23−-->
24
15
25−**What version of `bat` are you using?**
26−[paste the output of `bat --version` here]
27
16
28**Describe the bug you encountered:**
17**Describe the bug you encountered:**
18+
29...
19...
30
20
31**What did you expect to happen instead?**
21**What did you expect to happen instead?**
22+
32...
23...
33
24
25+
34**How did you install `bat`?**
26**How did you install `bat`?**
27+
35<!-- apt-get, homebrew, GitHub release, etc. -->
28<!-- apt-get, homebrew, GitHub release, etc. -->
36
29
37---
30---
38
31
39−[paste the output of `info.sh` here]
32+**Evironment**
33+
34+<!--
35+In order to reproduce your issue, please add some information about the environment
36+in which you're running bat.
37+
38+Linux and MacOS:
39+ Please run the script at
40+
41+ https://github.com/sharkdp/bat/blob/master/diagnostics/info.sh
42+
43+ (click "Raw" to get the actual source code) and paste the Markdown output here.
44+
45+Windows:
46+ Please add your Windows Version (e.g. "Windows 10 1908")
47+-->
.github/workflows/CICD.yml+1−1
@@ -27,7 +27,7 @@ jobs:
27 uses: actions-rs/cargo@v1
27 uses: actions-rs/cargo@v1
28 with:
28 with:
29 command: clippy
29 command: clippy
30− args: --all-targets --all-features
30+ args: --all-targets --all-features -- --allow clippy::style
31 - name: Test
31 - name: Test
32 uses: actions-rs/cargo@v1
32 uses: actions-rs/cargo@v1
33 with:
33 with:
.gitmodules+6
@@ -207,3 +207,9 @@
207 path = assets/themes/gruvbox
207 path = assets/themes/gruvbox
208 url = https://github.com/subnut/gruvbox-tmTheme.git
208 url = https://github.com/subnut/gruvbox-tmTheme.git
209 branch = bat-source
209 branch = bat-source
210+[submodule "assets/syntaxes/02_Extra/Lean"]
211+ path = assets/syntaxes/02_Extra/Lean
212+ url = https://github.com/leanprover/vscode-lean.git
213+[submodule "assets/syntaxes/02_Extra/Zig"]
214+ path = assets/syntaxes/02_Extra/Zig
215+ url = https://github.com/ziglang/sublime-zig-language.git
CHANGELOG.md+4
@@ -19,6 +19,10 @@
19
19
20## Syntaxes
20## Syntaxes
21
21
22+- Added Zig syntax, see #1470 (@paulsmith)
23+- Added Lean syntax, see #1446 (@Julian)
24+- Added `.resource` extension for Robot Framework files, see #1386
25+
22## New themes
26## New themes
23
27
24- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12)
28- `ansi` replaces `ansi-dark` and `ansi-light`, see #1104 and #1412 (@mk12)
Cargo.lock+20−21
@@ -253,9 +253,9 @@ dependencies = [
253
253
254[[package]]
254[[package]]
255name = "console"
255name = "console"
256−version = "0.13.0"
256+version = "0.14.0"
257source = "registry+https://github.com/rust-lang/crates.io-index"
257source = "registry+https://github.com/rust-lang/crates.io-index"
258−checksum = "a50aab2529019abfabfa93f1e6c41ef392f91fbf179b347a7e96abb524884a08"
258+checksum = "7cc80946b3480f421c2f17ed1cb841753a371c7c5104f51d507e13f532c856aa"
259dependencies = [
259dependencies = [
260 "encode_unicode",
260 "encode_unicode",
261 "lazy_static",
261 "lazy_static",
@@ -264,7 +264,6 @@ dependencies = [
264 "terminal_size",
264 "terminal_size",
265 "unicode-width",
265 "unicode-width",
266 "winapi",
266 "winapi",
267− "winapi-util",
268]
267]
269
268
270[[package]]
269[[package]]
@@ -499,9 +498,9 @@ dependencies = [
499
498
500[[package]]
499[[package]]
501name = "git2"
500name = "git2"
502−version = "0.13.12"
501+version = "0.13.15"
503source = "registry+https://github.com/rust-lang/crates.io-index"
502source = "registry+https://github.com/rust-lang/crates.io-index"
504−checksum = "ca6f1a0238d7f8f8fd5ee642f4ebac4dbc03e03d1f78fbe7a3ede35dcf7e2224"
503+checksum = "44f267c9da8a4de3c615b59e23606c75f164f84896e97f4dd6c15a4294de4359"
505dependencies = [
504dependencies = [
506 "bitflags",
505 "bitflags",
507 "libc",
506 "libc",
@@ -609,9 +608,9 @@ checksum = "aa7087f49d294270db4e1928fc110c976cd4b9e5a16348e0a1df09afa99e6c98"
609
608
610[[package]]
609[[package]]
611name = "libgit2-sys"
610name = "libgit2-sys"
612−version = "0.12.14+1.1.0"
611+version = "0.12.17+1.1.0"
613source = "registry+https://github.com/rust-lang/crates.io-index"
612source = "registry+https://github.com/rust-lang/crates.io-index"
614−checksum = "8f25af58e6495f7caf2919d08f212de550cfa3ed2f5e744988938ea292b9f549"
613+checksum = "f4ebdf65ca745126df8824688637aa0535a88900b83362d8ca63893bcf4e8841"
615dependencies = [
614dependencies = [
616 "cc",
615 "cc",
617 "libc",
616 "libc",
@@ -850,9 +849,9 @@ dependencies = [
850
849
851[[package]]
850[[package]]
852name = "predicates"
851name = "predicates"
853−version = "1.0.5"
852+version = "1.0.6"
854source = "registry+https://github.com/rust-lang/crates.io-index"
853source = "registry+https://github.com/rust-lang/crates.io-index"
855−checksum = "96bfead12e90dccead362d62bb2c90a5f6fc4584963645bc7f71a735e0b0735a"
854+checksum = "73dd9b7b200044694dfede9edf907c1ca19630908443e9447e624993700c6932"
856dependencies = [
855dependencies = [
857 "difference",
856 "difference",
858 "float-cmp",
857 "float-cmp",
@@ -951,9 +950,9 @@ dependencies = [
951
950
952[[package]]
951[[package]]
953name = "regex"
952name = "regex"
954−version = "1.3.9"
953+version = "1.4.2"
955source = "registry+https://github.com/rust-lang/crates.io-index"
954source = "registry+https://github.com/rust-lang/crates.io-index"
956−checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
955+checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
957dependencies = [
956dependencies = [
958 "aho-corasick",
957 "aho-corasick",
959 "memchr",
958 "memchr",
@@ -963,9 +962,9 @@ dependencies = [
963
962
964[[package]]
963[[package]]
965name = "regex-syntax"
964name = "regex-syntax"
966−version = "0.6.18"
965+version = "0.6.21"
967source = "registry+https://github.com/rust-lang/crates.io-index"
966source = "registry+https://github.com/rust-lang/crates.io-index"
968−checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
967+checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
969
968
970[[package]]
969[[package]]
971name = "remove_dir_all"
970name = "remove_dir_all"
@@ -1036,18 +1035,18 @@ dependencies = [
1036
1035
1037[[package]]
1036[[package]]
1038name = "serde"
1037name = "serde"
1039−version = "1.0.117"
1038+version = "1.0.118"
1040source = "registry+https://github.com/rust-lang/crates.io-index"
1039source = "registry+https://github.com/rust-lang/crates.io-index"
1041−checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a"
1040+checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
1042dependencies = [
1041dependencies = [
1043 "serde_derive",
1042 "serde_derive",
1044]
1043]
1045
1044
1046[[package]]
1045[[package]]
1047name = "serde_derive"
1046name = "serde_derive"
1048−version = "1.0.117"
1047+version = "1.0.118"
1049source = "registry+https://github.com/rust-lang/crates.io-index"
1048source = "registry+https://github.com/rust-lang/crates.io-index"
1050−checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e"
1049+checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
1051dependencies = [
1050dependencies = [
1052 "proc-macro2",
1051 "proc-macro2",
1053 "quote",
1052 "quote",
@@ -1148,9 +1147,9 @@ dependencies = [
1148
1147
1149[[package]]
1148[[package]]
1150name = "syntect"
1149name = "syntect"
1151−version = "4.4.0"
1150+version = "4.5.0"
1152source = "registry+https://github.com/rust-lang/crates.io-index"
1151source = "registry+https://github.com/rust-lang/crates.io-index"
1153−checksum = "4e3978df05b5850c839a6b352d3c35ce0478944a4be689be826b53cf75363e88"
1152+checksum = "2bfac2b23b4d049dc9a89353b4e06bbc85a8f42020cccbe5409a115cf19031e5"
1154dependencies = [
1153dependencies = [
1155 "bincode",
1154 "bincode",
1156 "bitflags",
1155 "bitflags",
@@ -1191,9 +1190,9 @@ dependencies = [
1191
1190
1192[[package]]
1191[[package]]
1193name = "terminal_size"
1192name = "terminal_size"
1194−version = "0.1.13"
1193+version = "0.1.15"
1195source = "registry+https://github.com/rust-lang/crates.io-index"
1194source = "registry+https://github.com/rust-lang/crates.io-index"
1196−checksum = "9a14cd9f8c72704232f0bfc8455c0e861f0ad4eb60cc9ec8a170e231414c1e13"
1195+checksum = "4bd2d183bd3fac5f5fe38ddbeb4dc9aec4a39a9d7d59e7491d900302da01cbe1"
1197dependencies = [
1196dependencies = [
1198 "libc",
1197 "libc",
1199 "winapi",
1198 "winapi",
Cargo.toml+3−3
@@ -37,7 +37,7 @@ regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine
37atty = { version = "0.2.14", optional = true }
37atty = { version = "0.2.14", optional = true }
38ansi_term = "^0.12.1"
38ansi_term = "^0.12.1"
39ansi_colours = "^1.0"
39ansi_colours = "^1.0"
40−console = "0.13.0"
40+console = "0.14.0"
41dirs = { version = "3.0", optional = true }
41dirs = { version = "3.0", optional = true }
42lazy_static = { version = "1.4", optional = true }
42lazy_static = { version = "1.4", optional = true }
43wild = { version = "2.0", optional = true }
43wild = { version = "2.0", optional = true }
@@ -57,7 +57,7 @@ optional = true
57default-features = false
57default-features = false
58
58
59[dependencies.syntect]
59[dependencies.syntect]
60−version = "4.4.0"
60+version = "4.5.0"
61default-features = false
61default-features = false
62features = ["parsing", "yaml-load", "dump-load", "dump-create"]
62features = ["parsing", "yaml-load", "dump-load", "dump-create"]
63
63
@@ -75,7 +75,7 @@ default-features = false
75tempdir = "0.3"
75tempdir = "0.3"
76assert_cmd = "1.0.2"
76assert_cmd = "1.0.2"
77serial_test = "0.5.1"
77serial_test = "0.5.1"
78−predicates = "1.0.5"
78+predicates = "1.0.6"
79
79
80[build-dependencies]
80[build-dependencies]
81clap = { version = "2.33", optional = true }
81clap = { version = "2.33", optional = true }
README.md+1−1
@@ -180,7 +180,7 @@ The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.
180
180
181## Installation
181## Installation
182
182
183−[![Packaging status](https://repology.org/badge/vertical-allrepos/bat.svg)](https://repology.org/project/bat/versions)
183+[![Packaging status](https://repology.org/badge/vertical-allrepos/bat-cat.svg)](https://repology.org/project/bat-cat/versions)
184
184
185### On Ubuntu (using `apt`)
185### On Ubuntu (using `apt`)
186*... and other Debian-based Linux distributions.*
186*... and other Debian-based Linux distributions.*
assets/syntaxes/02_Extra/Julia+1−1

Submodule changed.

assets/syntaxes/02_Extra/Leannew file+1

Submodule changed.

assets/syntaxes/02_Extra/Lean.sublime-syntaxnew file+125
@@ -0,0 +1,125 @@
1+%YAML 1.2
2+---
3+# http://www.sublimetext.com/docs/3/syntax.html
4+name: Lean
5+file_extensions:
6+ - lean
7+scope: source.lean
8+contexts:
9+ main:
10+ - include: comments
11+ - match: '\b(?<!\.)(inductive|coinductive|structure|theorem|axiom|axioms|abbreviation|lemma|definition|def|instance|class|constant)\b\s+(\{[^}]*\})?'
12+ captures:
13+ 1: keyword.other.definitioncommand.lean
14+ push:
15+ - meta_scope: meta.definitioncommand.lean
16+ - match: '(?=\bwith\b|\bextends\b|[:\|\(\[\{⦃<>])'
17+ pop: true
18+ - include: comments
19+ - include: definitionName
20+ - match: ","
21+ - match: \b(Prop|Type|Sort)\b
22+ scope: storage.type.lean
23+ - match: '\battribute\b\s*\[[^\]]*\]'
24+ scope: storage.modifier.lean
25+ - match: '@\[[^\]]*\]'
26+ scope: storage.modifier.lean
27+ - match: \b(?<!\.)(private|meta|mutual|protected|noncomputable)\b
28+ scope: keyword.control.definition.modifier.lean
29+ - match: \b(sorry)\b
30+ scope: invalid.illegal.lean
31+ - match: '#print\s+(def|definition|inductive|instance|structure|axiom|axioms|class)\b'
32+ scope: keyword.other.command.lean
33+ - match: '#(print|eval|reduce|check|help|exit|find|where)\b'
34+ scope: keyword.other.command.lean
35+ - match: \b(?<!\.)(import|export|prelude|theory|definition|def|abbreviation|instance|renaming|hiding|exposing|parameter|parameters|begin|constant|constants|lemma|variable|variables|theorem|example|open|axiom|inductive|coinductive|with|structure|universe|universes|alias|precedence|reserve|postfix|prefix|infix|infixl|infixr|notation|end|using|namespace|section|local|set_option|extends|include|omit|class|classes|instances|raw|run_cmd|restate_axiom)(?!\.)\b
36+ scope: keyword.other.lean
37+ - match: \b(?<!\.)(calc|have|this|match|do|suffices|show|by|in|at|let|forall|fun|exists|assume|from|obtain|haveI|λ)(?!\.)\b
38+ scope: keyword.other.lean
39+ - match: «
40+ push:
41+ - meta_content_scope: entity.name.lean
42+ - match: »
43+ pop: true
44+ - match: \b(?<!\.)(if|then|else)\b
45+ scope: keyword.control.lean
46+ - match: '"'
47+ captures:
48+ 0: punctuation.definition.string.begin.lean
49+ push:
50+ - meta_scope: string.quoted.double.lean
51+ - match: '"'
52+ captures:
53+ 0: punctuation.definition.string.end.lean
54+ pop: true
55+ - match: '\\[\\"nt'']'
56+ scope: constant.character.escape.lean
57+ - match: '\\x[0-9A-Fa-f][0-9A-Fa-f]'
58+ scope: constant.character.escape.lean
59+ - match: '\\u[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]'
60+ scope: constant.character.escape.lean
61+ - match: '''[^\\'']'''
62+ scope: string.quoted.single.lean
63+ - match: '''(\\(x..|u....|.))'''
64+ scope: string.quoted.single.lean
65+ captures:
66+ 1: constant.character.escape.lean
67+ - match: '`+[^\[(]\S+'
68+ scope: entity.name.lean
69+ - match: '\b([0-9]+|0([xX][0-9a-fA-F]+))\b'
70+ scope: constant.numeric.lean
71+ blockComment:
72+ - match: /-
73+ push:
74+ - meta_scope: comment.block.lean
75+ - match: "-/"
76+ pop: true
77+ - include: scope:source.lean.markdown
78+ - include: blockComment
79+ comments:
80+ - include: dashComment
81+ - include: docComment
82+ - include: stringBlock
83+ - include: modDocComment
84+ - include: blockComment
85+ dashComment:
86+ - match: (--)
87+ captures:
88+ 0: punctuation.definition.comment.lean
89+ push:
90+ - meta_scope: comment.line.double-dash.lean
91+ - match: $
92+ pop: true
93+ - include: scope:source.lean.markdown
94+ definitionName:
95+ - match: '\b[^:«»\(\)\{\}[:space:]=→λ∀?][^:«»\(\)\{\}[:space:]]*'
96+ scope: entity.name.function.lean
97+ - match: «
98+ push:
99+ - meta_content_scope: entity.name.function.lean
100+ - match: »
101+ pop: true
102+ docComment:
103+ - match: /--
104+ push:
105+ - meta_scope: comment.block.documentation.lean
106+ - match: "-/"
107+ pop: true
108+ - include: scope:source.lean.markdown
109+ - include: blockComment
110+ modDocComment:
111+ - match: /-!
112+ push:
113+ - meta_scope: comment.block.documentation.lean
114+ - match: "-/"
115+ pop: true
116+ - include: scope:source.lean.markdown
117+ - include: blockComment
118+ stringBlock:
119+ - match: /-"
120+ push:
121+ - meta_scope: comment.block.string.lean
122+ - match: '"-/'
123+ pop: true
124+ - include: scope:source.lean.markdown
125+ - include: blockComment
assets/syntaxes/02_Extra/Robot.sublime-syntax+1
@@ -4,6 +4,7 @@
4name: Robot Framework
4name: Robot Framework
5file_extensions:
5file_extensions:
6 - robot
6 - robot
7+ - resource
7scope: source.robot
8scope: source.robot
8contexts:
9contexts:
9 main:
10 main:
assets/syntaxes/02_Extra/SCSS_Sass+1−1

Submodule changed.

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

Submodule changed.

assets/syntaxes/02_Extra/Zignew file+1

Submodule changed.

assets/themes/dracula-sublime+1−1

Submodule changed.

assets/themes/zenburn+1−1

Submodule changed.

doc/assets.md+39−3
@@ -16,16 +16,51 @@ in the `.sublime-syntax` format.
16 *New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder.
16 *New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder.
17
17
183. Run the `assets/create.sh` script. It calls `bat cache --build` to parse all available
183. Run the `assets/create.sh` script. It calls `bat cache --build` to parse all available
19− `.sublime-syntax` files and serialize them to a `syntaxes.bin` file (in this folder).
19+ `.sublime-syntax` files and serialize them to a `syntaxes.bin` file.
20
20
214. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the
214. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the
22 `bat` binary.
22 `bat` binary.
23
23
245. Use `bat --list-languages` to check if the new languages are available.
245. Use `bat --list-languages` to check if the new languages are available.
25
25
26+6. Add a syntax test for the new language. See [#Syntax-tests](below) for details.
27+
26−6. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin`
28+7. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin`
27 file. A new binary cache file will be created once before every new release of `bat`.
29 file. A new binary cache file will be created once before every new release of `bat`.
28
30
31+### Syntax tests
32+
33+`bat` has a set of syntax highlighting regression tests in `tests/syntax-tests`. The main idea is
34+make sure that we do not run into issues we had in the past where either (1) syntax highlighting
35+for some language is suddenly not working anymore or (2) `bat` suddenly crashes for some input (due
36+to `regex` incompatibilities between `syntect` and Sublime Text).
37+
38+In order to add a new test file, please follow these steps (let's take "Ruby" as an example):
39+
40+1. Make sure that you are running the **latest version of `bat`** and that `bat` is available on
41+ the path. If you are creating a syntax test for a new builtin syntax (see above), make sure that
42+ your version of `bat` already has the new syntax builtin.
43+2. Find an example Ruby source file or write one yourself. If possible, the file should aim to be
44+ "comprehensive" (i.e. include a lot of the possible syntax), but this is not strictly necessary.
45+ A simple file is better than none at all. Also, the files shouldn't be gigantic.
46+3. Save the file in `tests/syntax-tests/source/Ruby` (adapt for your language). The file name could
47+ be `test.rb` (adapt extension) but can also be adapted if that is necessary in order for `bat` to
48+ highlight it correctly (e.g. `Makefile`).
49+4. If you have copied the file from somewhere else, please make sure that the file *may* be copied
50+ under the respective license and that the license is compatible with `bat`s license. If it
51+ requires attribution, please add a `LICENSE.md` in the same folder with a text like this:
52+ ```
53+ The `test.rb` file has been added from [enter source here] under the following license:
54+
55+ [add license text here]
56+ ```
57+5. Go to `tests/syntax-tests` and run the `update.sh` Bash script. A new file should be generated
58+ in the `highlighted` folder (e.g. `highlighted/Ruby/test.rb`).
59+6. Use `cat` or `bat --language=txt` to display the content of this file and make sure that the
60+ syntax highlighting looks correct.
61+7. `git add` the new files in the `source` folder as well as the autogenerated files in the
62+ `highlighted` folder.
63+
29### Troubleshooting
64### Troubleshooting
30
65
31Make sure that the local cache does not interfere with the internally stored syntaxes and
66Make sure that the local cache does not interfere with the internally stored syntaxes and
@@ -44,7 +79,7 @@ The following files have been manually modified after converting from a `.tmLang
44* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types and support for comments after section headers
79* `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types and support for comments after section headers
45* `Org mode.sublime-syntax` => removed `task` file type.
80* `Org mode.sublime-syntax` => removed `task` file type.
46* `SML.sublime_syntax` => removed `ml` file type.
81* `SML.sublime_syntax` => removed `ml` file type.
47−* `Robot.sublime_syntax` => changed name to "Robot Framework"
82+* `Robot.sublime_syntax` => changed name to "Robot Framework", added `.resource` extension
48
83
49### Non-submodule additions
84### Non-submodule additions
50
85
@@ -59,3 +94,4 @@ The following files have been manually modified after converting from a `.tmLang
59 https://github.com/seanjames777/SML-Language-Definition/blob/master/sml.tmLanguage
94 https://github.com/seanjames777/SML-Language-Definition/blob/master/sml.tmLanguage
60* `Cabal.sublime_syntax` has been added manually from
95* `Cabal.sublime_syntax` has been added manually from
61 https://github.com/SublimeHaskell/SublimeHaskell/ - we don't want to include the whole submodule because it includes other syntaxes ("Haskell improved") as well.
96 https://github.com/SublimeHaskell/SublimeHaskell/ - we don't want to include the whole submodule because it includes other syntaxes ("Haskell improved") as well.
97+* `Lean.sublime-syntax` has been added manually from https://github.com/leanprover/vscode-lean/blob/master/syntaxes/lean.json via conversion.
tests/benchmarks/run-benchmarks.sh+48−4
@@ -1,28 +1,72 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
2−
3cd "$(dirname "${BASH_SOURCE[0]}")" || exit
2cd "$(dirname "${BASH_SOURCE[0]}")" || exit
4
3
4+# Check that Hyperfine is installed.
5if ! command -v hyperfine > /dev/null 2>&1; then
5if ! 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
9fi
9fi
10
10
11+# Determine the target directories.
12+get_target_dir() {
13+ if [[ -f "$HOME/.cargo/config" ]]; then
14+ grep 'target-dir[[:space:]]*=' "$HOME/.cargo/config" \
15+ | sed 's/^[[:space:]]*target-dir[[:space:]]*=//; s/^[[:space:]]*"//; s/"[[:space:]]*$//' \
16+ && return 0
17+ fi
18+
19+ echo "../../target"
20+}
21+
22+TARGET_DIR="$(get_target_dir)"
23+TARGET_DEBUG="${TARGET_DIR}/debug/bat"
24+TARGET_RELEASE="${TARGET_DIR}/release/bat"
25+
26+# Determine which target to benchmark.
27+BAT=''
28+for arg in "$@"; do
29+ case "$arg" in
30+ --system) BAT="bat" ;;
31+ --debug) BAT="$TARGET_DEBUG" ;;
32+ --release) BAT="$TARGET_RELEASE" ;;
33+ --bat=*) BAT="${arg:6}" ;;
34+ esac
35+done
36+
37+if [[ -z "$BAT" ]]; then
38+ echo "A build of 'bat' must be specified for benchmarking."
39+ echo "You can use '--system', '--debug', or '--release'."
40+ exit 1
41+fi
42+
43+# Ensure that the target is built.
44+if ! command -v "$BAT" &>/dev/null; then
45+ echo "Could not find the build of bat to benchmark."
46+ case "$BAT" in
47+ "bat") echo "Make you sure to symlink 'batcat' as 'bat'." ;;
48+ "$TARGET_DEBUG") echo "Make you sure to 'cargo build' first." ;;
49+ "$TARGET_RELEASE") echo "Make you sure to 'cargo build --release' first." ;;
50+ esac
51+ exit 1
52+fi
53+
54+# Run the benchmark.
11echo "### Startup time"
55echo "### Startup time"
12echo
56echo
13
57
14−hyperfine --warmup 3 bat
58+hyperfine --warmup 3 "$BAT"
15
59
16echo
60echo
17echo "### Plain text"
61echo "### Plain text"
18echo
62echo
19
63
20−hyperfine --warmup 3 "bat --language txt --paging=never 'test-src/jquery-3.3.1.js'"
64+hyperfine --warmup 3 "$(printf "%q" "$BAT") --language txt --paging=never 'test-src/jquery-3.3.1.js'"
21
65
22echo
66echo
23echo "### Time to syntax-highlight large files"
67echo "### Time to syntax-highlight large files"
24echo
68echo
25
69
26for SRC in test-src/*; do
70for SRC in test-src/*; do
27− hyperfine --warmup 3 "bat --style=full --color=always --paging=never '$SRC'"
71+ hyperfine --warmup 3 "$(printf "%q" "$BAT") --style=full --color=always --paging=never $(printf "%q" "$SRC")"
28done
72done
tests/syntax-tests/highlighted/Lean/test.leannew file+68
@@ -0,0 +1,68 @@
1+import data.matrix.notation
2+import data.vector2
3+
4+/-!
5+
6+Helpers that don't currently fit elsewhere...
7+
8+-/
9+
10+lemma split_eq {m n : Type*} (x : m × n) (p p' : m × n) :
11+ p = x ∨ p' = x ∨ (x ≠ p ∧ x ≠ p') := by tauto
12+
13+-- For `playfield`s, the piece type and/or piece index type.
14+variables (X : Type*)
15+variables [has_repr X]
16+
17+namespace chess.utils
18+
19+section repr
20+
21+/--
22+An auxiliary wrapper for `option X` that allows for overriding the `has_repr` instance
23+for `option`, and rather, output just the value in the `some` and a custom provided
24+`string` for `none`.
25+-/
26+structure option_wrapper :=
27+(val : option X)
28+(none_s : string)
29+
30+instance wrapped_option_repr : has_repr (option_wrapper X) :=
31+⟨λ ⟨val, s⟩, (option.map has_repr.repr val).get_or_else s⟩
32+
33+variables {X}
34+/--
35+Construct an `option_wrapper` term from a provided `option X` and the `string`
36+that will override the `has_repr.repr` for `none`.
37+-/
38+def option_wrap (val : option X) (none_s : string) : option_wrapper X := ⟨val, none_s⟩
39+
40+-- The size of the "vectors" for a `fin n' → X`, for `has_repr` definitions
41+variables {m' n' : ℕ}
42+
43+/--
44+For a "vector" `X^n'` represented by the type `Π n' : ℕ, fin n' → X`, where
45+the `X` has a `has_repr` instance itself, we can provide a `has_repr` for the "vector".
46+This definition is used for displaying rows of the playfield, when it is defined
47+via a `matrix`, likely through notation.
48+-/
49+def vec_repr : Π {n' : ℕ}, (fin n' → X) → string :=
50+λ _ v, string.intercalate ", " ((vector.of_fn v).to_list.map repr)
51+
52+instance vec_repr_instance : has_repr (fin n' → X) := ⟨vec_repr⟩
53+
54+/--
55+For a `matrix` `X^(m' × n')` where the `X` has a `has_repr` instance itself,
56+we can provide a `has_repr` for the matrix, using `vec_repr` for each of the rows of the matrix.
57+This definition is used for displaying the playfield, when it is defined
58+via a `matrix`, likely through notation.
59+-/
60+def matrix_repr : Π {m' n'}, matrix (fin m') (fin n') X → string :=
61+λ _ _ M, string.intercalate ";\n" ((vector.of_fn M).to_list.map repr)
62+
63+instance matrix_repr_instance :
64+ has_repr (matrix (fin n') (fin m') X) := ⟨matrix_repr⟩
65+
66+end repr
67+
68+end chess.utils
tests/syntax-tests/highlighted/Zig/example.zignew file+107
@@ -0,0 +1,107 @@
1+//! this is a top level doc, starts with "//!"
2+
3+const std = @import("std");
4+
5+pub fn main() anyerror!void {
6+ const stdout = std.io.getStdOut().writer();
7+ try stdout.print("Hello, {}!\n", .{"world"});
8+}
9+
10+const expect = std.testing.expect;
11+
12+test "comments" {
13+ // comments start with "//" until newline
14+ // foo bar baz
15+ const x = true; // another comment
16+ expect(x);
17+}
18+
19+/// a doc comment starts with "///"
20+/// multiple lines are merged together
21+const Timestamp = struct {
22+ /// number of seconds since epoch
23+ seconds: i64,
24+
25+ /// number of nanoseconds past the second
26+ nano: u32,
27+
28+ const Self = @This();
29+
30+ pub fn unixEpoch() Self {
31+ return Self{
32+ .seconds = 0,
33+ .nanos = 0,
34+ };
35+ }
36+};
37+
38+const my_val = switch (std.Target.current.os.tag) {
39+ .linux => "Linux",
40+ else => "not Linux",
41+};
42+
43+const Book = enum {
44+ paperback,
45+ hardcover,
46+ ebook,
47+ pdf,
48+};
49+
50+const TokenType = union(enum) {
51+ int: isize,
52+ float: f64,
53+ string: []const u8,
54+};
55+
56+const array_lit: [4]u8 = .{ 11, 22, 33, 44 };
57+const sentinal_lit = [_:0]u8{ 1, 2, 3, 4 };
58+
59+test "address of syntax" {
60+ // Get the address of a variable:
61+ const x: i32 = 1234;
62+ const x_ptr = &x;
63+
64+ // Dereference a pointer:
65+ expect(x_ptr.* == 1234);
66+
67+ // When you get the address of a const variable, you get a const pointer to a single item.
68+ expect(@TypeOf(x_ptr) == *const i32);
69+
70+ // If you want to mutate the value, you'd need an address of a mutable variable:
71+ var y: i32 = 5678;
72+ const y_ptr = &y;
73+ expect(@TypeOf(y_ptr) == *i32);
74+ y_ptr.* += 1;
75+ expect(y_ptr.* == 5679);
76+}
77+
78+// integer literals
79+const decimal_int = 98222;
80+const hex_int = 0xff;
81+const another_hex_int = 0xFF;
82+const octal_int = 0o755;
83+const binary_int = 0b11110000;
84+
85+// underscores may be placed between two digits as a visual separator
86+const one_billion = 1_000_000_000;
87+const binary_mask = 0b1_1111_1111;
88+const permissions = 0o7_5_5;
89+const big_address = 0xFF80_0000_0000_0000;
90+
91+// float literals
92+const floating_point = 123.0E+77;
93+const another_float = 123.0;
94+const yet_another = 123.0e+77;
95+
96+const hex_floating_point = 0x103.70p-5;
97+const another_hex_float = 0x103.70;
98+const yet_another_hex_float = 0x103.70P-5;
99+
100+// underscores may be placed between two digits as a visual separator
101+const lightspeed = 299_792_458.000_000;
102+const nanosecond = 0.000_000_001;
103+const more_hex = 0x1234_5678.9ABC_CDEFp-10;
104+
105+fn max(comptime T: type, a: T, b: T) T {
106+ return if (a > b) a else b;
107+}
tests/syntax-tests/source/DotENV/.env+1−1
@@ -54,4 +54,4 @@ TEST_ESCAPE="escaped characters \n \t \r \" \' \$ or maybe a backslash \\..."
54TEST_DOUBLE="Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\"
54TEST_DOUBLE="Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\"
55
55
56# Single Quotes
56# Single Quotes
57−TEST_SINGLE='Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\'
57+TEST_SINGLE='Lorem {$VAR1} ${VAR2} $VAR3 ipsum dolor sit amet\n\r\t\\'
tests/syntax-tests/source/Lean/test.leannew file+68
@@ -0,0 +1,68 @@
1+import data.matrix.notation
2+import data.vector2
3+
4+/-!
5+
6+Helpers that don't currently fit elsewhere...
7+
8+-/
9+
10+lemma split_eq {m n : Type*} (x : m × n) (p p' : m × n) :
11+ p = x ∨ p' = x ∨ (x ≠ p ∧ x ≠ p') := by tauto
12+
13+-- For `playfield`s, the piece type and/or piece index type.
14+variables (X : Type*)
15+variables [has_repr X]
16+
17+namespace chess.utils
18+
19+section repr
20+
21+/--
22+An auxiliary wrapper for `option X` that allows for overriding the `has_repr` instance
23+for `option`, and rather, output just the value in the `some` and a custom provided
24+`string` for `none`.
25+-/
26+structure option_wrapper :=
27+(val : option X)
28+(none_s : string)
29+
30+instance wrapped_option_repr : has_repr (option_wrapper X) :=
31+⟨λ ⟨val, s⟩, (option.map has_repr.repr val).get_or_else s⟩
32+
33+variables {X}
34+/--
35+Construct an `option_wrapper` term from a provided `option X` and the `string`
36+that will override the `has_repr.repr` for `none`.
37+-/
38+def option_wrap (val : option X) (none_s : string) : option_wrapper X := ⟨val, none_s⟩
39+
40+-- The size of the "vectors" for a `fin n' → X`, for `has_repr` definitions
41+variables {m' n' : ℕ}
42+
43+/--
44+For a "vector" `X^n'` represented by the type `Π n' : ℕ, fin n' → X`, where
45+the `X` has a `has_repr` instance itself, we can provide a `has_repr` for the "vector".
46+This definition is used for displaying rows of the playfield, when it is defined
47+via a `matrix`, likely through notation.
48+-/
49+def vec_repr : Π {n' : ℕ}, (fin n' → X) → string :=
50+λ _ v, string.intercalate ", " ((vector.of_fn v).to_list.map repr)
51+
52+instance vec_repr_instance : has_repr (fin n' → X) := ⟨vec_repr⟩
53+
54+/--
55+For a `matrix` `X^(m' × n')` where the `X` has a `has_repr` instance itself,
56+we can provide a `has_repr` for the matrix, using `vec_repr` for each of the rows of the matrix.
57+This definition is used for displaying the playfield, when it is defined
58+via a `matrix`, likely through notation.
59+-/
60+def matrix_repr : Π {m' n'}, matrix (fin m') (fin n') X → string :=
61+λ _ _ M, string.intercalate ";\n" ((vector.of_fn M).to_list.map repr)
62+
63+instance matrix_repr_instance :
64+ has_repr (matrix (fin n') (fin m') X) := ⟨matrix_repr⟩
65+
66+end repr
67+
68+end chess.utils
tests/syntax-tests/source/Svelte/LICENSE → tests/syntax-tests/source/Svelte/LICENSE.mdrenamed

The content is the same.

tests/syntax-tests/source/Zig/example.zignew file+107
@@ -0,0 +1,107 @@
1+//! this is a top level doc, starts with "//!"
2+
3+const std = @import("std");
4+
5+pub fn main() anyerror!void {
6+ const stdout = std.io.getStdOut().writer();
7+ try stdout.print("Hello, {}!\n", .{"world"});
8+}
9+
10+const expect = std.testing.expect;
11+
12+test "comments" {
13+ // comments start with "//" until newline
14+ // foo bar baz
15+ const x = true; // another comment
16+ expect(x);
17+}
18+
19+/// a doc comment starts with "///"
20+/// multiple lines are merged together
21+const Timestamp = struct {
22+ /// number of seconds since epoch
23+ seconds: i64,
24+
25+ /// number of nanoseconds past the second
26+ nano: u32,
27+
28+ const Self = @This();
29+
30+ pub fn unixEpoch() Self {
31+ return Self{
32+ .seconds = 0,
33+ .nanos = 0,
34+ };
35+ }
36+};
37+
38+const my_val = switch (std.Target.current.os.tag) {
39+ .linux => "Linux",
40+ else => "not Linux",
41+};
42+
43+const Book = enum {
44+ paperback,
45+ hardcover,
46+ ebook,
47+ pdf,
48+};
49+
50+const TokenType = union(enum) {
51+ int: isize,
52+ float: f64,
53+ string: []const u8,
54+};
55+
56+const array_lit: [4]u8 = .{ 11, 22, 33, 44 };
57+const sentinal_lit = [_:0]u8{ 1, 2, 3, 4 };
58+
59+test "address of syntax" {
60+ // Get the address of a variable:
61+ const x: i32 = 1234;
62+ const x_ptr = &x;
63+
64+ // Dereference a pointer:
65+ expect(x_ptr.* == 1234);
66+
67+ // When you get the address of a const variable, you get a const pointer to a single item.
68+ expect(@TypeOf(x_ptr) == *const i32);
69+
70+ // If you want to mutate the value, you'd need an address of a mutable variable:
71+ var y: i32 = 5678;
72+ const y_ptr = &y;
73+ expect(@TypeOf(y_ptr) == *i32);
74+ y_ptr.* += 1;
75+ expect(y_ptr.* == 5679);
76+}
77+
78+// integer literals
79+const decimal_int = 98222;
80+const hex_int = 0xff;
81+const another_hex_int = 0xFF;
82+const octal_int = 0o755;
83+const binary_int = 0b11110000;
84+
85+// underscores may be placed between two digits as a visual separator
86+const one_billion = 1_000_000_000;
87+const binary_mask = 0b1_1111_1111;
88+const permissions = 0o7_5_5;
89+const big_address = 0xFF80_0000_0000_0000;
90+
91+// float literals
92+const floating_point = 123.0E+77;
93+const another_float = 123.0;
94+const yet_another = 123.0e+77;
95+
96+const hex_floating_point = 0x103.70p-5;
97+const another_hex_float = 0x103.70;
98+const yet_another_hex_float = 0x103.70P-5;
99+
100+// underscores may be placed between two digits as a visual separator
101+const lightspeed = 299_792_458.000_000;
102+const nanosecond = 0.000_000_001;
103+const more_hex = 0x1234_5678.9ABC_CDEFp-10;
104+
105+fn max(comptime T: type, a: T, b: T) T {
106+ return if (a > b) a else b;
107+}