1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-04 19:01:44 +00:00

Compare commits

..

216 Commits

Author SHA1 Message Date
sharkdp 608cefb05c Bump version 2019-09-03 08:07:42 +02:00
dependabot-preview[bot] 8d0aa39181 Bump ansi_term from 0.12.0 to 0.12.1
Bumps [ansi_term](https://github.com/ogham/rust-ansi-term) from 0.12.0 to 0.12.1.
- [Release notes](https://github.com/ogham/rust-ansi-term/releases)
- [Commits](https://github.com/ogham/rust-ansi-term/compare/v0.12.0...v0.12.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-03 07:21:05 +02:00
David Peter 5815364206 Add packaging status from repology.org 2019-09-01 11:03:35 +02:00
sharkdp 79f016e15c Update syntaxes 2019-08-31 20:58:16 +02:00
sharkdp 26f9125ebb Re-formulate help text 2019-08-31 20:56:53 +02:00
sharkdp 9814eab13f Suppress warning in -A mode 2019-08-31 20:56:53 +02:00
sharkdp 82ca8804a2 Handle non-unicode characters in the preprocessor 2019-08-31 20:56:53 +02:00
pjsier b48b9fcf3b Display binary file content for bat -A 2019-08-31 20:56:53 +02:00
sharkdp c64ab29739 Update min. required rust version 2019-08-31 14:48:42 +02:00
sharkdp 83dd3fb551 Update man page 2019-08-31 14:47:04 +02:00
sharkdp ed345f2889 Fix headline 2019-08-31 14:44:11 +02:00
sharkdp d2492980c0 Update syntaxes and themes 2019-08-31 14:43:20 +02:00
sharkdp 47d5130764 Bump version 2019-08-31 14:43:04 +02:00
sharkdp 4ba45e2ba2 Add first version of 'man page' syntax, closes #523 2019-08-31 14:32:37 +02:00
sharkdp 7076ae5cd9 Update dependencies 2019-08-31 14:14:08 +02:00
sharkdp 2e71146801 Fix another instance of the 'bat cache' bug, closes #584 2019-08-31 14:13:36 +02:00
sharkdp f3824bad17 Add explicit terminal width for test 2019-08-31 13:46:48 +02:00
sharkdp ec908d5937 Run 'cargo fmt' 2019-08-31 13:46:48 +02:00
sharkdp 3a75d85b80 Add test for 'snip' feature 2019-08-31 13:46:48 +02:00
sharkdp 63d652dab5 Add 'dyn' keyword for trait references 2019-08-31 13:46:48 +02:00
Ethan P 7f2e61d579 Add new style component to separate multiple '--line-range's 2019-08-31 13:46:48 +02:00
sharkdp e289a2c698 Add short '-L' option as an alias for --list-languages 2019-08-31 13:22:16 +02:00
sharkdp 83a213bae7 Add 'strace' syntax, closes #599 2019-08-31 13:13:42 +02:00
sharkdp 3967e28ded Add SCSS and Sass syntax, closes #637 2019-08-31 13:09:38 +02:00
sharkdp 2dc2a3712a Add Verilog syntax, closes #616 2019-08-31 12:59:02 +02:00
sharkdp 10e0f9efb0 Install fish completions in DEB package, closes #554 2019-08-28 21:06:52 +02:00
dependabot-preview[bot] f8ea075e78 Bump console from 0.7.7 to 0.8.0
Bumps [console](https://github.com/mitsuhiko/console) from 0.7.7 to 0.8.0.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Commits](https://github.com/mitsuhiko/console/compare/0.7.7...0.8.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-26 21:44:57 +02:00
dependabot-preview[bot] c187dce2c2 Bump lazy_static from 1.3.0 to 1.4.0
Bumps [lazy_static](https://github.com/rust-lang-nursery/lazy-static.rs) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/rust-lang-nursery/lazy-static.rs/releases)
- [Commits](https://github.com/rust-lang-nursery/lazy-static.rs/compare/1.3.0...1.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-26 07:13:01 +02:00
dependabot-preview[bot] 108c907d69 Bump git2 from 0.9.2 to 0.10.0
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.9.2 to 0.10.0.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/git2-curl-0.9.2...git2-curl-0.10.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-24 08:47:50 +02:00
sharkdp 187a3b9341 Use consistent syntax for command-line options
closes #574
2019-08-15 21:57:32 +02:00
David Peter 9c2d4f6a51 Add libc6-dev dependency for aarch64 2019-08-10 15:58:13 +02:00
sharkdp c1126157d4 Re-enable aarch64 builds 2019-08-10 15:58:13 +02:00
dependabot-preview[bot] dcfa810112 Bump syntect from 3.2.0 to 3.2.1
Bumps [syntect](https://github.com/trishume/syntect) from 3.2.0 to 3.2.1.
- [Release notes](https://github.com/trishume/syntect/releases)
- [Changelog](https://github.com/trishume/syntect/blob/master/CHANGELOG.md)
- [Commits](https://github.com/trishume/syntect/compare/v3.2.0...v3.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-08-10 14:06:13 +02:00
Dan Davison f963104006 Add GraphQL sublime syntax submodule 2019-08-10 13:17:02 +02:00
sharkdp 45e1c0ea6f Temporarily disable aarch64 2019-08-02 21:14:44 +02:00
sharkdp 590a1e9a4b Bump minimum supported version to 1.33 2019-08-02 21:00:33 +02:00
sharkdp 8e2c6abb13 Update dependencies 2019-08-02 20:57:16 +02:00
Wild Kat 28266ee441 use explicit dyn with Write to appease compiler 2019-08-02 18:50:55 +02:00
Ethan P 21821f1d4c Updated snapshot tests 2019-07-26 06:51:33 +02:00
Ethan P 772ce2e4fe Print a horizontal header line when 'grid' style without 'header' style 2019-07-26 06:51:33 +02:00
dependabot-preview[bot] 35ca1c5191 Bump atty from 0.2.12 to 0.2.13
Bumps [atty](https://github.com/softprops/atty) from 0.2.12 to 0.2.13.
- [Release notes](https://github.com/softprops/atty/releases)
- [Changelog](https://github.com/softprops/atty/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/atty/compare/0.2.12...0.2.13)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-25 21:34:19 +02:00
dependabot-preview[bot] 0cc60a1519 Bump wild from 2.0.1 to 2.0.2
Bumps [wild](https://gitlab.com/kornelski/wild) from 2.0.1 to 2.0.2.
- [Release notes](https://gitlab.com/kornelski/wild/tags)
- [Commits](https://gitlab.com/kornelski/wild/commits/master)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-24 21:50:05 +02:00
dependabot-preview[bot] ee6659dacf Bump ansi_term from 0.11.0 to 0.12.0
Bumps [ansi_term](https://github.com/ogham/rust-ansi-term) from 0.11.0 to 0.12.0.
- [Release notes](https://github.com/ogham/rust-ansi-term/releases)
- [Commits](https://github.com/ogham/rust-ansi-term/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-24 21:45:44 +02:00
sharkdp 76c615a304 Allow leading minus in '--terminal-width <value>'
closes #611
2019-07-24 21:44:25 +02:00
Igor Gnatenko e8c04672f0 Small improvements for Fedora instructions
Anything older than F29 is EOL now, so no need to mention it. Also in F29+ you can use standard `dnf install`.
2019-07-24 21:38:11 +02:00
dependabot-preview[bot] 7f5a5612e4 Bump atty from 0.2.11 to 0.2.12
Bumps [atty](https://github.com/softprops/atty) from 0.2.11 to 0.2.12.
- [Release notes](https://github.com/softprops/atty/releases)
- [Changelog](https://github.com/softprops/atty/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/atty/compare/0.2.11...0.2.12)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-12 07:15:42 +02:00
dependabot-preview[bot] eee5d424bb [Security] Bump smallvec from 0.6.9 to 0.6.10
Bumps [smallvec](https://github.com/servo/rust-smallvec) from 0.6.9 to 0.6.10. **This update includes security fixes.**
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-07 15:34:01 +02:00
dependabot-preview[bot] e5311e4b30 Bump console from 0.7.6 to 0.7.7
Bumps [console](https://github.com/mitsuhiko/console) from 0.7.6 to 0.7.7.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Commits](https://github.com/mitsuhiko/console/compare/0.7.6...0.7.7)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-07-05 14:34:15 +02:00
dependabot-preview[bot] a1b9334a44 Bump console from 0.7.5 to 0.7.6
Bumps [console](https://github.com/mitsuhiko/console) from 0.7.5 to 0.7.6.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Commits](https://github.com/mitsuhiko/console/compare/0.7.5...0.7.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-06-20 10:04:08 +02:00
Chloe Kudryavtsev d86b7cf7e0 Add Alpine Linux installation instructions
Resolves #586
2019-06-11 07:40:23 +02:00
dependabot-preview[bot] 67834da681 Bump git2 from 0.9.0 to 0.9.1
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.9.0 to 0.9.1.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.9.0...0.9.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-06-10 11:15:51 +02:00
toku-sa-n dcdf8dfaa7 Add install instructions(ja) for Gentoo Users. 2019-06-09 17:50:18 +02:00
toku-sa-n 9a44fa11c0 Add install instructions for Gentoo Users. 2019-06-09 17:50:18 +02:00
sharkdp 4ee0b2e16d Merge branch 'issmirnov-ssh-config' 2019-06-07 08:17:17 +02:00
sharkdp 518997135e Merge branch 'ssh-config' of https://github.com/issmirnov/bat into issmirnov-ssh-config 2019-06-07 08:17:04 +02:00
Ivan Smirnov 69fc1caead Add support for "etc/hosts" files.
- Syntax author: https://github.com/brandonwamboldt/sublime-hosts

Since the upstream version only has a tmLanguage, added a sublime-syntax
file manually.
2019-06-07 08:02:38 +02:00
Ivan Smirnov 175dd4c290 Add SSH config syntax
Tested:
```
bash assets/create.sh
cargo build
target/debug/bat --language ssh_config ~/.ssh/config
```
2019-06-06 20:01:23 -07:00
dependabot-preview[bot] e9210c0f6c Bump git2 from 0.8.0 to 0.9.0
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.8.0 to 0.9.0.
- [Release notes](https://github.com/rust-lang/git2-rs/releases)
- [Commits](https://github.com/rust-lang/git2-rs/compare/git2-curl-0.8.0...0.9.0)
2019-06-05 07:17:09 +02:00
sharkdp 3795acbd17 Add '.env' (DotENV) syntax 2019-05-31 21:05:34 +02:00
sharkdp c7d08cfcfd Add 'requirements.txt' syntax 2019-05-31 20:58:08 +02:00
dependabot-preview[bot] 8ec96da9f0 Bump dirs from 2.0.0 to 2.0.1
Bumps [dirs](https://github.com/soc/dirs-rs) from 2.0.0 to 2.0.1.
- [Release notes](https://github.com/soc/dirs-rs/releases)
- [Commits](https://github.com/soc/dirs-rs/commits)
2019-05-31 08:57:04 +02:00
Fernando Mendes c9d7e3652b Enforce the creation of the full cache dir path
Fixes #576
2019-05-30 22:28:52 +02:00
Brice Waegeneire dfa024f9e6 Add Org mode syntax, closes sharkdp#36 2019-05-29 19:52:06 +02:00
dependabot-preview[bot] b2757cb461 Bump dirs from 1.0.5 to 2.0.0
Bumps [dirs](https://github.com/soc/dirs-rs) from 1.0.5 to 2.0.0.
- [Release notes](https://github.com/soc/dirs-rs/releases)
- [Commits](https://github.com/soc/dirs-rs/commits)
2019-05-28 21:32:57 +02:00
sharkdp 416a0fd439 Fix autocompletion-path 2019-05-15 23:24:37 +02:00
sharkdp 9b1b3dda14 Only print the header for empty files
Instead of printing
```
───────┬─────────────────────────────────────────────────────────
       │ File: some-file
───────┼─────────────────────────────────────────────────────────
───────┴─────────────────────────────────────────────────────────
```
for empty files, bat will now print
```
───────┬─────────────────────────────────────────────────────────
       │ File: some-file   <EMPTY>
───────┴─────────────────────────────────────────────────────────
```
2019-05-15 22:37:03 +02:00
sharkdp ae7db313a6 Update man page 2019-05-15 22:14:40 +02:00
sharkdp 3c4384990d Update syntaxes and themes 2019-05-15 22:12:02 +02:00
sharkdp 260814c377 Bump version to 0.11 2019-05-15 22:07:35 +02:00
sharkdp 3675a82a1b Update dependencies 2019-05-15 22:06:28 +02:00
sharkdp 5b2b594919 Revert "Run 'cargo fmt'" (outdated rustfmt)
This reverts commit dd40f7545d.
2019-05-15 08:07:08 +02:00
sharkdp 9d53ce6be6 Fix warning 2019-05-14 23:42:23 +02:00
sharkdp 51e05499a9 Update dependencies 2019-05-14 23:40:21 +02:00
sharkdp dd40f7545d Run 'cargo fmt' 2019-05-14 23:40:07 +02:00
sharkdp c709bf2103 Print a warning message instead of just '<BINARY>' 2019-05-14 23:35:22 +02:00
Maksim Panfilov f37dbb80a8 Added printing of "<BINARY>" for binary files in the interactive mode if header decorations are turned off 2019-05-14 23:35:22 +02:00
sharkdp 0a1e08da96 Extend help text for --terminal-width and --wrap, closes #535 2019-05-14 23:24:13 +02:00
Ethan P 06b8dcb7eb Update fish completions for new --list-languages format 2019-05-14 22:50:42 +02:00
Ethan P 493a4e719e Added non-interactive mode for --list-languages
This makes scripting it a lot easier and less hacky.
2019-05-14 22:50:42 +02:00
Ethan P 27e0ca98d9 Remove language completions for config files 2019-05-14 22:50:42 +02:00
Ethan P 1b2066c5f2 Add fish shell argument completions for --language option 2019-05-14 22:50:42 +02:00
dependabot[bot] 4ec3cdb5b8 Bump error-chain from 0.12.0 to 0.12.1
Bumps [error-chain](https://github.com/rust-lang-nursery/error-chain) from 0.12.0 to 0.12.1.
- [Release notes](https://github.com/rust-lang-nursery/error-chain/releases)
- [Changelog](https://github.com/rust-lang-nursery/error-chain/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang-nursery/error-chain/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-05-13 18:32:28 +02:00
sharkdp 72152296c7 Fix accidental printing of files named 'cache'
This also adds two regression tests, so this will hopefully not pop up
again.

closes #557
2019-05-10 17:55:46 -05:00
Ethan P 2b9d25df05 Replace iterator with string starts_with and ends_with 2019-05-10 17:52:35 -05:00
Ethan P cc8186103b Reformatted with cargo fmt. 2019-05-10 17:52:35 -05:00
Ethan P 0ad09df7ab Improved logic when encountering ANSI in character wrap mode
Fixes #551
2019-05-10 17:52:35 -05:00
Ethan P 7ef0fe091d Cleaned up terminal-width validation even more 2019-05-10 17:50:58 -05:00
Ethan P 89fcbb2b15 Cleaned up terminal-width validation slightly 2019-05-10 17:50:58 -05:00
Ethan P a7e2bb86cb Add validation for --terminal-width option 2019-05-10 17:50:58 -05:00
sharkdp 1ce0bc8e0d Slightly modified help text 2019-05-10 11:04:46 -05:00
Ethan P fde00eec98 Add -pp for plain styling and no pager 2019-05-10 11:01:02 -05:00
Mitchell Kember bb6594e691 Add 3 new themes: ansi-light, ansi-dark, base16
Also, interpret transparent colors (#RRGGBB00) as specifying a terminal
color palette number with RR. The three new themes use this.
2019-05-08 07:35:43 -05:00
rasmuskriest e7c5561df7 Update Chocolatey package name to bat 2019-04-25 17:58:15 +02:00
rasmuskriest 0aabbc03d7 Add Chocolatey package instructions 2019-04-25 17:58:15 +02:00
Alexander Hultnér 8a5b59febc Updated manual to include -H, --highlight-line <N> 2019-04-25 17:57:01 +02:00
Tim Sampson 7afdd44c43 cache/misc: be more cautious with bash 2019-04-25 17:52:21 +02:00
Tim Sampson d72549a873 add fish shell syntax definition 2019-04-25 17:52:21 +02:00
evdev 1ba8540e5f Updated packaging script to include manual fish shell completions 2019-04-13 10:59:22 +02:00
evdev a6cee4da67 Removed completions file accidentaly left in root dir 2019-04-13 10:59:22 +02:00
evdev cd6850947e Updated fish completions to include parameter completion for available themes, added cache subcommand completions 2019-04-13 10:59:22 +02:00
evdev 14bfedeb20 Updated fish completions to include parameter completion for flags: color, italic-text, decorations, paging, wrap 2019-04-13 10:59:22 +02:00
evdev 8fe65252f7 WIP: added manual minimal fish shell completions for current flags. Does not include flag sub-options like language lists or subcommands 2019-04-13 10:59:22 +02:00
evdev 5e9351445f WIP: added manual minimal fish shell completions for current flags. Does not include flag sub-options like language lists or subcommands 2019-04-13 10:59:22 +02:00
dependabot[bot] 2fdfb8de40 Bump escargot from 0.4.0 to 0.5.0
Bumps [escargot](https://github.com/crate-ci/escargot) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/crate-ci/escargot/releases)
- [Changelog](https://github.com/crate-ci/escargot/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/escargot/compare/v0.4.0...v0.5.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-04-09 21:48:33 +02:00
dependabot[bot] f8c759edff Bump clap from 2.32.0 to 2.33.0
Bumps [clap](https://github.com/clap-rs/clap) from 2.32.0 to 2.33.0.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-04-08 13:00:03 +02:00
dependabot[bot] e34431f922 Bump assert_cmd from 0.11.0 to 0.11.1
Bumps [assert_cmd](https://github.com/assert-rs/assert_cmd) from 0.11.0 to 0.11.1.
- [Release notes](https://github.com/assert-rs/assert_cmd/releases)
- [Changelog](https://github.com/assert-rs/assert_cmd/blob/master/CHANGELOG.md)
- [Commits](https://github.com/assert-rs/assert_cmd/compare/v0.11.0...v0.11.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-04-04 21:11:46 +02:00
Björn c96927b550 Update F# syntax 2019-04-04 21:11:19 +02:00
Laurent Arnoud 921cc0d1cb Add copyright file on Debian package 2019-03-17 18:59:28 +01:00
dependabot[bot] dbc49e534a Bump syntect from 3.1.0 to 3.2.0
Bumps [syntect](https://github.com/trishume/syntect) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/trishume/syntect/releases)
- [Changelog](https://github.com/trishume/syntect/blob/master/CHANGELOG.md)
- [Commits](https://github.com/trishume/syntect/compare/v3.1.0...v3.2.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-03-11 06:37:16 +01:00
David Peter 7755ed79e0 Delete .DS_Store 2019-03-11 06:35:21 +01:00
Daniele Esposti 50aabf331d Updated minimum version of Rust 2019-03-09 07:43:41 +01:00
Daniele Esposti f259ff2920 Formatted code 2019-03-09 07:43:41 +01:00
Daniele Esposti 82f14121bd Applied linter fixes 2019-03-09 07:43:41 +01:00
Daniele Esposti a21ae614e6 Migrated to Rust 2018 2019-03-09 07:43:41 +01:00
dependabot[bot] b94c94e845 Bump lazy_static from 1.2.0 to 1.3.0
Bumps [lazy_static](https://github.com/rust-lang-nursery/lazy-static.rs) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/rust-lang-nursery/lazy-static.rs/releases)
- [Commits](https://github.com/rust-lang-nursery/lazy-static.rs/compare/1.2.0...1.3.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-03-08 21:45:42 +01:00
dependabot[bot] 161d107ec3 Bump dirs from 1.0.4 to 1.0.5
Bumps [dirs](https://github.com/soc/dirs-rs) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/soc/dirs-rs/releases)
- [Commits](https://github.com/soc/dirs-rs/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-03-05 22:31:16 +01:00
dependabot[bot] ecf147fd96 Bump syntect from 3.0.2 to 3.1.0
Bumps [syntect](https://github.com/trishume/syntect) from 3.0.2 to 3.1.0.
- [Release notes](https://github.com/trishume/syntect/releases)
- [Changelog](https://github.com/trishume/syntect/blob/master/CHANGELOG.md)
- [Commits](https://github.com/trishume/syntect/compare/v3.0.2...v3.1.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-02-25 07:03:17 +01:00
sharkdp f0771d6532 Do not replace arguments to pager when --pager is used, closes #509 2019-02-18 20:28:44 +01:00
Geoff Shannon d8f28c177a Make fd link actually link to fd 2019-02-17 09:19:42 +01:00
David Peter fbee9df719 Add "git show" section 2019-02-11 22:04:22 +01:00
David Peter 6e9ca7d6dc Add "xclip" section 2019-02-11 22:01:03 +01:00
David Peter a9ec5c063a Add documentation about "tail -f" 2019-02-11 21:54:16 +01:00
David Peter 8470fd7173 Add "Integration with other tools" section 2019-02-11 21:38:18 +01:00
Reid Wagner 76b7418e35 Only print contents if file wasn't empty, or EOF wasn't first thing received from stdin. 2019-02-11 20:33:16 +01:00
Reid Wagner 10c5f79640 Revert "Check result of read_until, and return Error if 0, which indicates EOF was found before delimeter."
This reverts commit 61e888de7f.
2019-02-11 20:33:16 +01:00
sharkdp 9e11d66979 Handle UTF-16 encoding errors with replacement characters 2019-02-10 10:18:07 +01:00
sharkdp fa3244f7c1 Add test for UTF-16LE encoding 2019-02-10 10:18:07 +01:00
sharkdp 906774e6d3 Integration tests for single-line files 2019-02-10 10:18:07 +01:00
Reid Wagner cec9cc073c Add integration tests running bat with empty input files. 2019-02-08 23:30:33 +01:00
David Peter a16789a060 Update alternatives.md 2019-02-07 23:52:31 +01:00
sharkdp e09499b3df Move config-dir and cache-dir from 'bat cache' to 'bat' 2019-02-07 23:27:53 +01:00
sharkdp cff01d81fa Rename 'bat cache --init' to 'bat cache --build' 2019-02-07 23:27:53 +01:00
sharkdp 31608c9a03 Update syntaxes 2019-02-07 23:01:06 +01:00
sharkdp 357ce84c56 Bump version to 0.10 2019-02-07 23:00:40 +01:00
sharkdp 3a5c52641b Update assets/syntaxes/Packages 2019-02-07 22:53:18 +01:00
sharkdp 6e8fca5bb2 Replace less command line arguments only for PAGER 2019-02-07 22:37:33 +01:00
Park Juhyung 63c77383ce Ignore flags from PAGER env var if the program is 'less' 2019-02-07 22:37:33 +01:00
sharkdp 4df22e617f Update documentation 2019-02-07 22:19:32 +01:00
sharkdp 6473e8c1be Remove import 2019-02-07 22:19:32 +01:00
sharkdp 972a764a74 Simplify Optional handling 2019-02-07 22:19:32 +01:00
sharkdp 54143d1403 Add --cache-dir option 2019-02-07 22:19:32 +01:00
sharkdp 6523bbf62f Replace 'is_absolute_path' with map and filter 2019-02-07 22:19:32 +01:00
Lavi 05e2c2c66b removed compile errors and warnings on non-macs 2019-02-07 22:19:32 +01:00
Lavi 69227222b5 config and cache now check XDG env vars first
`XDG_CACHE_HOME` and `XDG_CONFIG_HOME` are checked first and fall-back
to `~/.cache/` and `~/.config/`.
2019-02-07 22:19:32 +01:00
Lavi 49af3e854b Set cache_dir on MacOS to ~/.cache/bat/ 2019-02-07 22:19:32 +01:00
Lavi 6a8e4757b7 Updated bat config dir for MacOs
Removed directories crate and using dirs_rs
Changed bat config file and cache dir on MacOs:
config: ~/.config/bat/config
cache: ~/.config/bat/cache/
2019-02-07 22:19:32 +01:00
Harald Hoyer 91deef8b13 add varlink syntax
Varlink is an interface description format and protocol that aims
to make services accessible to both humans and machines in the
simplest feasible way.

See: https://varlink.org/ and https://github.com/varlink/ for
more information
2019-02-07 07:40:22 +01:00
Reid Wagner 61e888de7f Check result of read_until, and return Error if 0, which indicates EOF was found before delimeter. 2019-02-07 07:32:28 +01:00
Okumura Takahiro f3f9f10f05 Add Jsonnet (*.jsonnet) syntax
Jsonnet: https://jsonnet.org/
sublime-syntax: https://github.com/gburiola/sublime-jsonnet-syntax
2019-02-04 23:28:39 +01:00
object_1037 29ffa2a832 add Fedora instructions 2019-02-03 12:58:04 +01:00
object_1037 42a873fdb8 update README-ja.md 2019-02-03 12:58:04 +01:00
dependabot[bot] 82f048aedb Bump assert_cmd from 0.10.2 to 0.11.0
Bumps [assert_cmd](https://github.com/assert-rs/assert_cmd) from 0.10.2 to 0.11.0.
- [Release notes](https://github.com/assert-rs/assert_cmd/releases)
- [Changelog](https://github.com/assert-rs/assert_cmd/blob/master/CHANGELOG.md)
- [Commits](https://github.com/assert-rs/assert_cmd/compare/v0.10.2...v0.11.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-29 08:13:31 +01:00
Benjamin Santos ae08785ec8 Add Terraform syntax 2019-01-28 20:09:56 +01:00
sharkdp a500629359 Completely disable generation of shell completion files 2019-01-26 19:11:54 +01:00
Gergely Gombos 724a5fac99 Fix Fedora instructions in README
Correct instructions regarding Fedora Modular repos.
2019-01-26 19:11:37 +01:00
sharkdp c483e49b92 Consistent naming for submodules 2019-01-20 10:22:35 +01:00
Benjamin 94c9b40694 Protobuf-syntax and ProtobufText syntax (#474) 2019-01-20 10:20:53 +01:00
dependabot[bot] 0c9dc3b257 Bump console from 0.7.3 to 0.7.5
Bumps [console](https://github.com/mitsuhiko/console) from 0.7.3 to 0.7.5.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Commits](https://github.com/mitsuhiko/console/compare/0.7.3...0.7.5)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-18 07:25:29 +01:00
Benjamin Santos 3b5174bb1d Add syslog-syntax 2019-01-18 07:24:46 +01:00
David Peter 3324505383 Update README.md 2019-01-16 20:04:46 +01:00
dependabot[bot] de7872f8a8 Bump console from 0.7.2 to 0.7.3
Bumps [console](https://github.com/mitsuhiko/console) from 0.7.2 to 0.7.3.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Commits](https://github.com/mitsuhiko/console/compare/0.7.2...0.7.3)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-14 09:12:12 +01:00
dependabot[bot] abf0229741 Bump escargot from 0.3.1 to 0.4.0
Bumps [escargot](https://github.com/crate-ci/escargot) from 0.3.1 to 0.4.0.
- [Release notes](https://github.com/crate-ci/escargot/releases)
- [Changelog](https://github.com/crate-ci/escargot/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/escargot/compare/v0.3.1...v0.4.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-01-01 12:32:25 +01:00
dependabot[bot] e04bccd12d Bump console from 0.7.1 to 0.7.2
Bumps [console](https://github.com/mitsuhiko/console) from 0.7.1 to 0.7.2.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Commits](https://github.com/mitsuhiko/console/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-24 08:41:06 +01:00
David Peter 668c8a6703 Merge pull request #453 from sharkdp/line-highlight
Line highlight
2018-12-18 09:06:28 +01:00
sharkdp bd68684537 Fix the number of values to one 2018-12-16 22:35:22 +01:00
sharkdp c2847f6a9f Short options for line-range and highlight-line 2018-12-16 22:17:39 +01:00
sharkdp cf7ed042c1 Colorize the whole line 2018-12-16 21:53:15 +01:00
sharkdp 6b92814ea0 Allow for multiple highlighted lines 2018-12-16 21:00:18 +01:00
sharkdp a236a9b195 Merge branch 'master' of https://github.com/tskinn/bat into tskinn-master 2018-12-16 20:43:36 +01:00
sharkdp b68c5d8576 Bump minimum required Rust version to 1.30 2018-12-14 23:34:13 +01:00
sharkdp fee57d71d9 Print ANSI-reset code before newline
fixes #379
2018-12-14 23:34:13 +01:00
sharkdp 5d3205acc0 Add x86_64 Assembly manually 2018-12-14 23:07:11 +01:00
sharkdp 4e6816abd6 Remove problematic 'Assembly (x86_64)' submodule 2018-12-14 23:07:11 +01:00
dependabot[bot] 72e8036edc Bump git2 from 0.7.5 to 0.8.0
Bumps [git2](https://github.com/alexcrichton/git2-rs) from 0.7.5 to 0.8.0.
- [Release notes](https://github.com/alexcrichton/git2-rs/releases)
- [Commits](https://github.com/alexcrichton/git2-rs/compare/libgit2-sys-0.7.5...git2-curl-0.8.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-14 22:55:25 +01:00
sharkdp 397def1320 Omit launching of pager if NO file exists
closes #387
2018-12-14 22:53:31 +01:00
sharkdp d2d29180a7 Add ARM assembly 2018-12-14 22:52:57 +01:00
sharkdp 2f263c9fbf Add x86_64 assembly 2018-12-14 22:46:50 +01:00
ufuji1984 4ff360669f add quotes around filename
and make it more concise by using map_err
2018-12-11 22:24:52 +01:00
ufuji1984 549e5d7355 Report filename if File::open return Err
From issue #441
2018-12-11 22:24:52 +01:00
Markus Thömmes dd48d29c28 Add AsciiDoc syntax. 2018-12-11 21:12:29 +01:00
sharkdp 98ee5f7400 Add vimpager to alternatives, closes #429 2018-12-07 20:28:47 +01:00
dependabot[bot] 638c04c13e Bump console from 0.7.0 to 0.7.1
Bumps [console](https://github.com/mitsuhiko/console) from 0.7.0 to 0.7.1.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Commits](https://github.com/mitsuhiko/console/compare/0.7.0...0.7.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-12-03 07:04:34 +01:00
David Peter b1c865acaa Update README.md 2018-12-02 22:02:39 +01:00
Lavi Blumberg d3d795ffb2 Removed confusing variable from examples in README.md
Removed confusing the variable `BAT_CONFIG_DIR` from examples because it
 is not a real configuration option for bat.
2018-12-02 20:19:12 +01:00
David Peter 0571c51487 Add copyright notice in MIT license 2018-12-02 18:35:29 +01:00
Ole Martin Ruud 348c9f3562 Enhance SyntaxMapping with impl Trait 2018-11-27 20:36:23 +01:00
Ole Martin Ruud 6b6a8f8e16 Fix doc comment typo 2018-11-27 20:34:32 +01:00
Keith Devens 6aa002850c Correct typo in readme 2018-11-26 20:11:25 +01:00
dependabot[bot] 49c22c8d39 Bump console from 0.6.2 to 0.7.0
Bumps [console](https://github.com/mitsuhiko/console) from 0.6.2 to 0.7.0.
- [Release notes](https://github.com/mitsuhiko/console/releases)
- [Commits](https://github.com/mitsuhiko/console/compare/0.6.2...0.7.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-23 08:04:46 +01:00
dependabot[bot] 673caf6b59 Bump assert_cmd from 0.10.1 to 0.10.2
Bumps [assert_cmd](https://github.com/assert-rs/assert_cmd) from 0.10.1 to 0.10.2.
- [Release notes](https://github.com/assert-rs/assert_cmd/releases)
- [Changelog](https://github.com/assert-rs/assert_cmd/blob/master/CHANGELOG.md)
- [Commits](https://github.com/assert-rs/assert_cmd/compare/v0.10.1...v0.10.2)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-21 19:11:22 +01:00
David Peter e6ffab3cb4 Update assets/README.md 2018-11-19 18:48:36 +01:00
Jerome Leclanche 4e43f8fa74 Highlight XDG desktop entry as .ini file
Reference: https://standards.freedesktop.org/desktop-entry-spec/latest/
2018-11-19 18:48:36 +01:00
David Peter bac1b16885 Consistent spelling of "color" 2018-11-18 12:11:07 +01:00
Ahmed El Gabri 778a4929a8 Add twig support 2018-11-18 11:58:05 +01:00
sh-tech 5c22dd4248 add close tag 2018-11-15 08:53:03 +01:00
sh-tech 214cd0f8ea add link to original README 2018-11-15 08:53:03 +01:00
sh-tech 9fd61fcb6d add table of contents 2018-11-15 08:53:03 +01:00
sh-tech edf1d3b256 modify url 2018-11-15 08:53:03 +01:00
sh-tech eca47b2a28 translate Project goals, alternatives 2018-11-15 08:53:03 +01:00
sh-tech 62424e70d7 translate Customization 2018-11-15 08:53:03 +01:00
sh-tech 4791f15222 translate Installation 2018-11-15 08:53:03 +01:00
sh-tech 159f234b78 translate Key Features & How to Use 2018-11-15 08:53:03 +01:00
sh-tech 3ec96127f2 translate table of contents 2018-11-15 08:53:03 +01:00
sh-tech a9acb2711b copy README.md (NOT translate yet) 2018-11-15 08:53:03 +01:00
sharkdp a3182e68e4 Update .gitattributes 2018-11-12 21:49:19 +01:00
sharkdp 0691b18231 Add assets/.gitattributes 2018-11-11 14:50:59 +01:00
sharkdp c711cd1b2e Update .gitattributes 2018-11-11 14:50:05 +01:00
sharkdp 14e6b41a5f Add .gitattributes 2018-11-11 14:49:24 +01:00
Arnav Borborah 532af6556d Use Rust inclusive range (stable in 1.26) 2018-11-11 14:42:22 +01:00
David Peter 26717b0cd2 Update README.md 2018-11-11 14:39:04 +01:00
David Peter 1f177f0a1c Update README.md 2018-11-11 14:35:08 +01:00
David Peter 54c81fa543 Update README.md 2018-11-11 14:32:59 +01:00
David Peter 34dee9e3aa Updates for README 2018-11-11 14:28:18 +01:00
Taylor cea05e9f22 be consistent 2018-10-10 22:19:40 -06:00
sharkdp 2a7851530d Fix formatting 2018-10-10 20:45:10 +02:00
Taylor 1a6709c2cb add line highlight 2018-10-09 22:25:33 -06:00
85 changed files with 8509 additions and 963 deletions
+56
View File
@@ -97,3 +97,59 @@
[submodule "assets/themes/sublime-snazzy"] [submodule "assets/themes/sublime-snazzy"]
path = assets/themes/sublime-snazzy path = assets/themes/sublime-snazzy
url = https://github.com/greggb/sublime-snazzy url = https://github.com/greggb/sublime-snazzy
[submodule "assets/syntaxes/HTML (Twig)"]
path = assets/syntaxes/HTML (Twig)
url = https://github.com/Anomareh/PHP-Twig.tmbundle.git
[submodule "assets/syntaxes/AsciiDoc"]
path = assets/syntaxes/AsciiDoc
url = https://github.com/SublimeText/AsciiDoc.git
[submodule "assets/syntaxes/Assembly (ARM)"]
path = assets/syntaxes/Assembly (ARM)
url = https://github.com/tvi/Sublime-ARM-Assembly
[submodule "assets/syntaxes/syslog-syntax"]
path = assets/syntaxes/Syslog
url = https://github.com/caos21/syslog-syntax.git
branch = master
[submodule "assets/syntaxes/protobuf-syntax-highlighting"]
path = assets/syntaxes/Protobuf
url = https://github.com/VcamX/protobuf-syntax-highlighting.git
branch = master
[submodule "assets/syntaxes/Terraform"]
path = assets/syntaxes/Terraform
url = https://github.com/alexlouden/Terraform.tmLanguage.git
[submodule "assets/syntaxes/Jsonnet"]
path = assets/syntaxes/Jsonnet
url = https://github.com/gburiola/sublime-jsonnet-syntax.git
[submodule "assets/syntaxes/varlink"]
path = assets/syntaxes/varlink
url = https://github.com/varlink/syntax-highlight-varlink.git
[submodule "assets/syntaxes/sublime-fish"]
path = assets/syntaxes/sublime-fish
url = https://github.com/Phidica/sublime-fish.git
[submodule "assets/syntaxes/Org mode"]
path = assets/syntaxes/Org mode
url = https://github.com/jezcope/Org.tmbundle.git
[submodule "assets/syntaxes/requirementstxt"]
path = assets/syntaxes/requirementstxt
url = https://github.com/wuub/requirementstxt
[submodule "assets/syntaxes/DotENV"]
path = assets/syntaxes/DotENV
url = https://github.com/zaynali53/DotENV
[submodule "assets/syntaxes/hosts"]
path = assets/syntaxes/hosts
url = https://github.com/brandonwamboldt/sublime-hosts
[submodule "assets/syntaxes/ssh-config"]
path = assets/syntaxes/ssh-config
url = https://github.com/robballou/sublimetext-sshconfig.git
[submodule "assets/syntaxes/GraphQL"]
path = assets/syntaxes/GraphQL
url = https://github.com/dncrews/GraphQL-SublimeText3.git
[submodule "assets/syntaxes/Verilog"]
path = assets/syntaxes/Verilog
url = https://github.com/pro711/sublime-verilog
[submodule "assets/syntaxes/SCSS_Sass"]
path = assets/syntaxes/SCSS_Sass
url = https://github.com/braver/SublimeSass
[submodule "assets/syntaxes/Strace"]
path = assets/syntaxes/Strace
url = https://github.com/djuretic/SublimeStrace
+3 -3
View File
@@ -32,15 +32,15 @@ matrix:
# Minimum Rust supported channel. # Minimum Rust supported channel.
- os: linux - os: linux
rust: 1.29.0 rust: 1.35.0
env: TARGET=x86_64-unknown-linux-gnu env: TARGET=x86_64-unknown-linux-gnu
- os: linux - os: linux
rust: 1.29.0 rust: 1.35.0
env: env:
- TARGET=x86_64-unknown-linux-musl - TARGET=x86_64-unknown-linux-musl
- CC_x86_64_unknown_linux_musl=/usr/bin/musl-gcc - CC_x86_64_unknown_linux_musl=/usr/bin/musl-gcc
- os: osx - os: osx
rust: 1.29.0 rust: 1.35.0
env: TARGET=x86_64-apple-darwin env: TARGET=x86_64-apple-darwin
# Code formatting check # Code formatting check
Generated
+652 -456
View File
File diff suppressed because it is too large Load Diff
+13 -12
View File
@@ -7,37 +7,38 @@ license = "MIT/Apache-2.0"
name = "bat" name = "bat"
readme = "README.md" readme = "README.md"
repository = "https://github.com/sharkdp/bat" repository = "https://github.com/sharkdp/bat"
version = "0.9.0" version = "0.12.1"
exclude = [ exclude = [
"assets/syntaxes/*", "assets/syntaxes/*",
"assets/themes/*", "assets/themes/*",
] ]
build = "build.rs" build = "build.rs"
edition = '2018'
[dependencies] [dependencies]
atty = "0.2.2" atty = "0.2.13"
ansi_term = "0.11" ansi_term = "^0.12.1"
ansi_colours = "^1.0" ansi_colours = "^1.0"
console = "0.6" console = "0.8"
directories = "1.0" dirs = "2.0"
lazy_static = "1.2" lazy_static = "1.4"
wild = "2.0" wild = "2.0"
content_inspector = "0.2.4" content_inspector = "0.2.4"
encoding = "0.2" encoding = "0.2"
shell-words = "0.1.0" shell-words = "0.1.0"
[dependencies.git2] [dependencies.git2]
version = "0.7" version = "0.10"
default-features = false default-features = false
features = [] features = []
[dependencies.syntect] [dependencies.syntect]
version = "3.0.2" version = "3.2.1"
default-features = false default-features = false
features = ["parsing", "yaml-load", "dump-load", "dump-create"] features = ["parsing", "yaml-load", "dump-load", "dump-create"]
[dependencies.clap] [dependencies.clap]
version = "2.32" version = "2.33"
default-features = false default-features = false
features = ["suggestions", "color", "wrap_help"] features = ["suggestions", "color", "wrap_help"]
@@ -48,8 +49,8 @@ features = []
[dev-dependencies] [dev-dependencies]
tempdir = "0.3" tempdir = "0.3"
assert_cmd = "0.10.1" assert_cmd = "0.11.1"
escargot = "0.3.1" escargot = "0.5.0"
[build-dependencies] [build-dependencies]
clap = "2.32" clap = "2.33"
+2
View File
@@ -1,3 +1,5 @@
Copyright (c) 2018 bat-developers (https://github.com/sharkdp/bat).
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
+127 -34
View File
@@ -13,7 +13,7 @@
<a href="#installation">Installation</a> • <a href="#installation">Installation</a> •
<a href="#customization">Customization</a> • <a href="#customization">Customization</a> •
<a href="#project-goals-and-alternatives">Project goals, alternatives</a> • <a href="#project-goals-and-alternatives">Project goals, alternatives</a> •
Translation [<a href="https://github.com/chinanf-boy/bat-zh">中文</a>] Translation [<a href="https://github.com/chinanf-boy/bat-zh">中文</a>][<a href="doc/README-ja.md">日本文</a>]
</p> </p>
### Syntax highlighting ### Syntax highlighting
@@ -32,7 +32,10 @@ languages:
### Show non-printable characters ### Show non-printable characters
![Non-printable character example](https://i.imgur.com/2KTHhYT.png) You can use the `-A`/`--show-all` option to show and highlight non-printable
characters:
![Non-printable character example](https://i.imgur.com/WndGp9H.png)
### Automatic paging ### Automatic paging
@@ -41,8 +44,9 @@ languages:
### File concatenation ### File concatenation
Oh.. you can also use it to concatenate files :wink:. Whenever Oh.. you can also use it to concatenate files :wink:. Whenever
`bat` detects a non-interactive terminal, it will fall back to printing `bat` detects a non-interactive terminal (i.e. when you pipe into another process
the plain file contents. or into a file), `bat` will act as a drop-in replacement for `cat` and
fall back to printing the plain file contents.
## How to use ## How to use
@@ -70,8 +74,12 @@ Read from stdin, specify the language explicitly
> yaml2json .travis.yml | json_pp | bat -l json > yaml2json .travis.yml | json_pp | bat -l json
``` ```
Show and highlight non-printable characters:
```bash
> bat -A /etc/hosts
```
As a replacement for `cat`: Use it as a `cat` replacement:
```bash ```bash
bat > note.md # quickly create a new file bat > note.md # quickly create a new file
@@ -83,15 +91,78 @@ bat -n main.rs # show line numbers (only)
bat f - g # output 'f', then stdin, then 'g'. bat f - g # output 'f', then stdin, then 'g'.
``` ```
### Integration with other tools
#### `find` or `fd`
You can use the `-exec` option of `find` to preview all search results with `bat`:
```bash
find … -exec bat {} +
```
If you happen to use [`fd`](https://github.com/sharkdp/fd), you can use the `-X`/`--exec-batch` option to do the same:
```bash
fd … -X bat
```
#### `tail -f`
`bat` can be combined with `tail -f` to continuously monitor a given file with syntax highlighting.
```bash
tail -f /var/log/pacman.log | bat --paging=never -l log
```
Note that we have to switch off paging in order for this to work. We have also specified the syntax
explicitly (`-l log`), as it can not be auto-detected in this case.
#### `git show`
You can combine `bat` with `git show` to view an older version of a given file with proper syntax
highlighting:
```bash
git show v0.6.0:src/main.rs | bat -l rs
```
#### `xclip`
The line numbers and Git modification markers in the output of `bat` can make it hard to copy
the contents of a file. To prevent this, you can call `bat` with the `-p`/`--plain` option or
simply pipe the output into `xclip`:
```bash
bat main.cpp | xclip
```
`bat` will detect that the output is being redirected and print the plain file contents.
#### `man`
`bat` can be used as a pager for `man`. It can be used like this:
```
export MANPAGER="sh -c 'col -b | bat -l man -p'"
man 2 select
```
The [Manpage syntax](assets/syntaxes/Manpage.sublime-syntax) is developed in this repository and still needs some work.
## Installation ## Installation
[![Packaging status](https://repology.org/badge/vertical-allrepos/bat.svg)](https://repology.org/project/bat/versions)
### On Ubuntu ### On Ubuntu
*... and other Debian-based Linux distributions.* *... and other Debian-based Linux distributions.*
Download the latest `.deb` package from the [release page](https://github.com/sharkdp/bat/releases) Download the latest `.deb` package from the [release page](https://github.com/sharkdp/bat/releases)
and install it via: and install it via:
``` bash ``` bash
sudo dpkg -i bat_0.9.0_amd64.deb # adapt version number and architecture sudo dpkg -i bat_0.12.1_amd64.deb # adapt version number and architecture
```
### On Alpine Linux
You can install [the `bat` package](https://pkgs.alpinelinux.org/packages?name=bat)
from the official sources, provided you have the appropriate repository enabled:
```bash
apk add bat
``` ```
### On Arch Linux ### On Arch Linux
@@ -103,6 +174,23 @@ from the official sources:
pacman -S bat pacman -S bat
``` ```
### On Fedora
You can install [the `bat` package](https://koji.fedoraproject.org/koji/packageinfo?packageID=27506) from the official [Fedora Modular](https://docs.fedoraproject.org/en-US/modularity/using-modules/) repository.
```bash
dnf install bat
```
### On Gentoo Linux
You can install [the `bat` package](https://packages.gentoo.org/packages/sys-apps/bat)
from the official sources:
```bash
emerge sys-apps/bat
```
### On Void Linux ### On Void Linux
You can install `bat` via xbps-install: You can install `bat` via xbps-install:
@@ -152,12 +240,16 @@ brew install bat
### On Windows ### On Windows
You can download prebuilt binaries from the [Release page](https://github.com/sharkdp/bat/releases), You can download prebuilt binaries from the [Release page](https://github.com/sharkdp/bat/releases),
or install it with [scoop](https://scoop.sh/): or install it with [scoop](https://scoop.sh/) or [Chocolatey](https://chocolatey.org):
```bash ```bash
scoop install bat scoop install bat
``` ```
```bash
choco install bat
```
[See below](#using-bat-on-windows) for notes. [See below](#using-bat-on-windows) for notes.
### Via Docker ### Via Docker
@@ -200,12 +292,11 @@ This should work with the following distributions:
Check out the [Release page](https://github.com/sharkdp/bat/releases) for Check out the [Release page](https://github.com/sharkdp/bat/releases) for
prebuilt versions of `bat` for many different architectures. Statically-linked prebuilt versions of `bat` for many different architectures. Statically-linked
binaries are available, just look for releases with `musl` in the name on the binaries are also available: look for archives with `musl` in the file name.
releases page.
### From source ### From source
If you want to build `bat` from source, you need Rust 1.29 or If you want to build `bat` from source, you need Rust 1.35 or
higher. You can then use `cargo` to build everything: higher. You can then use `cargo` to build everything:
```bash ```bash
@@ -223,7 +314,8 @@ Use `bat --list-themes` to get a list of all available themes for syntax
highlighting. To select the `TwoDark` theme, call `bat` with the highlighting. To select the `TwoDark` theme, call `bat` with the
`--theme=TwoDark` option or set the `BAT_THEME` environment variable to `--theme=TwoDark` option or set the `BAT_THEME` environment variable to
`TwoDark`. Use `export BAT_THEME="TwoDark"` in your shell's startup file to `TwoDark`. Use `export BAT_THEME="TwoDark"` in your shell's startup file to
make the change permanent. make the change permanent. Alternatively, use `bat`s
[configuration file](https://github.com/sharkdp/bat#configuration-file).
If you want to preview the different themes on a custom file, you can use If you want to preview the different themes on a custom file, you can use
the following command (you need [`fzf`](https://github.com/junegunn/fzf) for this): the following command (you need [`fzf`](https://github.com/junegunn/fzf) for this):
@@ -232,16 +324,17 @@ bat --list-themes | fzf --preview="bat --theme={} --color=always /path/to/file"
``` ```
`bat` looks good on a dark background by default. However, if your terminal uses a `bat` looks good on a dark background by default. However, if your terminal uses a
light background, some themes will work better for you. For example, the `GitHub` light background, some themes like `GitHub` or `OneHalfLight` will work better for you.
theme is made for light backgrounds. You can also make your own theme by following the You can also use a custom theme by following the
['Adding new themes' section below](https://github.com/sharkdp/bat#adding-new-themes). ['Adding new themes' section below](https://github.com/sharkdp/bat#adding-new-themes).
### Output style ### Output style
You can use the `--style` option to control the appearance of `bat`s output. You can use the `--style` option to control the appearance of `bat`s output.
You can use `--style=numbers,changes`, for example, to show only Git changes You can use `--style=numbers,changes`, for example, to show only Git changes
and line numbers but no grid and no file header. Use the `BAT_STYLE` environment and line numbers but no grid and no file header. Set the `BAT_STYLE` environment
variable to make these changes permanent. variable to make these changes permanent or use `bat`s
[configuration file](https://github.com/sharkdp/bat#configuration-file).
### Adding new syntaxes / language definitions ### Adding new syntaxes / language definitions
@@ -253,10 +346,8 @@ and theme. To add new syntax definitions, do the following.
Create a folder with syntax definition files: Create a folder with syntax definition files:
```bash ```bash
BAT_CONFIG_DIR="$(bat cache --config-dir)" mkdir -p "$(bat --config-dir)/syntaxes"
cd "$(bat --config-dir)/syntaxes"
mkdir -p "$BAT_CONFIG_DIR/syntaxes"
cd "$BAT_CONFIG_DIR/syntaxes"
# Put new '.sublime-syntax' language definition files # Put new '.sublime-syntax' language definition files
# in this folder (or its subdirectories), for example: # in this folder (or its subdirectories), for example:
@@ -266,7 +357,7 @@ git clone https://github.com/tellnobody1/sublime-purescript-syntax
Now use the following command to parse these files into a binary cache: Now use the following command to parse these files into a binary cache:
```bash ```bash
bat cache --init bat cache --build
``` ```
Finally, use `bat --list-languages` to check if the new languages are available. Finally, use `bat --list-languages` to check if the new languages are available.
@@ -283,16 +374,14 @@ This works very similar to how we add new syntax definitions.
First, create a folder with the new syntax highlighting themes: First, create a folder with the new syntax highlighting themes:
```bash ```bash
BAT_CONFIG_DIR="$(bat cache --config-dir)" mkdir -p "$(bat --config-dir)/themes"
cd "$(bat --config-dir)/themes"
mkdir -p "$BAT_CONFIG_DIR/themes"
cd "$BAT_CONFIG_DIR/themes"
# Download a theme in '.tmTheme' format, for example: # Download a theme in '.tmTheme' format, for example:
git clone https://github.com/greggb/sublime-snazzy git clone https://github.com/greggb/sublime-snazzy
# Update the binary cache # Update the binary cache
bat cache --init bat cache --build
``` ```
Finally, use `bat --list-themes` to check if the new themes are available. Finally, use `bat --list-themes` to check if the new themes are available.
@@ -311,7 +400,9 @@ If you want to pass command-line arguments to the pager, you can also set them v
export BAT_PAGER="less -RF" export BAT_PAGER="less -RF"
``` ```
**Note**: By default, if the pager is set to `less` (any no command-line options are specified), Instead of using environment variables, you can also use `bat`s [configuration file](https://github.com/sharkdp/bat#configuration-file) to configure the pager (`--pager` option).
**Note**: By default, if the pager is set to `less` (and no command-line options are specified),
`bat` will pass the following command line `bat` will pass the following command line
options to the pager: `-R`/`--RAW-CONTROL-CHARS`, `-F`/`--quit-if-one-screen` and `-X`/`--no-init`. options to the pager: `-R`/`--RAW-CONTROL-CHARS`, `-F`/`--quit-if-one-screen` and `-X`/`--no-init`.
The first (`-R`) is needed to interpret ANSI colors correctly. The second option (`-F`) instructs The first (`-R`) is needed to interpret ANSI colors correctly. The second option (`-F`) instructs
@@ -325,19 +416,21 @@ will hopefully enable both quit-if-one-screen and mouse-wheel scrolling.
If scrolling still doesn't work for you, you can try to pass the `-S` option in addition. If scrolling still doesn't work for you, you can try to pass the `-S` option in addition.
### Configuration file ## Configuration file
`bat` can also be customized with a configuration file. The location of the file is dependent on you operating system. To get the default path for your system, call `bat` can also be customized with a configuration file. The location of the file is dependent
on your operating system. To get the default path for your system, call
``` ```
bat --config-file bat --config-file
``` ```
Alternatively, you can use the `BAT_CONFIG_PATH` environment variable to point `bat` to a non-default location of the configuration file: Alternatively, you can use the `BAT_CONFIG_PATH` environment variable to point `bat` to a
non-default location of the configuration file:
```bash ```bash
export BAT_CONFIG_PATH="/path/to/bat.conf" export BAT_CONFIG_PATH="/path/to/bat.conf"
``` ```
#### Format ### Format
The configuration file is a simple list of command line arguments. Use `bat --help` to see a full list of possible options and values. In addition, you can add comments by prepending a line with the `#` character. The configuration file is a simple list of command line arguments. Use `bat --help` to see a full list of possible options and values. In addition, you can add comments by prepending a line with the `#` character.
@@ -372,16 +465,16 @@ Example configuration file:
Windows only includes a very limited pager in the form of `more`. You can download a Windows binary Windows only includes a very limited pager in the form of `more`. You can download a Windows binary
for `less` [from its homepage](http://www.greenwoodsoftware.com/less/download.html) or [through for `less` [from its homepage](http://www.greenwoodsoftware.com/less/download.html) or [through
Chocolatey](https://chocolatey.org/packages/Less). To use it, place the binary in a directory in Chocolatey](https://chocolatey.org/packages/Less). To use it, place the binary in a directory in
your `PATH` or [define an environment variable](#using-a-different-pager). your `PATH` or [define an environment variable](#using-a-different-pager). The [Chocolatey package](#on-windows) installs `less` automatically.
### Colours ### Colors
Windows 10 natively supports colours in both `conhost.exe` (Command Prompt) and PowerShell since Windows 10 natively supports colors in both `conhost.exe` (Command Prompt) and PowerShell since
[v1511](https://en.wikipedia.org/wiki/Windows_10_version_history#Version_1511_(November_Update)), as [v1511](https://en.wikipedia.org/wiki/Windows_10_version_history#Version_1511_(November_Update)), as
well as in newer versions of bash. On earlier versions of Windows, you can use well as in newer versions of bash. On earlier versions of Windows, you can use
[Cmder](http://cmder.net/), which includes [ConEmu](https://conemu.github.io/). [Cmder](http://cmder.net/), which includes [ConEmu](https://conemu.github.io/).
**Note:** The Git and MSYS versions of `less` do not correctly interpret colours on Windows. If you **Note:** The Git and MSYS versions of `less` do not correctly interpret colors on Windows. If you
dont have any other pagers installed, you can disable paging entirely by passing `--paging=never` dont have any other pagers installed, you can disable paging entirely by passing `--paging=never`
or by setting `BAT_PAGER` to an empty string. or by setting `BAT_PAGER` to an empty string.
+1
View File
@@ -0,0 +1 @@
* linguist-vendored
+10 -2
View File
@@ -13,12 +13,15 @@ In order to add new syntaxes to `bat`, follow these steps:
Sublime Text and convert it to a `.sublime-syntax` file via *Tools* -> *Developer* -> Sublime Text and convert it to a `.sublime-syntax` file via *Tools* -> *Developer* ->
*New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder. *New Syntax from XXX.tmLanguage...*. Save the new file in the `assets/syntaxes` folder.
3. Run the `create.sh` script. It calls `bat cache --init` to parse all available 3. Run the `create.sh` script. It calls `bat cache --build` to parse all available
`.sublime-syntax` files and serialize them to a `syntaxes.bin` file (in this folder). `.sublime-syntax` files and serialize them to a `syntaxes.bin` file (in this folder).
4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the 4. Re-compile `bat`. At compilation time, the `syntaxes.bin` file will be stored inside the
`bat` binary. `bat` binary.
5. If you send a pull request with your changes, please do *not* include the changed `syntaxes.bin`
file. A new binary cache file will be created once before every new release of `bat`.
### Troubleshooting ### Troubleshooting
Make sure that the local cache does not interfere with the internally stored syntaxes and Make sure that the local cache does not interfere with the internally stored syntaxes and
@@ -29,4 +32,9 @@ themes (`bat cache --clear`).
The following files have been manually modified after converting from a `.tmLanguage` file: The following files have been manually modified after converting from a `.tmLanguage` file:
* `Dart.sublime-syntax` => removed `#regex.dart` include. * `Dart.sublime-syntax` => removed `#regex.dart` include.
* `INI.sublime-syntax` => added `.hgrc` and `hgrc` file types. * `INI.sublime-syntax` => added `.hgrc`, `hgrc`, and `desktop` file types.
* `Org mode.sublime-syntax` => removed `task` file type.
### Non-submodule additions
* `Assembly (x86_64)` has been manually added from https://github.com/13xforever/x86-assembly-textmate-bundle due to `git clone` recursion problems
+76
View File
@@ -0,0 +1,76 @@
# Fish Shell Completions
# Place or symlink to $XDG_CONFIG_HOME/fish/completions/bat.fish ($XDG_CONFIG_HOME is usually set to ~/.config)
# Helper function:
function __bat_autocomplete_languages --description "A helper function used by "(status filename)
bat --list-languages | awk -F':' '
{
lang=$1
split($2, exts, ",")
for (i in exts) {
ext=exts[i]
if (ext !~ /[A-Z].*/ && ext !~ /^\..*rc$/) {
print ext"\t"lang
}
}
}
' | sort
end
# Completions:
complete -c bat -l color -xka "auto never always" -d "Specify when to use colored output (default: auto)" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l config-dir -d "Display location of 'bat' configuration directory" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l config-file -d "Display location of 'bat' configuration file" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l decorations -xka "auto never always" -d "Specify when to use the decorations specified with '--style' (default: auto)" -n "not __fish_seen_subcommand_from cache"
complete -c bat -s h -l help -d "Print help message" -n "not __fish_seen_subcommand_from cache"
complete -c bat -s H -l highlight-line -x -d "<N> Highlight the N-th line with a different background color" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l italic-text -xka "always never" -d "Specify when to use ANSI sequences for italic text (default: never)" -n "not __fish_seen_subcommand_from cache"
complete -c bat -s l -l language -d "Set the language for syntax highlighting" -n "not __fish_seen_subcommand_from cache" -xa "(__bat_autocomplete_languages)"
complete -c bat -s r -l line-range -x -d "<N:M> Only print the specified range of lines for each file" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l list-languages -d "Display list of supported languages for syntax highlighting" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l list-themes -d "Display a list of supported themes for syntax highlighting" -n "not __fish_seen_subcommand_from cache"
complete -c bat -s m -l map-syntax -x -d "<from:to> Map a file extension or file name to an existing syntax" -n "not __fish_seen_subcommand_from cache"
complete -c bat -s n -l number -d "Only show line numbers, no other decorations. Alias for '--style=numbers'" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l pager -x -d "<command> Specify which pager program to use (default: less)" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l paging -xka "auto never always" -d "Specify when to use the pager (default: auto)" -n "not __fish_seen_subcommand_from cache"
complete -c bat -s p -l plain -d "Only show plain style, no decorations. Alias for '--style=plain'" -n "not __fish_seen_subcommand_from cache"
complete -c bat -s A -l show-all -d "Show non-printable characters like space/tab/newline" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l style -xka "auto full plain changes header grid numbers" -d "Comma-separated list of style elements or presets to display with file contents" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l tabs -x -d "<T> Set the tab width to T spaces (width of 0 passes tabs through directly)" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l terminal-width -x -d "<width> Explicitly set terminal width; Prefix with '+' or '-' to offset (default width is auto determined)" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l theme -xka "(bat --list-themes | cat)" -d "Set the theme for syntax highlighting" -n "not __fish_seen_subcommand_from cache"
complete -c bat -s u -l unbuffered -d "POSIX-compliant unbuffered output. Option is ignored" -n "not __fish_seen_subcommand_from cache"
complete -c bat -s V -l version -d "Show version information" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l wrap -xka "auto never character" -d "<mode> Specify the text-wrapping mode (default: auto)" -n "not __fish_seen_subcommand_from cache"
# Sub-command 'cache' completions
complete -c bat -a "cache" -d "Modify the syntax/language definition cache" -n "not __fish_seen_subcommand_from cache"
complete -c bat -l build -f -d "Parse syntaxes/language definitions into cache" -n "__fish_seen_subcommand_from cache"
complete -c bat -l clear -f -d "Reset syntaxes/language definitions to default settings" -n "__fish_seen_subcommand_from cache"
+2 -1
View File
@@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
set -euo pipefail
ASSET_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" ASSET_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@@ -11,6 +12,6 @@ JAVADOC_FILE="${ASSET_DIR}/syntaxes/Packages/Java/JavaDoc.sublime-syntax"
JAVADOC_PATCH="${ASSET_DIR}/JavaDoc.sublime-syntax.patch" JAVADOC_PATCH="${ASSET_DIR}/JavaDoc.sublime-syntax.patch"
patch "$JAVADOC_FILE" "$JAVADOC_PATCH" patch "$JAVADOC_FILE" "$JAVADOC_PATCH"
bat cache --init --blank --source="$ASSET_DIR" --target="$ASSET_DIR" bat cache --build --blank --source="$ASSET_DIR" --target="$ASSET_DIR"
patch -R "$JAVADOC_FILE" "$JAVADOC_PATCH" patch -R "$JAVADOC_FILE" "$JAVADOC_PATCH"
BIN
View File
Binary file not shown.
Vendored Submodule
+1
+283
View File
@@ -0,0 +1,283 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: AsciiDoc
comment: |
A very early hack. Mostly ripped from other syntaxes.
Only the very basic stuff is working.
file_extensions:
- adoc
- asciidoc
- asc
scope: text.html.asciidoc
contexts:
main:
- include: heading_inline
- include: heading-block
- include: heading-blockattr
- match: \$\$(?!\$)
push:
- meta_scope: comment.block.passthrough.macro.doubledollar.asciidoc
- match: \$\$(?!\$)
pop: true
- match: \+\+\+(?!\+)
push:
- meta_scope: comment.block.passthrough.macro.tripeplus.asciidoc
- match: \+\+\+(?!\+)
pop: true
- match: (//).*$\n?
scope: comment.line.double-slash.asciidoc
- match: |-
(?x)^
(?= ([/+-.*_=]{4,})\s*$
| ([ \t]{1,})
| [=]{1,6}\s*+
| [ ]{,3}(?<marker>[-*_])([ ]{,2}\k<marker>){2,}[ \t]*+$
)
push:
- meta_scope: meta.block-level.asciidoc
- match: |-
(?x)^
(?! \1
| ([ \t]{1,})
| [=]{1,6}\s*+
| [ ]{,3}(?<marker>[-*_])([ ]{,2}\k<marker>){2,}[ \t]*+$
)
pop: true
- include: block_quote
- include: block_raw
- include: heading_inline
- include: heading-block
- include: separator
- match: '^[ ]{0,3}([*+-])(?=\s)'
captures:
1: punctuation.definition.list_item.asciidoc
push:
- meta_scope: markup.list.unnumbered.asciidoc
- match: ^(?=\S)
captures:
1: punctuation.definition.list_item.asciidoc
pop: true
- include: list-paragraph
- match: '^[ ]{0,3}[0-9]+(\.)(?=\s)'
captures:
1: punctuation.definition.list_item.asciidoc
push:
- meta_scope: markup.list.numbered.asciidoc
- match: ^(?=\S)
captures:
1: punctuation.definition.list_item.asciidoc
pop: true
- include: list-paragraph
- match: '^([/+-.*_=]){4,}\s*$'
push:
- meta_scope: comment.block.asciidoc
- match: '^\1{4,}\s*$'
pop: true
- match: '^([/+.]){4,}\s*$'
comment: asciidoc formatting is disabled inside certain blocks.
push:
- meta_scope: meta.disable-asciidoc
- match: '^[/+.]{4,}\s*$'
pop: true
- match: '^(?=\S)(?![=-]{3,}(?=$))(?!\.\S+)'
push:
- meta_scope: meta.paragraph.asciidoc
- match: '^(?:\s*$|(?=[ ]{,3}>.))|(?=[ \t]*\n)(?<=^===|^====|=====|^---|^----|-----)[ \t]*\n'
pop: true
- include: inline
- include: scope:text.html.basic
- match: '^(={3,})(?=[ \t]*$)'
scope: markup.heading.0.asciidoc
captures:
1: punctuation.definition.heading.asciidoc
- match: '^(-{3,})(?=[ \t]*$)'
scope: markup.heading.1.asciidoc
captures:
1: punctuation.definition.heading.asciidoc
- match: '^(~{3,})(?=[ \t]*$)'
scope: markup.heading.2.asciidoc
captures:
1: punctuation.definition.heading.asciidoc
- match: '^(\^{3,})(?=[ \t]*$)'
scope: markup.heading.3.asciidoc
captures:
1: punctuation.definition.heading.asciidoc
- match: '^(\+{3,})(?=[ \t]*$)'
scope: markup.heading.4.asciidoc
captures:
1: punctuation.definition.heading.asciidoc
attribute-entry:
- match: '^:[-_. A-Za-z0-9]+:\s*(.*)\s*$'
scope: variable.other
attribute-reference:
- match: "{[-_. A-Za-z0-9]+}"
scope: variable.other
attribute-reference-predefined:
- match: "{(?i:amp|asciidoc-dir|asciidoc-file|asciidoc-version|author|authored|authorinitials|backend-docbook|backend-xhtml11|backend-html4|docbook-article|xhtml11-article|html4-article|docbook-book|xhtml11-book|html4-book|docbook-manpage|xhtml11-manpage|html4-manpage|backend|backslash|basebackend|brvbar|date|docdate|doctime|docname|docfile|docdir|doctitle|doctype-article|doctype-book|doctype-manpage|doctype|email|empty|encoding|filetype|firstname|gt|id|indir|infile|lastname|level|listindex|localdate|localtime|lt|manname|manpurpose|mantitle|manvolnum|middlename|nbsp|outdir|outfile|reftext|revision|sectnum|showcomments|title|two_colons|two_semicolons|user-dir|verbose)}"
scope: support.variable
block_quote:
- match: '^([/+-.*_=]){4,}\s*$'
push:
- meta_scope: comment.block.asciidoc
- match: '^\1{4,}\s*$'
pop: true
block_raw:
- match: '\G([ ]{4}|\t).*$\n?'
scope: markup.raw.block.asciidoc
bracket:
- match: '<(?![a-z/?\$!])'
comment: |
asciidoc will convert this for us. We match it so that the
HTML grammar will not mark it up as invalid.
scope: meta.other.valid-bracket.asciidoc
character-replacements:
- match: \(C\)|\(R\)|\(TM\)|--(?!-)|\.\.\.(?!\.)|->|<-|=>|<=
scope: constant.character.asciidoc
escape:
- match: '\\[-`*_#+.!(){}\[\]\\>:]'
scope: constant.character.escape.asciidoc
heading:
- match: '(?m)^(\S+)$([=-~^+])+\s*$'
scope: markup.heading.asciidoc
captures:
1: punctuation.definition.heading.asciidoc
heading-block:
- match: ^\.(\w.*)$
scope: markup.heading.asciidoc
captures:
1: punctuation.definition.heading.asciidoc
heading-blockattr:
- match: '^\[\[?(\w.*)\]$'
scope: markup.heading.asciidoc
captures:
1: punctuation.definition.heading.asciidoc
heading_inline:
- match: '\G(={1,6})(?!=)\s*(?=\S)'
captures:
1: punctuation.definition.heading.asciidoc
push:
- meta_scope: markup.heading.asciidoc
- meta_content_scope: entity.name.section.asciidoc
- match: \s*(=*)$\n?
captures:
1: punctuation.definition.heading.asciidoc
pop: true
- include: inline
inline:
- include: line-break
- include: line-page-break
- include: line-ruler
- include: escape
- include: passthrough-macro-trippleplus-inline
- include: passthrough-macro-doubledollar-inline
- include: character-replacements
- include: bracket
- include: raw
- include: text-quote-single
- include: text-quote-double
- include: text-quote-other
- include: text-bold-unconstrained
- include: text-italic-unconstrained
- include: text-monospace-unconstrained
- include: text-unquoted-unconstrained
- include: text-bold
- include: text-italic
- include: text-monospace
- include: text-unquoted
- include: attribute-entry
- include: attribute-reference-predefined
- include: attribute-reference
line-break:
- match: (?<=\S)\s+\+$
scope: constant.character.escape.asciidoc
line-page-break:
- match: "^<{3,}$"
scope: constant.character.escape.asciidoc
line-ruler:
- match: "^'{3,}$"
scope: constant.character.escape.asciidoc
list-paragraph:
- match: \G\s+(?=\S)
push:
- meta_scope: meta.paragraph.list.asciidoc
- match: ^\s*$
pop: true
- include: inline
passthrough-macro-doubledollar-inline:
- match: '(?:\[.*\])?\$\$(?!\$).+\$\$(?!\$)'
scope: comment.block.passthrough.asciidoc
passthrough-macro-trippleplus-inline:
- match: '(?:\[.*\])?\+\+\+(?!\+).+\+\+\+(?!\+)'
scope: comment.block.passthrough.asciidoc
raw:
- match: '(`+)(?:[^`]|(?!(?<!`)\1(?!`))`)*+(\1)'
scope: markup.raw.inline.asciidoc
captures:
1: punctuation.definition.raw.asciidoc
2: punctuation.definition.raw.asciidoc
separator:
- match: '\G[ ]{,3}([-*_])([ ]{,2}\1){2,}[ \t]*$\n?'
scope: meta.separator.asciidoc
text-bold:
- match: (?<!\w)(\*)(?=\S)
captures:
1: punctuation.definition.bold.asciidoc
push:
- meta_scope: markup.bold.asciidoc
- match: (?<=\S)(\1)(?!\w)
captures:
1: punctuation.definition.bold.asciidoc
pop: true
text-bold-unconstrained:
- match: (\*\*)(?=\S)
captures:
1: punctuation.definition.bold.asciidoc
push:
- meta_scope: markup.bold.asciidoc
- match: (?<=\S)(\1)
captures:
1: punctuation.definition.bold.asciidoc
pop: true
text-italic:
- match: (?<!\w)('|_)(?=\S)
captures:
1: punctuation.definition.italic.asciidoc
push:
- meta_scope: markup.italic.asciidoc
- match: (?<=\S)(\1)((?!\1)|(?=\1\1))(?!\w)
captures:
1: punctuation.definition.italic.asciidoc
pop: true
text-italic-unconstrained:
- match: (__)(?=\S)
captures:
1: punctuation.definition.italic.asciidoc
push:
- meta_scope: markup.italic.asciidoc
- match: (?<=\S)(\1)
captures:
1: punctuation.definition.italic.asciidoc
pop: true
text-monospace:
- match: '(?<!\w)([\+`])[^\+]*(\1)(?!\w)'
scope: string.interpolated.asciidoc
text-monospace-unconstrained:
- match: (\+\+).*(\1)
scope: string.interpolated.asciidoc
text-quote-double:
- match: '(?<!\w)(?:\[.*\])?``(?!`).*''''(?!'')(?!\w)'
scope: string.quoted.double.asciidoc
text-quote-other:
- match: '(?<!\w)(?:\[.*\])?([~^]).*(\1)(?!\w)'
scope: string.quoted.single.asciidoc
text-quote-single:
- match: '(?<!\w)(?:\[.*\])?`(?!`).*''(?!'')(?!\w)'
comment: "TODO: Sub- and Superscript are really unconstrained"
scope: string.quoted.single.asciidoc
text-unquoted:
- match: (?<!\w)(#).*(\1)(?!\w)
scope: string.unquoted.asciidoc
text-unquoted-unconstrained:
- match: (##).*(\1)
scope: string.unquoted.asciidoc
+172
View File
@@ -0,0 +1,172 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: ARM Assembly
file_extensions:
- s
- S
scope: source.asm.arm
contexts:
main:
- match: "@.*$"
scope: comment.line
- match: //.*$
scope: comment.line
- match: ;.*$
scope: comment.line
- match: ^\s*\#\s*if\s+0\b
push:
- meta_scope: comment.preprocessor
- match: ^\s*\#\s*endif\b
pop: true
- match: /\*
push:
- meta_scope: comment.block
- match: \*/
pop: true
- match: |-
(?x)
^\s*\#\s*(define)\s+ # define
((?<id>[a-zA-Z_][a-zA-Z0-9_]*)) # macro name
(?: # and optionally:
(\() # an open parenthesis
(
\s* \g<id> \s* # first argument
((,) \s* \g<id> \s*)* # additional arguments
(?:\.\.\.)? # varargs ellipsis?
)
(\)) # a close parenthesis
)?
captures:
1: keyword.control.import.define.c
2: entity.name.function.preprocessor.c
4: punctuation.definition.parameters.c
5: variable.parameter.preprocessor.c
7: punctuation.separator.parameters.c
8: punctuation.definition.parameters.c
push:
- meta_scope: meta.preprocessor.macro.c
- match: (?=(?://|/\*))|$
pop: true
- match: (?>\\\s*\n)
scope: punctuation.separator.continuation.c
- include: $top_level_main
- match: ^\s*#\s*(error|warning)\b
captures:
1: keyword.control.import.error.c
push:
- meta_scope: meta.preprocessor.diagnostic.c
- match: $
captures:
1: keyword.control.import.error.c
pop: true
- match: (?>\\\s*\n)
scope: punctuation.separator.continuation.c
- match: ^\s*#\s*(include|import)\b\s+
captures:
1: keyword.control.import.include.c
push:
- meta_scope: meta.preprocessor.c.include
- match: (?=(?://|/\*))|$
captures:
1: keyword.control.import.include.c
pop: true
- match: (?>\\\s*\n)
scope: punctuation.separator.continuation.c
- match: '"'
captures:
0: punctuation.definition.string.begin.c
push:
- meta_scope: string.quoted.double.include.c
- match: '"'
captures:
0: punctuation.definition.string.end.c
pop: true
- match: <
captures:
0: punctuation.definition.string.begin.c
push:
- meta_scope: string.quoted.other.lt-gt.include.c
- match: ">"
captures:
0: punctuation.definition.string.end.c
pop: true
- match: '((?i)([xw][0-9]|[xw]1[0-9]||[xw]2[0-9]|[wx]30|wzr|xzr|wsp|fpsr|fpcr|[rcp]1[0-5]|[rcp][0-9]|a[1-4]|v[1-8]|sl|sb|fp|ip|sp|lr|(c|s)psr(_c)?|pc|[sd]3[0-1]|[sd][12][0-9]|[sd][0-9]|fpsid|fpscr|fpexc|q3[0-1]|q2[0-9]|q1[0-9]|q[0-9]|APSR_nzcv|sy)!?(?-i))?\b'
scope: storage.other.register
- match: \.(?i)(globl|global|macro|endm|purgem|if|elseif|else|endif|section|text|arm|align|balign|irp|rept|endr|req|unreq|error|short|func|endfunc|hidden|type|fpu|arch|code|altmacro|object_arch|word|int|string)(?-i)\b
scope: keyword.control.directive
- match: armv(2a?|3m?|4t?|5t?e?6(j|t2|zk?|-m)?|7v?e?(-(a|r|m))?|8-a(\+crc)?)
scope: keyword.control.arch.arm
- match: ^\s*#\s*(define|defined|elif|else|if|ifdef|ifndef|line|pragma|undef|endif)\b
captures:
1: keyword.control.import.c
push:
- meta_scope: meta.preprocessor.c
- match: (?=(?://|/\*))|$
captures:
1: keyword.control.import.c
pop: true
- match: (?>\\\s*\n)
scope: punctuation.separator.continuation.c
- match: |-
(?x)\b((?i)
(
(bf(c|i)|(u|s)bfx|(u|s)xta?(h|b)?) |
(v(add|cvt|sub|mov|trn|cmp|div|qdmulh|mrs|mul|ld1|qadd|qshrun|st[1234]|addw|mull|mlal|rshrn|swp|qmovun)|qmovun)(\.([isup]?8|[isupf]?16|[isuf]?32|[isu]?64))* |
(and|m(rs|sr)|eor|sub|rsb|add|adc|sbc|rsc|tst|teq|cmp|cmn|orr|mov|bic|mvn |
(neg) |
(lsr|lsl|ror|asr) # shift ops either pseudo ops or actual shifts
)s? |
(mul|mla|mull|smlabb) |
(mov(w|t)) |
rev(8|16)? |
(pld|adr|adrl|vswp)
)
(ne|eq|cs|hs|cc|lo|mi|pl|vs|vc|hi|ls|lt|le|gt|ge|al)?(?-i))?\b
scope: support.function.mnemonic.arithmetic
- match: |-
(?x)\b((?i)(
swi|svc|wfi|
dmb | clrex | dsb | isb |
v(ldr|str|push|pop) |
(push|pop) |
(st|ld)(
p |
r(ex|s?(h|b)|d)? |
m(
(f|e)(d|a) |
(d|i)(b|a)
)?
) |
b(l|x|lx|lr|r)? |
(i|e)?ret|
b\.(eq|ne|hs|cs|lo|cc|mi|pl|vs|vc|hi|ls|ge|lt|gt|le|al|nv)+ |
(c|t)?bn?z|
)+(ne|eq|cs|hs|cc|lo|mi|pl|vs|vc|hi|ls|lt|le|gt|ge|al)?(?-i))\b
scope: support.function.mnemonic.memory
- match: '\b((?i)(def(b|w|s)|equ|(include|get)(\s+([a-zA-Z_]+[0-9a-zA-Z_]*|[0-9]+[a-zA-Z_]+[0-9a-zA-Z_]*?)\.s)?)?(?-i))\b'
scope: meta.preprocessor.c.include
- match: \b((?i)(align)(?-i))?\b
scope: storage.type.c.memaccess
- match: \s+\".+\"
scope: string
- match: \b((?i)nop(ne|eq|cs|hs|cc|lo|mi|pl|vs|vc|hi|ls|lt|le|gt|ge|al)?(?-i))?\b
scope: comment.nop
- match: '\s\['
push:
- meta_scope: storage.type.c.memaccess
- match: '\]'
pop: true
- match: (?>\\\s*\n)
scope: punctuation.separator.continuation.c
- include: $top_level_main
- match: (\b|\s+)\=\b
scope: keyword.control.evaluation
- match: '(\b|\s+)(\#)?-?(0x|&)[0-9a-fA-F_]+\b'
scope: constant.numeric.hex
- match: '(\b|\s+)\#-?[0-9a-zA-Z_]+\b'
scope: constant.numeric.literal
- match: '(\b|\s+)[0-9]+\b'
scope: constant.numeric.dec
- match: '\b([a-zA-Z_]+[0-9a-zA-Z_]*|[0-9]+[a-zA-Z_]+[0-9a-zA-Z_]*)\b'
scope: meta.function.source.arm.label
File diff suppressed because it is too large Load Diff
Vendored Submodule
+1
Submodule assets/syntaxes/DotENV added at f6cad1140c
+88
View File
@@ -0,0 +1,88 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: DotENV
file_extensions:
- .env
- .envrc
- .env.dist
- .env.local
- .env.sample
- .env.example
- .env.test
- .env.test.local
- .env.dev
- .env.development
- .env.development.local
- .env.prod
- .env.production
- .env.production.local
- .env.dusk.local
scope: source.env
contexts:
main:
- match: (#).*$\n?
comment: "Comments - starts with #"
scope: comment.line.number-sign.env
captures:
1: punctuation.definition.comment.env
- match: (\")
comment: Strings (double)
captures:
1: punctuation.definition.string.begin.env
push:
- meta_scope: string.quoted.double.env
- match: (\")
captures:
1: punctuation.definition.string.end
pop: true
- include: interpolation
- include: variable
- include: escape-characters
- match: (\')
comment: Strings (single)
captures:
1: punctuation.definition.string.begin.env
push:
- meta_scope: string.quoted.single.env
- match: (\')
captures:
1: punctuation.definition.string.end
pop: true
- match: '(?<=[\w])\s?='
comment: Assignment Operator
scope: keyword.operator.assignment.env
- match: '([\w]+)(?=\s?\=)'
comment: Variable
scope: variable.other.env
- match: (?i)\s?(export)
comment: Keywords
scope: keyword.other.env
- match: (?i)(?<=\=)\s?(true|false|null)
comment: Constants
scope: constant.language.env
- match: '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)\b'
comment: Numeric
scope: constant.numeric.env
escape-characters:
- match: '\\[nrt\\\$\"\'']'
scope: constant.character.escape.env
interpolation:
- match: '(\$\{|\{)'
comment: 'Template Syntax: "foo ${bar} {$baz}"'
captures:
1: string.interpolated.env keyword.other.template.begin.env
push:
- match: '(\})'
captures:
1: string.interpolated.env keyword.other.template.end.env
pop: true
- match: '(?x)(\$+)?([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*?\b)'
captures:
1: punctuation.definition.variable.env variable.other.env
2: variable.other.env
variable:
- match: '(?x)(\$+)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*?\b)'
captures:
1: punctuation.definition.variable.env variable.other.env
2: variable.other.env
+567 -129
View File
@@ -9,63 +9,230 @@ file_extensions:
scope: source.fsharp scope: source.fsharp
contexts: contexts:
main: main:
- include: compiler_directives
- include: comments - include: comments
- include: constants - include: constants
- include: structure
- include: attributes
- include: strings - include: strings
- include: chars
- include: double_tick
- include: definition - include: definition
- include: method_calls - include: abstract_definition
- include: attributes
- include: modules - include: modules
- include: anonymous_functions - include: anonymous_functions
- include: du_declaration
- include: record_declaration
- include: records
- include: strp_inlined
- include: keywords - include: keywords
- include: cexprs
- include: text
abstract_definition:
- match: '\b(abstract)\s+(member)?(\s+\[\<.*\>\])?\s*([_[:alpha:]0-9,\._`\s]+)(:)'
captures:
1: keyword.fsharp
2: keyword.fsharp
3: support.function.attribute.fsharp
5: keyword.fsharp
push:
- meta_scope: abstract.definition.fsharp
- match: \s*(with)\b|=|$
captures:
1: keyword.fsharp
pop: true
- include: comments
- include: common_declaration
- match: '(\?{0,1})([[:alpha:]0-9''`^._ ]+)\s*(:)(\s*([[:alpha:]0-9''`^._ ]+)){0,1}'
captures:
1: keyword.symbol.fsharp
2: variable.parameter.fsharp
3: keyword.symbol.fsharp
4: entity.name.type.fsharp
- match: '(?!with|get|set\b)\b([\w0-9''`^._]+)'
captures:
1: entity.name.type.fsharp
- include: keywords
anonymous_functions: anonymous_functions:
- match: \b(fun)\b - match: \b(fun)\b
captures: captures:
1: keyword.other.function-definition.fsharp 1: keyword.fsharp
push: push:
- meta_scope: meta.function.anonymous - meta_scope: function.anonymous
- match: (->) - match: (->)
captures: captures:
1: keyword.other.fsharp 1: keyword.fsharp
pop: true pop: true
- include: comments
- match: (\()
captures:
1: keyword.symbol.fsharp
push:
- match: \s*(?=(->))
captures:
1: keyword.symbol.fsharp
pop: true
- include: member_declaration
- include: variables - include: variables
attributes: attributes:
- match: '\[\<' - match: '\[\<'
push: push:
- meta_scope: support.function.attribute.fsharp - meta_scope: support.function.attribute.fsharp
- match: '\>\]' - match: '\>\]|\]'
pop: true pop: true
- include: main - include: main
characters: cexprs:
- match: (') - match: '\b(async|seq|promise|task|maybe|asyncMaybe|controller|scope|application|pipeline)\s*\{'
scope: cexpr.fsharp
captures: captures:
1: punctuation.definition.string.begin.fsharp 0: keyword.fsharp
push: chars:
- meta_scope: string.quoted.single.fsharp - match: ('\\?.')
- match: (') scope: char.fsharp
captures: captures:
1: punctuation.definition.string.end.fsharp 1: string.quoted.single.fsharp
pop: true
- match: '\\$[ \t]*'
scope: punctuation.separator.string.ignore-eol.fsharp
- match: '\\([\\""ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8})'
scope: constant.character.string.escape.fsharp
- match: '\\(?![\\''ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8}).'
scope: invalid.illeagal.character.string.fsharp
comments: comments:
- match: \(\*\*?(\*)\) - match: (\(\*(?!\)))
scope: comment.block.fsharp
captures: captures:
1: comment.block.empty.fsharp 1: comment.block.fsharp
- match: '\(\*[^\)]'
push: push:
- meta_scope: comment.block.fsharp - meta_scope: comment.block.fsharp
- match: \*\) - match: (\*\))
captures:
1: comment.block.fsharp
pop: true pop: true
- include: comments
- match: //.*$ - match: //.*$
scope: comment.line.double-slash.fsharp scope: comment.line.double-slash.fsharp
common_binding_definition:
- include: comments
- include: attributes
- match: (:)\s*(\()\s*(static member|member)
captures:
1: keyword.symbol.fsharp
2: keyword.symbol.fsharp
3: keyword.fsharp
push:
- match: (\))\s*((?=,)|(?=\=))
captures:
1: keyword.symbol.fsharp
pop: true
- match: '(\^[[:alpha:]0-9''._]+)'
captures:
1: entity.name.type.fsharp
- include: variables
- include: keywords
- match: (:)\s*(\()
captures:
1: keyword.symbol.fsharp
2: keyword.symbol.fsharp
push:
- match: '(\)\s*(([?[:alpha:]0-9''`^._ ]*)))'
captures:
1: keyword.symbol.fsharp
2: entity.name.type.fsharp
pop: true
- include: tuple_signature
- match: '(:)\s*(\^[[:alpha:]0-9''._]+)\s*(when)'
captures:
1: keyword.symbol.fsharp
2: entity.name.type.fsharp
3: keyword.fsharp
push:
- match: (?=:)
captures:
1: keyword.symbol.fsharp
pop: true
- match: \b(and|when|or)\b
scope: keyword.fsharp
- match: "([[:alpha:]0-9'^._]+)"
comment: Because we first capture the keywords, we can capture what looks like a word and assume it's an entity definition
captures:
1: entity.name.type.fsharp
- match: (\(|\))
scope: keyword.symbol.fsharp
- match: '(:)\s*([?[:alpha:]0-9''`^._ ]+)'
captures:
1: keyword.symbol.fsharp
2: entity.name.type.fsharp
- match: '(->)\s*(\()?\s*([?[:alpha:]0-9''`^._ ]+)*'
captures:
1: keyword.symbol.fsharp
2: keyword.symbol.fsharp
3: entity.name.type.fsharp
- match: (\*)\s*(\()
captures:
1: keyword.symbol.fsharp
2: keyword.symbol.fsharp
push:
- match: '(\)\s*(([?[:alpha:]0-9''`^._ ]+))+)'
captures:
1: keyword.symbol.fsharp
2: entity.name.type.fsharp
pop: true
- include: tuple_signature
- match: '(\*)(\s*([?[:alpha:]0-9''`^._ ]+))*'
captures:
1: keyword.symbol.fsharp
2: entity.name.type.fsharp
- match: '(<(?![[:space:]]*\)))'
captures:
1: keyword.symbol.fsharp
push:
- match: ((?<!:)>)
captures:
1: keyword.symbol.fsharp
pop: true
- include: generic_declaration
- match: "({)"
captures:
1: keyword.symbol.fsharp
push:
- match: "(})"
captures:
1: keyword.symbol.fsharp
pop: true
- include: record_signature
- include: definition
- include: variables
- include: keywords
common_declaration:
- match: '\s*(->)\s*([[:alpha:]0-9''`^._ ]+)(<)'
captures:
1: keyword.symbol.fsharp
2: entity.name.type.fsharp
3: keyword.symbol.fsharp
push:
- match: (>)
captures:
1: keyword.symbol.fsharp
pop: true
- match: "([[:alpha:]0-9'`^._ ]+)"
captures:
1: entity.name.type.fsharp
- include: keywords
- match: '\s*(->)\s*(?!with|get|set\b)\b([\w0-9''`^._]+)'
captures:
1: keyword.symbol.fsharp
2: entity.name.type.fsharp
- match: '(\?{0,1})([[:alpha:]0-9''`^._ ]+)\s*(:)(\s*([?[:alpha:]0-9''`^._ ]+)(<))'
captures:
1: keyword.symbol.fsharp
2: variable.parameter.fsharp
3: keyword.symbol.fsharp
4: keyword.symbol.fsharp
5: entity.name.type.fsharp
push:
- match: (>)
captures:
1: keyword.symbol.fsharp
pop: true
- match: "([[:alpha:]0-9'`^._ ]+)"
captures:
1: entity.name.type.fsharp
- include: keywords
compiler_directives:
- match: \s?(#if|#elif|#else|#elseif|#endif|#light|#nowarn)
scope: compiler_directive.fsharp
captures:
constants: constants:
- match: \(\) - match: \(\)
scope: constant.language.unit.fsharp scope: constant.language.unit.fsharp
@@ -73,123 +240,349 @@ contexts:
scope: constant.numeric.floating-point.fsharp scope: constant.numeric.floating-point.fsharp
- match: '\b(-?((0(x|X)[0-9a-fA-F][0-9a-fA-F_]*)|(0(o|O)[0-7][0-7_]*)|(0(b|B)[01][01_]*)|([0-9][0-9_]*)))' - match: '\b(-?((0(x|X)[0-9a-fA-F][0-9a-fA-F_]*)|(0(o|O)[0-7][0-7_]*)|(0(b|B)[01][01_]*)|([0-9][0-9_]*)))'
scope: constant.numeric.integer.nativeint.fsharp scope: constant.numeric.integer.nativeint.fsharp
- match: \b(true|false|null|unit)\b
scope: constant.others.fsharp
definition: definition:
- match: '\b(val|val|let|and|member|override|use)\s?(rec|inline|mutable)?(\s+\(?([a-zA-Z.\|_][a-zA-Z0-9.|_]*)\)?\w*)\b' - match: '\b(let mutable|static let mutable|let inline|let|member val|static member inline|static member|default|member|override|let!)(\s+rec|mutable)?(\s+\[\<.*\>\])?\s*(private|internal|public)?\s+(\[[^-=]*\]|[_[:alpha:]]([_[:alpha:]0-9,\._]+)*|``[_[:alpha:]]([_[:alpha:]0-9,\._`\s]+|(?<=,)\s)*)?'
captures: captures:
1: keyword.other.binding.fsharp 1: keyword.fsharp
2: keyword.other.function-recursive.fsharp 2: keyword.fsharp
3: variable.other.binding.fsharp 3: support.function.attribute.fsharp
4: keyword.fsharp
5: variable.fsharp
push: push:
- meta_scope: meta.binding.fsharp - meta_scope: binding.fsharp
- match: "=|$" - match: \s*(with\b|=|\n+=|(?<=\=))
captures: captures:
1: punctuation.separator.function.type-constraint.fsharp 1: keyword.fsharp
pop: true pop: true
- include: common_binding_definition
- match: '\b(static val mutable|val mutable|val)(\s+rec|mutable)?(\s+\[\<.*\>\])?\s*(private|internal|public)?\s+(\[[^-=]*\]|[_[:alpha:]]([_[:alpha:]0-9,\._]+)*|``[_[:alpha:]]([_[:alpha:]0-9,\._`\s]+|(?<=,)\s)*)?'
captures:
1: keyword.fsharp
2: keyword.fsharp
3: support.function.attribute.fsharp
4: keyword.fsharp
5: variable.fsharp
push:
- meta_scope: binding.fsharp
- match: \n$
pop: true
- include: common_binding_definition
double_tick:
- match: (``)(.*)(``)
scope: variable.other.binding.fsharp
captures:
1: string.quoted.single.fsharp
2: variable.other.binding.fsharp
3: string.quoted.single.fsharp
du_declaration:
- match: \b(of)\b
captures:
1: keyword.fsharp
push:
- meta_scope: du_declaration.fsharp
- match: $|(\|)
captures:
1: keyword.symbol.fsharp
pop: true
- include: comments
- match: '([[:alpha:]0-9''`<>^._]+|``[[:alpha:]0-9'' <>^._]+``)\s*(:)\s*([[:alpha:]0-9''`<>^._]+|``[[:alpha:]0-9'' <>^._]+``)'
captures:
1: variable.parameter.fsharp
2: keyword.symbol.fsharp
3: entity.name.type.fsharp
- match: "([[:alpha:]0-9'`^._]+)|``([[:alpha:]0-9'^._ ]+)``"
captures:
1: entity.name.type.fsharp
- include: keywords
generic_declaration:
- match: (:)\s*(\()\s*(static member|member)
captures:
1: keyword.symbol.fsharp
2: keyword.symbol.fsharp
3: keyword.fsharp
push:
- match: (\))
captures:
1: keyword.symbol.fsharp
pop: true
- match: (\()
captures:
1: keyword.symbol.fsharp
push:
- match: (\))
captures:
1: keyword.symbol.fsharp
pop: true
- include: member_declaration
- match: '((''|\^)[[:alpha:]0-9''._]+)'
captures:
1: entity.name.type.fsharp
- include: variables - include: variables
- match: \b(let)\s+((\(\))|(_))\s+= - include: keywords
scope: meta.expression.fsharp - match: \b(private|to|public|internal|function|yield!|yield|class|exception|match|delegate|of|new|in|as|if|then|else|elif|for|begin|end|inherit|do|let\!|return\!|return|interface|with|abstract|property|union|enum|member|try|finally|and|when|use|use\!|struct|while|mutable)(?!')\b
scope: keyword.fsharp
- match: ":"
scope: keyword.fsharp
- include: constants
- match: '((''|\^)[[:alpha:]0-9''._]+)'
captures: captures:
1: keyword.other.binding.fsharp 1: entity.name.type.fsharp
2: keyword.other.function-recursive.fsharp - match: (<)
4: constant.language.unit.fsharp captures:
5: constant.language.ignored.fsharp 1: keyword.symbol.fsharp
keywords:
- match: ^\s*#\s*(light|if|else|endif|r|I|load|time|help|quit)\b
push: push:
- meta_scope: meta.preprocessor.fsharp - match: (>)
- match: (\s|$)
pop: true
- match: \b(new|in|as|if|then|else|elif|for|begin|end|match|with|type|inherit|true|false|null|do)\b
scope: keyword.other.fsharp
- match: '(\|>|\|?>|\->|\<\-|:>|:|\[|\]|\;|\||_)'
scope: entity.name
method_calls:
- match: '(?<!\w)([a-z]\w*)(\.)'
push:
- meta_scope: meta.method-call.fsharp
- match: '[A-Z]\w*(\.)'
scope: meta.method.fsharp
captures: captures:
1: punctuation.separator.method-call.fsharp 1: keyword.symbol.fsharp
- match: (?=.)
pop: true pop: true
modules: - match: '((''|\^)[[:alpha:]0-9''._]+)'
- match: '\b(namespace|module)\s+([a-zA-Z][a-zA-Z0-9''_.]*)' captures:
1: entity.name.type.fsharp
- include: tuple_signature
- include: generic_declaration
- match: '(?!when|and|or\b)\b([\w0-9''`^._]+)'
captures: captures:
1: keyword.other.fsharp 1: entity.name.type.fsharp
- match: (\|)
captures:
1: keyword.symbol.fsharp
- include: keywords
keywords:
- match: \b(private|to|public|internal|function|yield!|yield|class|exception|match|delegate|of|new|in|as|if|then|else|elif|for|begin|end|inherit|do|let\!|return\!|return|interface|with|abstract|property|union|enum|member|try|finally|and|when|or|use|use\!|struct|while|mutable)(?!')\b
scope: keyword.fsharp
- match: '(&&&|\|\|\||\^\^\^|~~~|<<<|>>>|\|>|\->|\<\-|:>|:\?>|:|\[|\]|\;|<>|=|@|\|\||&&|{|}|\||_|\.\.|\,|\+|\-|\*|\/|\^|\!|\>|\>\=|\>\>|\<|\<\=|\(|\)|\<\<)'
scope: keyword.symbol.fsharp
member_declaration:
- include: comments
- include: common_declaration
- match: (:)\s*(\()\s*(static member|member)
captures:
1: keyword.symbol.fsharp
2: keyword.symbol.fsharp
3: keyword.fsharp
push:
- match: (\))\s*((?=,)|(?=\=))
captures:
1: keyword.symbol.fsharp
pop: true
- match: (\()
captures:
1: keyword.symbol.fsharp
push:
- match: (\))
captures:
1: keyword.symbol.fsharp
pop: true
- include: member_declaration
- match: '(\^[[:alpha:]0-9''._]+)'
captures:
1: entity.name.type.fsharp
- include: variables
- include: keywords
- match: '(\^[[:alpha:]0-9''._]+)'
captures:
1: entity.name.type.fsharp
- match: \b(and|when|or)\b
scope: keyword.fsharp
- match: (\(|\))
scope: keyword.symbol.fsharp
- match: '(\?{0,1})([[:alpha:]0-9''`^._]+|``[[:alpha:]0-9''`^:,._ ]+``)\s*(:{0,1})(\s*([?[:alpha:]0-9''`<>._ ]+)){0,1}'
captures:
1: keyword.symbol.fsharp
2: variable.parameter.fsharp
3: keyword.symbol.fsharp
4: entity.name.type.fsharp
- include: keywords
modules:
- match: '\b(namespace|module)\s*(public|internal|private)?\s+([[:alpha:]][[:alpha:]0-9''_. ]*)'
captures:
1: keyword.fsharp
2: keyword.fsharp
3: entity.name.section.fsharp
push:
- meta_scope: entity.name.section.fsharp
- match: (\s?=|\s|$)
captures:
1: keyword.symbol.fsharp
pop: true
- match: '(\.)([A-Z][[:alpha:]0-9''_]*)'
scope: entity.name.section.fsharp
captures:
1: punctuation.separator.namespace-reference.fsharp
2: entity.name.section.fsharp
- match: '\b(open)\s+([[:alpha:]][[:alpha:]0-9''_]*)(?=(\.[A-Z][[:alpha:]0-9_]*)*)'
captures:
1: keyword.fsharp
2: entity.name.section.fsharp 2: entity.name.section.fsharp
push: push:
- meta_scope: meta.module.namespace.fsharp - meta_scope: namespace.open.fsharp
- match: (\s|$) - match: (\s|$)
pop: true pop: true
- match: '(\.)([A-Z][a-zA-Z0-9''_]*)' - match: '(\.)([[:alpha:]][[:alpha:]0-9''_]*)'
scope: support.other.module.fsharp scope: entity.name.section.fsharp
captures: captures:
1: punctuation.separator.module-reference.fsharp 1: punctuation.separator.namespace-reference.fsharp
2: support.other.module.fsharp 2: entity.name.section.fsharp
- match: '\b(open)\s+([A-Z][a-zA-Z0-9''_]*)(?=(\.[A-Z][a-zA-Z0-9_]*)*)' - match: '^\s*(module)\s+([A-Z][[:alpha:]0-9''_]*)\s*(=)\s*([A-Z][[:alpha:]0-9''_]*)'
captures: captures:
1: keyword.other.fsharp 1: keyword.fsharp
2: support.other.module.fsharp 2: entity.name.type.namespace.fsharp
3: punctuation.separator.namespace-definition.fsharp
4: entity.name.section.fsharp
push: push:
- meta_scope: meta.module.open.fsharp - meta_scope: namespace.alias.fsharp
- match: (\s|$) - match: (\s|$)
pop: true pop: true
- match: '(\.)([A-Z][a-zA-Z0-9''_]*)' - match: '(\.)([A-Z][[:alpha:]0-9''_]*)'
scope: support.other.module.fsharp scope: entity.name.section.fsharp
captures: captures:
1: punctuation.separator.module-reference.fsharp 1: punctuation.separator.namespace-reference.fsharp
2: support.other.module.fsharp 2: entity.name.section.fsharp
- match: '^\s*(module)\s+([A-Z][a-zA-Z0-9''_]*)\s*(=)\s*([A-Z][a-zA-Z0-9''_]*)' record_declaration:
- match: '(\{)'
captures: captures:
1: keyword.other.module-definition.fsharp 1: keyword.symbol.fsharp
2: entity.name.type.module.fsharp
3: punctuation.separator.module-definition.fsharp
4: support.other.module.fsharp
push: push:
- meta_scope: meta.module.alias.fsharp - match: '(?<=\})'
- match: (\s|$)
pop: true pop: true
- match: '(\.)([A-Z][a-zA-Z0-9''_]*)' - include: comments
scope: support.other.module.fsharp - match: '(((mutable)\s[[:alpha:]]+)|[[:alpha:]0-9''`<>^._]*)\s*((?<!:):(?!:))\s*'
captures: captures:
1: punctuation.separator.module-reference.fsharp 3: keyword.fsharp
2: support.other.module.fsharp 4: keyword.symbol.fsharp
- match: '(?<!\w)([A-Z][a-zA-Z0-9_]*)(\.)' push:
- match: '$|(;|\})'
captures:
1: keyword.symbol.fsharp
pop: true
- include: comments
- match: "([[:alpha:]0-9'`^_ ]+)"
captures:
1: entity.name.type.fsharp
- include: keywords
- include: compiler_directives
- include: constants
- include: strings
- include: chars
- include: double_tick
- include: definition
- include: attributes
- include: anonymous_functions
- include: keywords
- include: cexprs
- include: text
record_signature:
- match: "[[:alpha:]0-9'`^_ ]+(=)([[:alpha:]0-9'`^_ ]+)"
captures: captures:
1: support.other.module.fsharp 1: keyword.symbol.fsharp
2: punctuation.separator.module-reference.fsharp 2: variable.parameter.fsharp
- match: "({)"
captures:
1: keyword.symbol.fsharp
push: push:
- meta_scope: meta.module.reference.fsharp - match: "(})"
- match: '[A-Z][a-zA-Z0-9_]+(\.)'
scope: support.other.module.fsharp
captures: captures:
1: punctuation.separator.module-reference.fsharp 1: keyword.symbol.fsharp
- match: (?=.)
pop: true pop: true
- match: "[[:alpha:]0-9'`^_ ]+(=)([[:alpha:]0-9'`^_ ]+)"
captures:
1: keyword.symbol.fsharp
2: variable.parameter.fsharp
- include: record_signature
- include: keywords
records:
- match: '\b(type)[\s]+(private|internal|public)?\s*'
captures:
1: keyword.fsharp
2: keyword.fsharp
push:
- meta_scope: record.fsharp
- match: '\s*((with)|((as)\s+([[:alpha:]0-9'']+))|(=)|[\n=]|(\(\)))'
captures:
2: keyword.fsharp
3: keyword.fsharp
4: keyword.fsharp
5: variable.parameter.fsharp
6: keyword.symbol.fsharp
7: constant.language.unit.fsharp
pop: true
- include: comments
- include: attributes
- match: "([[:alpha:]0-9'^._]+|``[[:alpha:]0-9'`^:,._ ]+``)"
captures:
1: entity.name.type.fsharp
- match: (<)
captures:
1: keyword.fsharp
push:
- match: ((?<!:)>)
captures:
1: keyword.fsharp
pop: true
- match: '((''|\^)``[[:alpha:]0-9`^:,._ ]+``|(''|\^)[[:alpha:]0-9`^:._]+)'
captures:
1: entity.name.type.fsharp
- match: \b(interface|with|abstract|and|when|or|not|struct|equality|comparison|unmanaged|delegate|enum)\b
scope: keyword.fsharp
- match: (\()
captures:
1: keyword.symbol.fsharp
push:
- match: (\))
captures:
1: keyword.symbol.fsharp
pop: true
- match: (static member|member|new)
captures:
1: keyword.fsharp
- include: common_binding_definition
- match: '([\w0-9''`^._]+)'
captures:
1: entity.name.type.fsharp
- include: keywords
- match: \s*(private|internal|public)
captures:
1: keyword.symbol.fsharp
2: keyword.fsharp
- match: (\()
captures:
1: keyword.symbol.fsharp
push:
- match: '\s*(?=(=)|[\n=]|(\(\))|(as))'
captures:
1: keyword.symbol.fsharp
pop: true
- include: member_declaration
- include: keywords
string_formatter:
- match: (%0?-?(\d+)?((a|t)|(\.\d+)?(f|F|e|E|g|G|M)|(b|c|s|d|i|x|X|o|u)|(s|b|O)|(\+?A)))
scope: entity.name.type.format.specifier.fsharp
captures:
1: keyword.format.specifier.fsharp
strings: strings:
- match: '(?=[^\\])(""")'
captures:
1: punctuation.definition.string.begin.fsharp
push:
- meta_scope: string.quoted.double.fsharp
- match: (""")
captures:
1: punctuation.definition.string.end.fsharp
pop: true
- match: '\\$[ \t]*'
scope: punctuation.separator.string.ignore-eol.fsharp
- match: '(?=[^\\])(@")' - match: '(?=[^\\])(@")'
captures: captures:
1: punctuation.definition.string.begin.fsharp 1: punctuation.definition.string.begin.fsharp
push: push:
- meta_scope: string.quoted.double.fsharp - meta_scope: string.quoted.literal.fsharp
- match: (") - match: (")(?!")
captures: captures:
1: punctuation.definition.string.end.fsharp 1: punctuation.definition.string.end.fsharp
pop: true pop: true
- match: '\\$[ \t]*' - match: '"(")'
scope: punctuation.separator.string.ignore-eol.fsharp scope: constant.character.string.escape.fsharp
- match: '(?=[^\\])(""")'
captures:
1: punctuation.definition.string.begin.fsharp
push:
- meta_scope: string.quoted.triple.fsharp
- match: (""")
captures:
1: punctuation.definition.string.end.fsharp
pop: true
- include: string_formatter
- match: '(?=[^\\])(")' - match: '(?=[^\\])(")'
captures: captures:
1: punctuation.definition.string.begin.fsharp 1: punctuation.definition.string.begin.fsharp
@@ -201,34 +594,79 @@ contexts:
pop: true pop: true
- match: '\\$[ \t]*' - match: '\\$[ \t]*'
scope: punctuation.separator.string.ignore-eol.fsharp scope: punctuation.separator.string.ignore-eol.fsharp
- match: '\\([\\''ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8})' - match: '\\([\\''''ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8})'
scope: constant.character.string.escape.fsharp scope: constant.character.string.escape.fsharp
- match: '\\(?![\\''ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8}).' - match: '\\(?![\\''''ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8}).'
scope: invalid.illeagal.character.string.fsharp scope: invalid.illeagal.character.string.fsharp
- match: '(?=[^\\])('')' - include: string_formatter
strp_inlined:
- match: (\()
captures: captures:
1: punctuation.definition.string.begin.fsharp 1: keyword.symbol.fsharp
push: push:
- meta_scope: string.quoted.double.fsharp - match: (\))
- match: (')
captures: captures:
1: punctuation.definition.string.end.fsharp 1: keyword.symbol.fsharp
pop: true pop: true
- match: '\\$[ \t]*' - include: strp_inlined_body
scope: punctuation.separator.string.ignore-eol.fsharp strp_inlined_body:
- match: '\\([\\"ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8})' - include: comments
scope: constant.character.string.escape.fsharp - include: anonymous_functions
- match: '\\(?![\\"ntbr]|u[a-fA-F0-9]{4}|u[a-fA-F0-9]{8}).' - match: '(\^[[:alpha:]0-9''._]+)'
scope: invalid.illeagal.character.string.fsharp captures:
structure: 1: entity.name.type.fsharp
- match: \( - match: \b(and|when|or)\b
scope: keyword.fsharp
- match: (\()
captures:
1: keyword.symbol.fsharp
push: push:
- meta_scope: meta.paren-group.fsharp - match: (\))
- match: \) captures:
1: keyword.symbol.fsharp
pop: true pop: true
- include: main - include: strp_inlined_body
- match: '(static member|member)\s*([[:alpha:]0-9''`<>^._]+|``[[:alpha:]0-9'' <>^._]+``)\s*(:)'
captures:
1: keyword.fsharp
2: variable.fsharp
3: keyword.symbol.fsharp
- include: compiler_directives
- include: constants
- include: strings
- include: chars
- include: double_tick
- include: keywords
- include: text
- include: definition
- include: attributes
- include: keywords
- include: cexprs
- include: text
text:
- match: \\
scope: text.fsharp
tuple_signature:
- match: "(([?[:alpha:]0-9'`^._ ]+))+"
captures:
1: entity.name.type.fsharp
- match: (\()
captures:
1: keyword.symbol.fsharp
push:
- match: (\))
captures:
1: keyword.symbol.fsharp
pop: true
- match: "(([?[:alpha:]0-9'`^._ ]+))+"
captures:
1: entity.name.type.fsharp
- include: tuple_signature
- include: keywords
variables: variables:
- match: \(\) - match: \(\)
scope: variable.parameter.unit.fsharp scope: constant.language.unit.fsharp
- match: '[a-zA-Z]\w*' - match: '(\?{0,1})(``[[:alpha:]0-9''`^:,._ ]+``|[[:alpha:]0-9''`<>^._ ]\w*)'
scope: variable.parameter.fsharp captures:
1: keyword.symbol.fsharp
2: variable.parameter.fsharp
Vendored Submodule
+1
Submodule assets/syntaxes/GraphQL added at 66ce8713d8
+662
View File
@@ -0,0 +1,662 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: HTML (Twig)
file_extensions:
- twig
- html.twig
scope: text.html.twig
contexts:
main:
- match: '(<)([a-zA-Z0-9:]++)(?=[^>]*></\2>)'
captures:
1: punctuation.definition.tag.html
2: entity.name.tag.html
push:
- meta_scope: meta.tag.any.html
- match: (>(<)/)(\2)(>)
captures:
1: punctuation.definition.tag.html
2: meta.scope.between-tag-pair.html
3: entity.name.tag.html
4: punctuation.definition.tag.html
pop: true
- include: tag-stuff
- match: (<\?)(xml)
captures:
1: punctuation.definition.tag.html
2: entity.name.tag.xml.html
push:
- meta_scope: meta.tag.preprocessor.xml.html
- match: (\?>)
captures:
1: punctuation.definition.tag.html
2: entity.name.tag.xml.html
pop: true
- include: tag-generic-attribute
- include: string-double-quoted
- include: string-single-quoted
- match: <!--
captures:
0: punctuation.definition.comment.html
push:
- meta_scope: comment.block.html
- match: '--\s*>'
captures:
0: punctuation.definition.comment.html
pop: true
- match: "--"
scope: invalid.illegal.bad-comments-or-CDATA.html
- include: embedded-code
- match: <!
captures:
0: punctuation.definition.tag.html
push:
- meta_scope: meta.tag.sgml.html
- match: ">"
captures:
0: punctuation.definition.tag.html
pop: true
- match: (?i:DOCTYPE)
captures:
1: entity.name.tag.doctype.html
push:
- meta_scope: meta.tag.sgml.doctype.html
- match: (?=>)
captures:
1: entity.name.tag.doctype.html
pop: true
- match: '"[^">]*"'
scope: string.quoted.double.doctype.identifiers-and-DTDs.html
- match: '\[CDATA\['
push:
- meta_scope: constant.other.inline-data.html
- match: "]](?=>)"
pop: true
- match: (\s*)(?!--|>)\S(\s*)
scope: invalid.illegal.bad-comments-or-CDATA.html
- include: embedded-code
- match: '(?:^\s+)?(<)((?i:style))\b(?![^>]*/>)'
captures:
1: punctuation.definition.tag.html
2: entity.name.tag.style.html
3: punctuation.definition.tag.html
push:
- meta_scope: source.css.embedded.html
- match: (</)((?i:style))(>)(?:\s*\n)?
captures:
1: punctuation.definition.tag.html
2: entity.name.tag.style.html
3: punctuation.definition.tag.html
pop: true
- include: tag-stuff
- match: (>)
captures:
1: punctuation.definition.tag.html
push:
- match: (?=</(?i:style))
pop: true
- include: embedded-code
- include: scope:source.css
- match: '(?:^\s+)?(<)((?i:script))\b(?![^>]*/>)'
captures:
1: punctuation.definition.tag.html
2: entity.name.tag.script.html
push:
- meta_scope: source.js.embedded.html
- match: (?<=</(script|SCRIPT))(>)(?:\s*\n)?
captures:
2: punctuation.definition.tag.html
pop: true
- include: tag-stuff
- match: (?<!</(?:script|SCRIPT))(>)
captures:
1: punctuation.definition.tag.html
2: entity.name.tag.script.html
push:
- match: (</)((?i:script))
captures:
1: punctuation.definition.tag.html
2: entity.name.tag.script.html
pop: true
- match: (//).*?((?=</script)|$\n?)
scope: comment.line.double-slash.js
captures:
1: punctuation.definition.comment.js
- match: /\*
captures:
0: punctuation.definition.comment.js
push:
- meta_scope: comment.block.js
- match: \*/|(?=</script)
captures:
0: punctuation.definition.comment.js
pop: true
- include: php
- include: twig-print-tag
- include: twig-statement-tag
- include: twig-comment-tag
- include: scope:source.js
- match: (</?)((?i:body|head|html)\b)
captures:
1: punctuation.definition.tag.html
2: entity.name.tag.structure.any.html
push:
- meta_scope: meta.tag.structure.any.html
- match: (>)
captures:
1: punctuation.definition.tag.html
2: entity.name.tag.structure.any.html
pop: true
- include: tag-stuff
- match: (</?)((?i:address|blockquote|dd|div|dl|dt|fieldset|form|frame|frameset|h1|h2|h3|h4|h5|h6|iframe|noframes|object|ol|p|ul|applet|center|dir|hr|menu|pre)\b)
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.block.any.html
push:
- meta_scope: meta.tag.block.any.html
- match: (>)
captures:
1: punctuation.definition.tag.end.html
pop: true
- include: tag-stuff
- match: (</?)((?i:a|abbr|acronym|area|b|base|basefont|bdo|big|br|button|caption|cite|code|col|colgroup|del|dfn|em|font|head|html|i|img|input|ins|isindex|kbd|label|legend|li|link|map|meta|noscript|optgroup|option|param|q|s|samp|script|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt|u|var)\b)
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.inline.any.html
push:
- meta_scope: meta.tag.inline.any.html
- match: "((?: ?/)?>)"
captures:
1: punctuation.definition.tag.end.html
pop: true
- include: tag-stuff
- match: "(</?)([a-zA-Z0-9:]+)"
captures:
1: punctuation.definition.tag.begin.html
2: entity.name.tag.other.html
push:
- meta_scope: meta.tag.other.html
- match: (>)
captures:
1: punctuation.definition.tag.end.html
pop: true
- include: tag-stuff
- include: entities
- match: <>
scope: invalid.illegal.incomplete.html
- match: <
scope: invalid.illegal.bad-angle-bracket.html
- include: twig-print-tag
- include: twig-statement-tag
- include: twig-comment-tag
embedded-code:
- include: ruby
- include: php
- include: twig-print-tag
- include: twig-statement-tag
- include: twig-comment-tag
- include: python
entities:
- match: "(&)([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+)(;)"
scope: constant.character.entity.html
captures:
1: punctuation.definition.entity.html
3: punctuation.definition.entity.html
- match: "&"
scope: invalid.illegal.bad-ampersand.html
php:
- match: (?=(^\s*)?<\?)
push:
- match: (?!(^\s*)?<\?)
pop: true
- include: scope:text.html.php
python:
- match: (?:^\s*)<\?python(?!.*\?>)
push:
- meta_scope: source.python.embedded.html
- match: \?>(?:\s*$\n)?
pop: true
- include: scope:source.python
ruby:
- match: "<%+#"
captures:
0: punctuation.definition.comment.erb
push:
- meta_scope: comment.block.erb
- match: "%>"
captures:
0: punctuation.definition.comment.erb
pop: true
- match: <%+(?!>)=?
captures:
0: punctuation.section.embedded.ruby
push:
- meta_scope: source.ruby.embedded.html
- match: "-?%>"
captures:
0: punctuation.section.embedded.ruby
pop: true
- match: (#).*?(?=-?%>)
scope: comment.line.number-sign.ruby
captures:
1: punctuation.definition.comment.ruby
- include: scope:source.ruby
- match: <\?r(?!>)=?
captures:
0: punctuation.section.embedded.ruby.nitro
push:
- meta_scope: source.ruby.nitro.embedded.html
- match: '-?\?>'
captures:
0: punctuation.section.embedded.ruby.nitro
pop: true
- match: (#).*?(?=-?\?>)
scope: comment.line.number-sign.ruby.nitro
captures:
1: punctuation.definition.comment.ruby.nitro
- include: scope:source.ruby
string-double-quoted:
- match: '"'
captures:
0: punctuation.definition.string.begin.html
push:
- meta_scope: string.quoted.double.html
- match: '"'
captures:
0: punctuation.definition.string.end.html
pop: true
- include: embedded-code
- include: entities
string-single-quoted:
- match: "'"
captures:
0: punctuation.definition.string.begin.html
push:
- meta_scope: string.quoted.single.html
- match: "'"
captures:
0: punctuation.definition.string.end.html
pop: true
- include: embedded-code
- include: entities
tag-generic-attribute:
- match: '\b([a-zA-Z\-:]+)'
scope: entity.other.attribute-name.html
tag-id-attribute:
- match: \b(id)\b\s*(=)
captures:
1: entity.other.attribute-name.id.html
2: punctuation.separator.key-value.html
push:
- meta_scope: meta.attribute-with-value.id.html
- match: (?<='|")
captures:
1: entity.other.attribute-name.id.html
2: punctuation.separator.key-value.html
pop: true
- match: '"'
captures:
0: punctuation.definition.string.begin.html
push:
- meta_scope: string.quoted.double.html
- meta_content_scope: meta.toc-list.id.html
- match: '"'
captures:
0: punctuation.definition.string.end.html
pop: true
- include: embedded-code
- include: entities
- match: "'"
captures:
0: punctuation.definition.string.begin.html
push:
- meta_scope: string.quoted.single.html
- meta_content_scope: meta.toc-list.id.html
- match: "'"
captures:
0: punctuation.definition.string.end.html
pop: true
- include: embedded-code
- include: entities
tag-stuff:
- include: tag-id-attribute
- include: tag-generic-attribute
- include: string-double-quoted
- include: string-single-quoted
- include: embedded-code
twig-arrays:
- match: '(?<=[\s\(\{\[:,])\['
captures:
0: punctuation.section.array.begin.twig
push:
- meta_scope: meta.array.twig
- match: '\]'
captures:
0: punctuation.section.array.end.twig
pop: true
- include: twig-arrays
- include: twig-hashes
- include: twig-constants
- include: twig-strings
- include: twig-functions-warg
- include: twig-functions
- include: twig-macros
- include: twig-objects
- include: twig-properties
- include: twig-filters-warg
- include: twig-filters
- include: twig-filters-warg-ud
- include: twig-filters-ud
- match: ","
scope: punctuation.separator.object.twig
twig-comment-tag:
- match: '\{#-?'
captures:
0: punctuation.definition.comment.begin.twig
push:
- meta_scope: comment.block.twig
- match: '-?#\}'
captures:
0: punctuation.definition.comment.end.twig
pop: true
twig-constants:
- match: '(?i)(?<=[\s\[\(\{:,])(?:true|false|null|none)(?=[\s\)\]\}\,])'
scope: constant.language.twig
- match: '(?<=[\s\[\(\{:,]|\.\.|\*\*)[0-9]+(?:\.[0-9]+)?(?=[\s\)\]\}\,]|\.\.|\*\*)'
scope: constant.numeric.twig
twig-filters:
- match: '(?<=(?:[a-zA-Z0-9_\x{7f}-\x{ff}\]\)\''\"]\|)|\{%\sfilter\s)(abs|capitalize|e(?:scape)?|first|join|(?:json|url)_encode|keys|last|length|lower|nl2br|number_format|raw|reverse|round|sort|striptags|title|trim|upper)(?=[\s\|\]\}\):,]|\.\.|\*\*)'
captures:
1: support.function.twig
twig-filters-ud:
- match: '(?<=(?:[a-zA-Z0-9_\x{7f}-\x{ff}\]\)\''\"]\|)|\{%\sfilter\s)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)'
captures:
1: meta.function-call.other.twig
twig-filters-warg:
- match: '(?<=(?:[a-zA-Z0-9_\x{7f}-\x{ff}\]\)\''\"]\|)|\{%\sfilter\s)(batch|convert_encoding|date|date_modify|default|e(?:scape)?|format|join|merge|number_format|replace|round|slice|split|trim)(\()'
captures:
1: support.function.twig
2: punctuation.definition.parameters.begin.twig
push:
- meta_content_scope: meta.function.arguments.twig
- match: \)
captures:
0: punctuation.definition.parameters.end.twig
pop: true
- include: twig-constants
- include: twig-functions-warg
- include: twig-functions
- include: twig-macros
- include: twig-objects
- include: twig-properties
- include: twig-filters-warg
- include: twig-filters
- include: twig-filters-warg-ud
- include: twig-filters-ud
- include: twig-strings
- include: twig-arrays
- include: twig-hashes
twig-filters-warg-ud:
- match: '(?<=(?:[a-zA-Z0-9_\x{7f}-\x{ff}\]\)\''\"]\|)|\{%\sfilter\s)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(\()'
captures:
1: meta.function-call.other.twig
2: punctuation.definition.parameters.begin.twig
push:
- meta_content_scope: meta.function.arguments.twig
- match: \)
captures:
0: punctuation.definition.parameters.end.twig
pop: true
- include: twig-constants
- include: twig-functions-warg
- include: twig-functions
- include: twig-macros
- include: twig-objects
- include: twig-properties
- include: twig-filters-warg
- include: twig-filters
- include: twig-filters-warg-ud
- include: twig-filters-ud
- include: twig-strings
- include: twig-arrays
- include: twig-hashes
twig-functions:
- match: (?<=is\s)(defined|empty|even|iterable|odd)
captures:
1: support.function.twig
twig-functions-warg:
- match: '(?<=[\s\(\[\{:,])(attribute|block|constant|cycle|date|divisible by|dump|include|max|min|parent|random|range|same as|source|template_from_string)(\()'
captures:
1: support.function.twig
2: punctuation.definition.parameters.begin.twig
push:
- meta_content_scope: meta.function.arguments.twig
- match: \)
captures:
0: punctuation.definition.parameters.end.twig
pop: true
- include: twig-constants
- include: twig-functions-warg
- include: twig-functions
- include: twig-macros
- include: twig-objects
- include: twig-properties
- include: twig-filters-warg
- include: twig-filters
- include: twig-filters-warg-ud
- include: twig-filters-ud
- include: twig-strings
- include: twig-arrays
twig-hashes:
- match: '(?<=[\s\(\{\[:,])\{'
captures:
0: punctuation.section.hash.begin.twig
push:
- meta_scope: meta.hash.twig
- match: '\}'
captures:
0: punctuation.section.hash.end.twig
pop: true
- include: twig-hashes
- include: twig-arrays
- include: twig-constants
- include: twig-strings
- include: twig-functions-warg
- include: twig-functions
- include: twig-macros
- include: twig-objects
- include: twig-properties
- include: twig-filters-warg
- include: twig-filters
- include: twig-filters-warg-ud
- include: twig-filters-ud
- match: ":"
scope: punctuation.separator.key-value.twig
- match: ","
scope: punctuation.separator.object.twig
twig-keywords:
- match: (?<=\s)((?:end)?(?:autoescape|block|embed|filter|for|if|macro|raw|sandbox|set|spaceless|trans|verbatim)|as|do|else|elseif|extends|flush|from|ignore missing|import|include|only|use|with)(?=\s)
scope: keyword.control.twig
twig-macros:
- match: |-
(?x)
(?<=[\s\(\[\{:,])
([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)
(?:
(\.)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)
)?
(\()
captures:
1: meta.function-call.twig
2: punctuation.separator.property.twig
3: variable.other.property.twig
4: punctuation.definition.parameters.begin.twig
push:
- meta_content_scope: meta.function.arguments.twig
- match: \)
captures:
0: punctuation.definition.parameters.end.twig
pop: true
- include: twig-constants
- include: twig-operators
- include: twig-functions-warg
- include: twig-functions
- include: twig-macros
- include: twig-objects
- include: twig-properties
- include: twig-filters-warg
- include: twig-filters
- include: twig-filters-warg-ud
- include: twig-filters-ud
- include: twig-strings
- include: twig-arrays
- include: twig-hashes
twig-objects:
- match: '(?<=[\s\{\[\(:,])([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(?=[\s\}\[\]\(\)\.\|,:])'
captures:
1: variable.other.twig
twig-operators:
- match: (?<=\s)(\+|-|//?|%|\*\*?)(?=\s)
captures:
1: keyword.operator.arithmetic.twig
- match: (?<=\s)(=|~)(?=\s)
captures:
1: keyword.operator.assignment.twig
- match: (?<=\s)(b-(?:and|or|xor))(?=\s)
captures:
1: keyword.operator.bitwise.twig
- match: '(?<=\s)((?:!|=)=|<=?|>=?|(?:not )?in|is(?: not)?|(?:ends|starts) with|matches)(?=\s)'
captures:
1: keyword.operator.comparison.twig
- match: (?<=\s)(\?|:|and|not|or)(?=\s)
captures:
1: keyword.operator.logical.twig
- match: '(?<=[a-zA-Z0-9_\x{7f}-\x{ff}\]\)''"])\.\.(?=[a-zA-Z0-9_\x{7f}-\x{ff}''"])'
captures:
0: keyword.operator.other.twig
- match: '(?<=[a-zA-Z0-9_\x{7f}-\x{ff}\]\}\)''"])\|(?=[a-zA-Z_\x{7f}-\x{ff}])'
captures:
0: keyword.operator.other.twig
twig-print-tag:
- match: '\{\{-?'
captures:
0: punctuation.section.tag.twig
push:
- meta_scope: meta.tag.template.value.twig
- match: '-?\}\}'
captures:
0: punctuation.section.tag.twig
pop: true
- include: twig-constants
- include: twig-operators
- include: twig-functions-warg
- include: twig-functions
- include: twig-macros
- include: twig-objects
- include: twig-properties
- include: twig-filters-warg
- include: twig-filters
- include: twig-filters-warg-ud
- include: twig-filters-ud
- include: twig-strings
- include: twig-arrays
- include: twig-hashes
twig-properties:
- match: |-
(?x)
(?<=[a-zA-Z0-9_\x{7f}-\x{ff}])
(\.)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)
(?=[\.\s\|\[\)\]\}:,])
captures:
1: punctuation.separator.property.twig
2: variable.other.property.twig
- match: |-
(?x)
(?<=[a-zA-Z0-9_\x{7f}-\x{ff}])
(\.)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)
(\()
captures:
1: punctuation.separator.property.twig
2: variable.other.property.twig
3: punctuation.definition.parameters.begin.twig
push:
- meta_content_scope: meta.function.arguments.twig
- match: \)
captures:
0: punctuation.definition.parameters.end.twig
pop: true
- include: twig-constants
- include: twig-functions-warg
- include: twig-functions
- include: twig-macros
- include: twig-objects
- include: twig-properties
- include: twig-filters-warg
- include: twig-filters
- include: twig-filters-warg-ud
- include: twig-filters-ud
- include: twig-strings
- include: twig-arrays
- match: |-
(?x)
(?<=[a-zA-Z0-9_\x{7f}-\x{ff}\]])
(?:
(\[)('[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*')(\])
|(\[)("[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*")(\])
|(\[)([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(\])
)
captures:
1: punctuation.section.array.begin.twig
2: variable.other.property.twig
3: punctuation.section.array.end.twig
4: punctuation.section.array.begin.twig
5: variable.other.property.twig
6: punctuation.section.array.end.twig
7: punctuation.section.array.begin.twig
8: variable.other.property.twig
9: punctuation.section.array.end.twig
twig-statement-tag:
- match: '\{%-?'
captures:
0: punctuation.section.tag.twig
push:
- meta_scope: meta.tag.template.block.twig
- match: '-?%\}'
captures:
0: punctuation.section.tag.twig
pop: true
- include: twig-constants
- include: twig-keywords
- include: twig-operators
- include: twig-functions-warg
- include: twig-functions
- include: twig-macros
- include: twig-filters-warg
- include: twig-filters
- include: twig-filters-warg-ud
- include: twig-filters-ud
- include: twig-objects
- include: twig-properties
- include: twig-strings
- include: twig-arrays
- include: twig-hashes
twig-strings:
- match: (?:(?<!\\)|(?<=\\\\))'
captures:
0: punctuation.definition.string.begin.twig
push:
- meta_scope: string.quoted.single.twig
- match: (?:(?<!\\)|(?<=\\\\))'
captures:
0: punctuation.definition.string.end.twig
pop: true
- match: (?:(?<!\\)|(?<=\\\\))"
captures:
0: punctuation.definition.string.begin.twig
push:
- meta_scope: string.quoted.double.twig
- match: (?:(?<!\\)|(?<=\\\\))"
captures:
0: punctuation.definition.string.end.twig
pop: true
+23
View File
@@ -0,0 +1,23 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: hosts
file_extensions:
- hosts
scope: source.hosts
contexts:
main:
- scope: comment.line.number-sign
match: \#.*
comment: comment
- match: ^\s*([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|[0-9a-f:]+)
comment: ipaddress
scope: constant.numeric.ipaddress
- match: \s(localhost|ip6-loopback|ip6-localhost|ip6-localnet|ip6-mcastprefix|ip6-allnodes|ip6-allrouters|ip6-allhosts|broadcasthost)\b
scope: keyword.host.predefined}
comment: prefdfined
+1
View File
@@ -12,6 +12,7 @@ file_extensions:
- lng - lng
- cfg - cfg
- CFG - CFG
- desktop
- url - url
- URL - URL
- .editorconfig - .editorconfig
Vendored Submodule
+1
Submodule assets/syntaxes/Jsonnet added at 80775c616e
+44
View File
@@ -0,0 +1,44 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Manpage
file_extensions:
- man
scope: source.man
variables:
section_heading: '^\S.*$'
contexts:
main:
- match: ^
push: first_line
first_line:
- match: '([A-Z0-9]+)(\()([^)]+)(\))'
captures:
1: meta.preprocessor
2: keyword.operator
3: string.quoted.other
4: keyword.operator
- match: '$'
push: body
body:
- match: '^(SYNOPSIS|SYNTAX|SINTASSI|SKŁADNIA|СИНТАКСИС|書式)'
push: Packages/C/C.sublime-syntax
scope: markup.heading
with_prototype:
- match: '(?={{section_heading}})'
pop: true
- match: '^\S.*$'
scope: markup.heading
- match: '\b([a-z0-9_]+)(\()([^)]*)(\))'
captures:
1: entity.name.function
2: keyword.operator
3: constant.numeric
4: keyword.operator
Vendored Submodule
+1
+219
View File
@@ -0,0 +1,219 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: orgmode
file_extensions:
- org
scope: text.orgmode
contexts:
main:
- match: |-
(?x)
^(\*+) # leading stars
\s*([A-Z_]{2,})? # todo keywords
\s*(\[\#[A-Ca-c]\])? # priority
\s*(?=\s+[A-Za-z0-9]+) # expected heading text
comment: Outline headings
captures:
1: punctuation.definition.heading.orgmode
2: keyword.other.todo.orgmode
3: constant.other.priority.orgmode
push:
- meta_scope: markup.heading.orgmode
- meta_content_scope: entity.name.section.orgmode
- match: (?=\s*$\n?)
pop: true
- include: heading-inline
- match: "^-{5,}$"
scope: meta.separator.orgmode
- match: '^\s*([-+]|\s+\*)\s+(.*?)\s+::'
captures:
1: keyword.operator.list.orgmode
2: markup.bold.definition.orgmode
push:
- meta_scope: meta.list.definition.orgmode
- match: $
pop: true
- include: inline
- match: '^\s*?([-+]|\s+\*|\d+[).])'
captures:
1: keyword.operator.list.orgmode
push:
- meta_scope: meta.list.plain.orgmode
- match: $
pop: true
- include: list-inline
- match: (?i)^#\+(BEGIN_(QUOTE|VERSE|CENTER))$
captures:
1: keyword.control.block.orgmode
push:
- meta_scope: markup.quote.orgmode
- match: (?i)^#\+(END_\2)$
captures:
1: keyword.control.block.orgmode
pop: true
- match: "^#[^+].*$"
scope: comment.line.number-sign.orgmode
- match: ^:(PROPERTIES):$
captures:
1: keyword.control.drawer.orgmode
push:
- meta_scope: meta.drawer.properties.orgmode
- match: ^:(END):$
captures:
1: keyword.control.drawer.orgmode
pop: true
- include: properties
- match: ^:(.+):$
captures:
1: keyword.control.drawer.orgmode
push:
- meta_scope: meta.drawer.other.orgmode
- match: ^:(END):$
captures:
1: keyword.control.drawer.orgmode
pop: true
- match: (?i)#\+(BEGIN_LaTeX)$
captures:
1: keyword.control.block.orgmode
push:
- meta_scope: meta.block.latex.orgmode
- match: (?i)#\+(END_LaTeX)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:text.tex.latex
- match: (?i)#\+(BEGIN_HTML)$
captures:
1: keyword.control.block.orgmode
push:
- meta_scope: meta.block.html.orgmode
- match: (?i)#\+(END_HTML)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:text.html.basic
- match: (?i)#\+(BEGIN_SRC)\s+(python)\s*(.*)$
captures:
1: keyword.control.block.orgmode
2: constant.other.language.orgmode
3: string.other.header-args.orgmode
push:
- meta_scope: meta.block.source.python.orgmode
- match: (?i)#\+(END_SRC)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:source.python
- match: (?i)#\+(BEGIN_SRC)\s+(ruby)\s*(.*)$
captures:
1: keyword.control.block.orgmode
2: constant.other.language.orgmode
3: string.other.header-args.orgmode
push:
- meta_scope: meta.block.source.ruby.orgmode
- match: (?i)#\+(END_SRC)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:source.ruby
- match: (?i)#\+(BEGIN_SRC)\s+((?:emacs-)?lisp)\s*(.*)$
captures:
1: keyword.control.block.orgmode
2: constant.other.language.orgmode
3: string.other.header-args.orgmode
push:
- meta_scope: meta.block.source.lisp.orgmode
- match: (?i)#\+(END_SRC)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:source.lisp
- match: (?i)#\+(BEGIN_SRC)\s+(sh)\s*(.*)$
captures:
1: keyword.control.block.orgmode
2: constant.other.language.orgmode
3: string.other.header-args.orgmode
push:
- meta_scope: meta.block.source.shell.orgmode
- match: (?i)#\+(END_SRC)$
captures:
1: keyword.control.block.orgmode
pop: true
- include: scope:source.shell
- match: '(?i)#\+(BEGIN_(SRC|EXAMPLE))(?:\s+([\w-]+)?\s*(.*))?$'
captures:
1: keyword.control.block.orgmode
3: constant.other.language.orgmode
4: string.other.header-args.orgmode
push:
- meta_scope: meta.block.source.other.orgmode
- meta_content_scope: markup.raw.block.orgmode
- match: (?i)#\+(END_\2)$
captures:
1: keyword.control.block.orgmode
pop: true
- match: '#\+(OPTIONS):'
captures:
1: keyword.control.pragma.orgmode
push:
- meta_scope: meta.pragma.options.orgmode
- match: $
pop: true
- match: '([^\s]+):([^\s]+)'
scope: meta.option.orgmode
captures:
1: variable.parameter.option.orgmode
2: string.other.option.orgmode
- match: '#\+(CALL):\s+[A-Za-z-]+(?:\[([^\]]*)\])?\(?'
captures:
1: keyword.control.pragma.orgmode
2: string.other.header-args.orgmode
push:
- meta_scope: meta.pragma.call.orgmode
- match: '\)?([^)]*)$'
captures:
1: string.other.header-args.orgmode
pop: true
- match: (\w+)=
scope: meta.assignment.orgmode
captures:
1: variable.parameter.header-args.orgmode
- match: '^#\+([a-zA-Z_-]+): ?(.*)$'
scope: meta.pragma.orgmode
captures:
1: keyword.control.pragma.orgmode
2: string.unquoted.pragma.orgmode
- include: inline
heading-inline:
- match: ':([^:^\s]*)(?=:)'
scope: meta.keyword.orgmode
captures:
1: string.quoted.keyword.orgmode
- include: inline
inline:
- match: '(?<=^|[.,:;\s])/[^/]+/(?=$|[.,:;\s])'
scope: markup.italic.orgmode
- match: '(?<=^|[.,:;\s])\*[^*]+\*(?=$|[.,:;\s])'
scope: markup.bold.orgmode
- match: '(?<=^|[.,:;\s])_[^_]+_(?=$|[.,:;\s])'
scope: markup.underline.orgmode
- match: '(?<=^|[.,:;\s])([~=]).+?\1(?=$|[.,:;\s])'
scope: markup.raw.inline.orgmode
- match: '\[(?:\[([^\]]*)\])?\[([^\]]*)\]\]'
scope: meta.link.orgmode
captures:
1: markup.underline.link.orgmode
2: string.other.link.orgmode
- match: (?:http|ftp)s?:\/\/\S+
scope: markup.underline.url.orgmode
list-inline:
- match: '\[[ -X]\]'
scope: keyword.operator.checkbox.orgmode
- include: inline
properties:
- match: '^:([A-Za-z_]+):\s(.*)$'
scope: meta.property.orgmode
captures:
1: keyword.control.property.orgmode
2: string.unquoted.propval.orgmode
Vendored Submodule
+1
Vendored Submodule
+1
Vendored Submodule
+1
Submodule assets/syntaxes/Strace added at 3ec51e0bca
Vendored Submodule
+1
Submodule assets/syntaxes/Syslog added at 7628d4e0b8
Vendored Submodule
+1
Vendored Submodule
+1
Submodule assets/syntaxes/Verilog added at 532e87c1b4
+149
View File
@@ -0,0 +1,149 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Verilog
file_extensions:
- v
- V
scope: source.verilog
contexts:
main:
- match: '^\s*(module|function|primitive)\s+\b([a-zA-Z_][a-zA-Z0-9_]*)\b'
scope: meta.entity.module.verilog
captures:
1: storage.type.verilog
2: entity.name.type.class.verilog
- match: '^\s*(?!else)(?!begin)([a-zA-Z_][a-zA-Z0-9_]*)\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*(\()'
scope: meta.definition.verilog
captures:
1: entity.name.type.class.verilog
2: entity.name.type.instance.verilog
3: keyword.operator.parenthesis.round.verilog
- match: '^\s*(?!else)(?!begin)([a-zA-Z_][a-zA-Z0-9_]*)\s+([#])(\()([ ._+`,a-zA-Z0-9]+)(\))\s+([a-zA-Z_][a-zA-Z0-9_]*)\s*(\()'
scope: meta.definition.withparameter.verilog
captures:
1: entity.name.type.class.verilog
2: keyword.other.verilog
3: keyword.operator.parenthesis.round.verilog
4: keyword.other.verilog
5: keyword.operator.parenthesis.round.verilog
6: entity.name.type.instance.verilog
7: keyword.operator.parenthesis.round.verilog
- match: '^\s*\b(?!else)(?!begin)([a-zA-Z_][a-zA-Z0-9_]*)\b\s+([#])'
scope: meta.definition.withparameter.verilog
captures:
1: entity.name.type.class.verilog
2: keyword.other.verilog
- match: '^\s*(defparam)\s+([a-zA-Z_][a-zA-Z0-9_]*)(.[a-zA-Z_][a-zA-Z0-9_]*)\s*(=)'
scope: meta.definition.defparam.verilog
captures:
1: keyword.other.verilog
2: entity.name.type.instance.verilog
3: meta.module.parameters.verilog
4: keyword.other.verilog
- match: \b(automatic|cell|config|deassign|defparam|design|disable|edge|endconfig|endgenerate|endspecify|endtable|endtask|event|generate|genvar|ifnone|incdir|include|instance|liblist|library|localparam|macromodule|negedge|noshowcancelled|posedge|pulsestyle_onevent|pulsestyle_ondetect|real|realtime|scalared|showcancelled|specify|specparam|table|task|time|use|vectored)\b
scope: keyword.other.verilog
- match: "(#[0-9]+)"
scope: keyword.delay.verilog
- match: \b(initial|always|wait|force|release|assign)\b
scope: keyword.control.verilog
- match: \b(begin|end|fork|join)\b
scope: keyword.other.verilog
- match: \b(forever|repeat|while|for|if|else|case|casex|casez|default|endcase)\b
scope: keyword.control.verilog
- match: '^\s*(`include)\s+(["<].*[">])'
scope: meta.include.verilog
captures:
1: meta.preprocessor.verilog
2: entity.name.type.include.verilog
- match: '^\s*(`ifdef|`ifndef|`undef|`define)\s+([a-zA-Z_][a-zA-Z0-9_]*)\b'
scope: meta.preprocessor.ifdef.verilog
captures:
1: meta.preprocessor.verilog
2: constant.other.define.verilog
- match: '`(celldefine|default_nettype|define|else|elsif|endcelldefine|endif|ifdef|ifndef|include|line|nounconnected_drive|resetall|timescale|unconnected_drive|undef)\b'
scope: meta.preprocessor.verilog
- match: "[.][_a-zA-Z0-9]+"
scope: meta.module.parameters.verilog
- match: '`\b([a-zA-Z_][a-zA-Z0-9_]*)\b'
scope: constant.other.define.verilog
- include: comments
- match: \b(endmodule|endfunction|endprimitive)\b
scope: storage.type.verilog
- match: '^\s*\b([a-zA-Z_][a-zA-Z0-9_]*)\b\s*(:)\s*'
scope: meta.case.verilog
captures:
1: entity.name.state.verilog
2: keyword.operator.bitwise.verilog
- include: all-types
- match: (==|===|!=|!==|<=|>=|<|>)
scope: keyword.operator.comparison.verilog
- match: (\-|\+|\*|\/|%)
scope: keyword.operator.arithmetic.verilog
- match: (!|&&|\|\|)
scope: keyword.operator.logical.verilog
- match: (&|\||\^|~|<<|>>|\?|:)
scope: keyword.operator.bitwise.verilog
- match: "({|})"
scope: keyword.operator.parenthesis.curly.verilog
- match: (\(|\))
scope: keyword.operator.parenthesis.round.verilog
- match: '(\[|\])'
scope: keyword.operator.parenthesis.square.verilog
- match: "([;,])"
scope: keyword.delimiter.verilog
- match: (#|@|=)
scope: keyword.other.verilog
- match: '\b(output|input|inout|and|nand|nor|or|xor|xnor|buf|not|bufif[01]|notif[01]|r?[npc]mos|tran|r?tranif[01]|pullup|pulldown)\b'
scope: support.type.verilog
- match: '((\b\d+)?''s?([bB]\s*(([0-1_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*))|[oO]\s*(([0-7_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*))|[dD]\s*(([0-9_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*))|[hH]\s*(([0-9a-fA-F_xXzZ?]+)|(`[A-Z]+[_0-9a-zA-Z]*)))((e|E)(\+|-)?[0-9]+)?\b)|(\b\d+\b)'
scope: constant.numeric.verilog
- include: strings
- match: '\$\b([a-zA-Z_][a-zA-Z0-9_]*)\b'
scope: support.function.verilog
all-types:
- include: storage-type-verilog
- include: storage-modifier-verilog
comments:
- match: /\*
captures:
0: punctuation.definition.comment.verilog
push:
- meta_scope: comment.block.verilog
- match: \*/
captures:
0: punctuation.definition.comment.verilog
pop: true
- match: (//).*$\n?
scope: comment.line.double-slash.verilog
captures:
1: punctuation.definition.comment.verilog
storage-modifier-verilog:
- match: '\b(signed|unsigned|small|medium|large|supply[01]|strong[01]|pull[01]|weak[01]|highz[01])\b'
scope: storage.modifier.verilog
storage-type-verilog:
- match: '\b(wire|tri|tri[01]|supply[01]|wand|triand|wor|trior|trireg|reg|parameter|integer)\b'
scope: storage.type.verilog
strings:
- match: '"'
captures:
0: punctuation.definition.string.begin.verilog
push:
- meta_scope: string.quoted.double.verilog
- match: '"'
captures:
0: punctuation.definition.string.end.verilog
pop: true
- match: \\.
scope: constant.character.escape.verilog
- match: "'"
captures:
0: punctuation.definition.string.begin.verilog
push:
- meta_scope: string.quoted.single.verilog
- match: "'"
captures:
0: punctuation.definition.string.end.verilog
pop: true
- match: \\.
scope: constant.character.escape.verilog
File diff suppressed because it is too large Load Diff
Vendored Submodule
+1
Submodule assets/syntaxes/hosts added at 21250a7117
+19
View File
@@ -0,0 +1,19 @@
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: requirements.txt
file_extensions:
- requirements.txt
scope: source.requirementstxt
contexts:
main:
- match: (#).*$\n?
scope: comment.line.requirementstxt
captures:
1: punctuation.definition.comment.requirementstxt
- match: '(?i)^[a-z0-9_\-\.]+'
scope: string.package_name.requirementstxt
- match: (?i)==|<|<=|>=|>
scope: keyword.operator.logical.punctuation.requirementstxt
- match: '(?i)\d+\.[\da-z\-_\.]*'
scope: constant.numeric.verions.requirementstxt
+4
View File
@@ -25,3 +25,7 @@ contexts:
scope: entity.other.attribute-name.show-nonprintable.escape scope: entity.other.attribute-name.show-nonprintable.escape
- match: "␈" - match: "␈"
scope: entity.other.attribute-name.show-nonprintable.backspace scope: entity.other.attribute-name.show-nonprintable.backspace
- match: "\\\\x[A-Z0-9][A-Z0-9]"
scope: comment.block.show-nonprintable.backspace
- match: "\\\\u\\{[a-z0-9]+\\}"
scope: comment.block.show-nonprintable.backspace
Vendored Submodule
+1
Vendored Submodule
+1
Submodule assets/syntaxes/varlink added at 04f30d4b83
BIN
View File
Binary file not shown.
+504
View File
@@ -0,0 +1,504 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!--
The colors in this theme are encoded as #RRGGBBAA where RR is an ANSI
palette number from 00 to 0f, and AA is the special value 00 to indicate
that this encoding is being used.
-->
<key>author</key>
<string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
<key>name</key>
<string>ANSI Dark</string>
<key>colorSpaceName</key>
<string>sRGB</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#00000000</string>
<key>caret</key>
<string>#07000000</string>
<key>foreground</key>
<string>#07000000</string>
<key>invisibles</key>
<string>#07000000</string>
<key>lineHighlight</key>
<string>#07000000</string>
<key>selection</key>
<string>#07000000</string>
<key>gutter</key>
<string>#00000000</string>
<key>gutterForeground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Text</string>
<key>scope</key>
<string>variable.parameter.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>comment, punctuation.definition.comment</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Punctuation</string>
<key>scope</key>
<string>punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Delimiters</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Operators</string>
<key>scope</key>
<string>keyword.operator</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keywords</string>
<key>scope</key>
<string>keyword</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variables</string>
<key>scope</key>
<string>variable</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Functions</string>
<key>scope</key>
<string>entity.name.function, meta.require, support.function.any-method</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Labels</string>
<key>scope</key>
<string>entity.name.label</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>support.class, entity.name.class, entity.name.type.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>meta.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Methods</string>
<key>scope</key>
<string>keyword.other.special-method</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage</string>
<key>scope</key>
<string>storage</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Support</string>
<key>scope</key>
<string>support.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Strings, Inherited Class</string>
<key>scope</key>
<string>string, constant.other.symbol, entity.other.inherited-class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Integers</string>
<key>scope</key>
<string>constant.numeric</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Floats</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Boolean</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Constants</string>
<key>scope</key>
<string>constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Tags</string>
<key>scope</key>
<string>entity.name.tag</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Attributes</string>
<key>scope</key>
<string>entity.other.attribute-name</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Attribute IDs</string>
<key>scope</key>
<string>entity.other.attribute-name.id, punctuation.definition.entity</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Selector</string>
<key>scope</key>
<string>meta.selector</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Values</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Headings</string>
<key>scope</key>
<string>markup.heading punctuation.definition.heading, entity.name.section</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Units</string>
<key>scope</key>
<string>keyword.other.unit</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bold</string>
<key>scope</key>
<string>markup.bold, punctuation.definition.bold</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Italic</string>
<key>scope</key>
<string>markup.italic, punctuation.definition.italic</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Code</string>
<key>scope</key>
<string>markup.raw.inline</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Link Text</string>
<key>scope</key>
<string>string.other.link, punctuation.definition.string.end.markdown, punctuation.definition.string.begin.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Link Url</string>
<key>scope</key>
<string>meta.link</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Quotes</string>
<key>scope</key>
<string>markup.quote</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Inserted</string>
<key>scope</key>
<string>markup.inserted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Changed</string>
<key>scope</key>
<string>markup.changed</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Colors</string>
<key>scope</key>
<string>constant.other.color</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Regular Expressions</string>
<key>scope</key>
<string>string.regexp</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Escape Characters</string>
<key>scope</key>
<string>constant.character.escape</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Embedded</string>
<key>scope</key>
<string>punctuation.section.embedded, variable.interpolation</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Illegal</string>
<key>scope</key>
<string>invalid.illegal</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#01000000</string>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Broken</string>
<key>scope</key>
<string>invalid.broken</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#03000000</string>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
</array>
<key>uuid</key>
<string>uuid</string>
</dict>
</plist>
+504
View File
@@ -0,0 +1,504 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!--
The colors in this theme are encoded as #RRGGBBAA where RR is an ANSI
palette number from 00 to 0f, and AA is the special value 00 to indicate
that this encoding is being used.
-->
<key>author</key>
<string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
<key>name</key>
<string>ANSI Light</string>
<key>colorSpaceName</key>
<string>sRGB</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#07000000</string>
<key>caret</key>
<string>#00000000</string>
<key>foreground</key>
<string>#00000000</string>
<key>invisibles</key>
<string>#00000000</string>
<key>lineHighlight</key>
<string>#00000000</string>
<key>selection</key>
<string>#00000000</string>
<key>gutter</key>
<string>#07000000</string>
<key>gutterForeground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Text</string>
<key>scope</key>
<string>variable.parameter.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>comment, punctuation.definition.comment</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Punctuation</string>
<key>scope</key>
<string>punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Delimiters</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Operators</string>
<key>scope</key>
<string>keyword.operator</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keywords</string>
<key>scope</key>
<string>keyword</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variables</string>
<key>scope</key>
<string>variable</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Functions</string>
<key>scope</key>
<string>entity.name.function, meta.require, support.function.any-method</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Labels</string>
<key>scope</key>
<string>entity.name.label</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>support.class, entity.name.class, entity.name.type.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>meta.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Methods</string>
<key>scope</key>
<string>keyword.other.special-method</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage</string>
<key>scope</key>
<string>storage</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Support</string>
<key>scope</key>
<string>support.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Strings, Inherited Class</string>
<key>scope</key>
<string>string, constant.other.symbol, entity.other.inherited-class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Integers</string>
<key>scope</key>
<string>constant.numeric</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Floats</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Boolean</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Constants</string>
<key>scope</key>
<string>constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Tags</string>
<key>scope</key>
<string>entity.name.tag</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Attributes</string>
<key>scope</key>
<string>entity.other.attribute-name</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Attribute IDs</string>
<key>scope</key>
<string>entity.other.attribute-name.id, punctuation.definition.entity</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Selector</string>
<key>scope</key>
<string>meta.selector</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Values</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Headings</string>
<key>scope</key>
<string>markup.heading punctuation.definition.heading, entity.name.section</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Units</string>
<key>scope</key>
<string>keyword.other.unit</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bold</string>
<key>scope</key>
<string>markup.bold, punctuation.definition.bold</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Italic</string>
<key>scope</key>
<string>markup.italic, punctuation.definition.italic</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Code</string>
<key>scope</key>
<string>markup.raw.inline</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Link Text</string>
<key>scope</key>
<string>string.other.link, punctuation.definition.string.end.markdown, punctuation.definition.string.begin.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Link Url</string>
<key>scope</key>
<string>meta.link</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Quotes</string>
<key>scope</key>
<string>markup.quote</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Inserted</string>
<key>scope</key>
<string>markup.inserted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Changed</string>
<key>scope</key>
<string>markup.changed</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Colors</string>
<key>scope</key>
<string>constant.other.color</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Regular Expressions</string>
<key>scope</key>
<string>string.regexp</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Escape Characters</string>
<key>scope</key>
<string>constant.character.escape</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Embedded</string>
<key>scope</key>
<string>punctuation.section.embedded, variable.interpolation</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Illegal</string>
<key>scope</key>
<string>invalid.illegal</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#01000000</string>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Broken</string>
<key>scope</key>
<string>invalid.broken</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#03000000</string>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
</array>
<key>uuid</key>
<string>uuid</string>
</dict>
</plist>
+543
View File
@@ -0,0 +1,543 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!--
The colors in this theme are encoded as #RRGGBBAA where RR is an ANSI
palette number from 00 to 0f, and AA is the special value 00 to indicate
that this encoding is being used.
-->
<key>author</key>
<string>Template: Chris Kempson, Scheme: Mitchell Kember</string>
<key>name</key>
<string>Base16</string>
<key>colorSpaceName</key>
<string>sRGB</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#00000000</string>
<key>caret</key>
<string>#07000000</string>
<key>foreground</key>
<string>#07000000</string>
<key>invisibles</key>
<string>#08000000</string>
<key>lineHighlight</key>
<string>#08000000</string>
<key>selection</key>
<string>#0b000000</string>
<key>gutter</key>
<string>#0a000000</string>
<key>gutterForeground</key>
<string>#08000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Text</string>
<key>scope</key>
<string>variable.parameter.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>comment, punctuation.definition.comment</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#08000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Punctuation</string>
<key>scope</key>
<string>punctuation.definition.string, punctuation.definition.variable, punctuation.definition.string, punctuation.definition.parameters, punctuation.definition.string, punctuation.definition.array</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Delimiters</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Operators</string>
<key>scope</key>
<string>keyword.operator</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keywords</string>
<key>scope</key>
<string>keyword</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variables</string>
<key>scope</key>
<string>variable</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Functions</string>
<key>scope</key>
<string>entity.name.function, meta.require, support.function.any-method</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Labels</string>
<key>scope</key>
<string>entity.name.label</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0e000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>support.class, entity.name.class, entity.name.type.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Classes</string>
<key>scope</key>
<string>meta.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0f000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Methods</string>
<key>scope</key>
<string>keyword.other.special-method</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage</string>
<key>scope</key>
<string>storage</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Support</string>
<key>scope</key>
<string>support.function</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Strings, Inherited Class</string>
<key>scope</key>
<string>string, constant.other.symbol, entity.other.inherited-class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Integers</string>
<key>scope</key>
<string>constant.numeric</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Floats</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Boolean</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Constants</string>
<key>scope</key>
<string>constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Tags</string>
<key>scope</key>
<string>entity.name.tag</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Attributes</string>
<key>scope</key>
<string>entity.other.attribute-name</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Attribute IDs</string>
<key>scope</key>
<string>entity.other.attribute-name.id, punctuation.definition.entity</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Selector</string>
<key>scope</key>
<string>meta.selector</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Values</string>
<key>scope</key>
<string>none</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Headings</string>
<key>scope</key>
<string>markup.heading punctuation.definition.heading, entity.name.section</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#04000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Units</string>
<key>scope</key>
<string>keyword.other.unit</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bold</string>
<key>scope</key>
<string>markup.bold, punctuation.definition.bold</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#03000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Italic</string>
<key>scope</key>
<string>markup.italic, punctuation.definition.italic</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Code</string>
<key>scope</key>
<string>markup.raw.inline</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Link Text</string>
<key>scope</key>
<string>string.other.link, punctuation.definition.string.end.markdown, punctuation.definition.string.begin.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Link Url</string>
<key>scope</key>
<string>meta.link</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Quotes</string>
<key>scope</key>
<string>markup.quote</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#09000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Separator</string>
<key>scope</key>
<string>meta.separator</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#0b000000</string>
<key>foreground</key>
<string>#07000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Inserted</string>
<key>scope</key>
<string>markup.inserted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#02000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#01000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Changed</string>
<key>scope</key>
<string>markup.changed</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Colors</string>
<key>scope</key>
<string>constant.other.color</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Regular Expressions</string>
<key>scope</key>
<string>string.regexp</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Escape Characters</string>
<key>scope</key>
<string>constant.character.escape</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#06000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Embedded</string>
<key>scope</key>
<string>punctuation.section.embedded, variable.interpolation</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#05000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Illegal</string>
<key>scope</key>
<string>invalid.illegal</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#01000000</string>
<key>foreground</key>
<string>#0f000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Broken</string>
<key>scope</key>
<string>invalid.broken</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#09000000</string>
<key>foreground</key>
<string>#00000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Deprecated</string>
<key>scope</key>
<string>invalid.deprecated</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#0e000000</string>
<key>foreground</key>
<string>#0f000000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Unimplemented</string>
<key>scope</key>
<string>invalid.unimplemented</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#08000000</string>
<key>foreground</key>
<string>#0f000000</string>
</dict>
</dict>
</array>
<key>uuid</key>
<string>uuid</string>
</dict>
</plist>
+24 -19
View File
@@ -1,26 +1,31 @@
#[macro_use] // TODO: Re-enable generation of shell completion files (below) when clap 3 is out.
extern crate clap; // For more details, see https://github.com/sharkdp/bat/issues/372
use clap::Shell; fn main() {}
use std::fs;
include!("src/clap_app.rs"); // #[macro_use]
// extern crate clap;
const BIN_NAME: &str = "bat"; // use clap::Shell;
// use std::fs;
fn main() { // include!("src/clap_app.rs");
let outdir = std::env::var_os("SHELL_COMPLETIONS_DIR").or(std::env::var_os("OUT_DIR"));
let outdir = match outdir { // const BIN_NAME: &str = "bat";
None => return,
Some(outdir) => outdir,
};
fs::create_dir_all(&outdir).unwrap(); // fn main() {
// let outdir = std::env::var_os("SHELL_COMPLETIONS_DIR").or(std::env::var_os("OUT_DIR"));
let mut app = build_app(true); // let outdir = match outdir {
app.gen_completions(BIN_NAME, Shell::Bash, &outdir); // None => return,
app.gen_completions(BIN_NAME, Shell::Fish, &outdir); // Some(outdir) => outdir,
app.gen_completions(BIN_NAME, Shell::Zsh, &outdir); // };
app.gen_completions(BIN_NAME, Shell::PowerShell, &outdir);
} // fs::create_dir_all(&outdir).unwrap();
// let mut app = build_app(true);
// app.gen_completions(BIN_NAME, Shell::Bash, &outdir);
// app.gen_completions(BIN_NAME, Shell::Fish, &outdir);
// app.gen_completions(BIN_NAME, Shell::Zsh, &outdir);
// app.gen_completions(BIN_NAME, Shell::PowerShell, &outdir);
// }
+1
View File
@@ -0,0 +1 @@
* linguist-vendored
+47
View File
@@ -43,6 +43,7 @@ pack() {
# TODO: disabled for now, see issue #372 # TODO: disabled for now, see issue #372
# cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".bash "$tempdir/$package_name/autocomplete/${PROJECT_NAME}.bash-completion" # cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".bash "$tempdir/$package_name/autocomplete/${PROJECT_NAME}.bash-completion"
# cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".fish "$tempdir/$package_name/autocomplete" # cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".fish "$tempdir/$package_name/autocomplete"
cp assets/completions/bat.fish "$tempdir/$package_name/autocomplete"
# cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/_"$PROJECT_NAME" "$tempdir/$package_name/autocomplete" # cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/_"$PROJECT_NAME" "$tempdir/$package_name/autocomplete"
# archiving # archiving
@@ -59,6 +60,11 @@ make_deb() {
local dpkgname local dpkgname
local conflictname local conflictname
local gcc_prefix local gcc_prefix
local homepage
local maintainer
homepage="https://github.com/sharkdp/bat"
maintainer="David Peter <mail@david-peter.de>"
case $TARGET in case $TARGET in
x86_64*) x86_64*)
@@ -101,10 +107,51 @@ make_deb() {
install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1" install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
gzip --best "$tempdir/usr/share/man/man1/$PROJECT_NAME.1" gzip --best "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
# completions
install -Dm644 assets/completions/bat.fish "$tempdir/usr/share/fish/completions/$PROJECT_NAME.fish"
# readme and license # readme and license
install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md" install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md"
install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT" install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT"
install -Dm644 LICENSE-APACHE "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-APACHE" install -Dm644 LICENSE-APACHE "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-APACHE"
cat > "$tempdir/usr/share/doc/$PROJECT_NAME/copyright" <<EOF
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: $PROJECT_NAME
Source: $homepage
Files: *
Copyright: $maintainer
License: Apache-2.0 or MIT
License: Apache-2.0
On Debian systems, the complete text of the Apache-2.0 can be found in the
file /usr/share/common-licenses/Apache-2.0.
License: MIT
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
.
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
EOF
# Control file # Control file
mkdir "$tempdir/DEBIAN" mkdir "$tempdir/DEBIAN"
+2 -1
View File
@@ -33,5 +33,6 @@ if [[ $TARGET == aarch64-unknown-linux-gnu ]]; then
sudo apt-get install -y \ sudo apt-get install -y \
gcc-4.8-aarch64-linux-gnu \ gcc-4.8-aarch64-linux-gnu \
binutils-aarch64-linux-gnu \ binutils-aarch64-linux-gnu \
gcc-aarch64-linux-gnu gcc-aarch64-linux-gnu \
libc6-dev-arm64-cross
fi fi
+455
View File
@@ -0,0 +1,455 @@
<p align="center">
<img src="logo-header.svg" alt="bat - a cat clone with wings"><br>
<a href="https://travis-ci.org/sharkdp/bat"><img src="https://travis-ci.org/sharkdp/bat.svg?branch=master" alt="Build Status"></a>
<a href="https://ci.appveyor.com/project/sharkdp/bat"><img src="https://ci.appveyor.com/api/projects/status/cptsmtbiwbnr2vhf?svg=true"></a>
<img src="https://img.shields.io/crates/l/bat.svg" alt="license">
<a href="https://crates.io/crates/bat"><img src="https://img.shields.io/crates/v/bat.svg?colorB=319e8c" alt="Version info"></a><br>
A <i>cat(1)</i> clone with syntax highlighting and Git integration.
</p>
<p align="center">
<a href="#syntax-highlighting">特徴</a> •
<a href="#how-to-use">使い方</a> •
<a href="#installation">インストール</a> •
<a href="#customization">カスタマイズ</a> •
<a href="#project-goals-and-alternatives">プロジェクトの目標と既存の類似したOSS</a> •
翻訳 [<a href="https://github.com/chinanf-boy/bat-zh">中文</a>][<a href="README-ja">日本文</a>]
</p>
### シンタックスハイライト
`bat` は多くのプログラミング言語やマークアップ言語のシンタックスハイライトに対応しています。
![Syntax highlighting example](https://imgur.com/rGsdnDe.png)
### Gitの統合
`bat``git` とも連携しており、差分を表現する記号が表示されます(図の左端):
![Git integration example](https://i.imgur.com/2lSW4RE.png)
### 空白文字の可視化
`-A`/`--show-all` オプションをつけることで、空白文字を可視化できます:
![Non-printable character example](https://i.imgur.com/WndGp9H.png)
### 自動呼び出し
出力が1つの画面に対して大きすぎる場合、`bat` は自身の出力を `less` にパイプで繋げることが可能です。
### ファイルの連結
あなたはさらにファイルを連結させるに使うことも可能です:wink:。
`bat` は非対話型のターミナルを検出すると、いつでも `cat` の完全互換として振る舞い、
プレーンなファイルを表示します。
## 使い方
単一のファイルを表示させたい
```bash
> bat README.md
```
複数のファイルを一度に表示させたい場合
```bash
> bat src/*.rs
```
標準入力から自動的に構文を決定させたい場合
```bash
> curl -s https://sh.rustup.rs | bat
```
Read from stdin, specify the language explicitly
標準入力から明示的に言語を指定したい場合
```bash
> yaml2json .travis.yml | json_pp | bat -l json
```
空白文字を可視化させたい場合:
```bash
> bat -A /etc/hosts
```
`cat` の代わりに `bat` を使用する際の例:
```bash
bat > note.md # quickly create a new file
bat header.md content.md footer.md > document.md
bat -n main.rs # show line numbers (only)
bat f - g # output 'f', then stdin, then 'g'.
```
## インストール
### Ubuntu
*... や他のDebianベースのLinuxディストリビューション*
最新の `.deb` パッケージを[こちら](https://github.com/sharkdp/bat/releases)からダウンロードして、インストールしてください:
``` bash
sudo dpkg -i bat_0.12.1_amd64.deb # adapt version number and architecture
```
### Arch Linux
[Arch Linuxの公式リソース](https://www.archlinux.org/packages/community/x86_64/bat/)からインストールできます。
```bash
pacman -S bat
```
### Void Linux
xbps-ininstall経由で `bat` をインストールできます。
```
xbps-install -S bat
```
### Fedora
[Fedora Modular](https://docs.fedoraproject.org/en-US/modularity/using-modules/)経由で `bat` をインストールできます。これはFedora 29以上ではデフォルトで有効化されています。 もしそうでなければ、 `dnf install fedora-repos-modular` を実行してセットアップし、 `fedora-modular` と `fedora-updates-modular` が `/etc/yum.repos.d` で有効化されていることを確認してください。
```bash
dnf module install bat
```
### Gentoo Linux
[Gentoo Linuxの公式リソース](https://packages.gentoo.org/packages/sys-apps/bat)からインストールできます。
```bash
emerge sys-apps/bat
```
### FreeBSD
事前にコンパイル済みである[pkg](https://www.freshports.org/textproc/bat)をインストールできます:
```bash
pkg install bat
```
または、FreeBSDのportsから自身でビルドすることも可能です:
```bash
cd /usr/ports/textproc/bat
make install
```
### nix
`bat` を[nix package manager](https://nixos.org/nix)経由でインストールすることができます:
```bash
nix-env -i bat
```
### openSUSE
You can install `bat` with zypper:
`bat` をzypperでインストールすることができます:
```
zypper install bat
```
### macOS
[Homebrew](http://braumeister.org/formula/bat)でインストールすることができます:
```bash
brew install bat
```
### Windows
You can download prebuilt binaries from the [Release page],
or install it with :
事前にビルド済みのバイナリを[リリースページ](https://github.com/sharkdp/bat/releases)からダウンロードすることができます。または、[scoop](https://scoop.sh/)でインストールすることも可能です。
```bash
scoop install bat
```
[See below](#using-bat-on-windows) for notes.
### Docker
コンテナ内で`bat` を使いたい方のために[Docker image](https://hub.docker.com/r/danlynn/bat/)が用意されています。
```bash
docker pull danlynn/bat
alias bat='docker run -it --rm -e BAT_THEME -e BAT_STYLE -e BAT_TABS -v "$(pwd):/myapp" danlynn/bat'
```
### Ansible
[Ansible](https://www.ansible.com/)でインストールすることができます:
```bash
# Install role on local machine
ansible-galaxy install aeimer.install_bat
```
```yaml
---
# Playbook to install bat
- host: all
roles:
- aeimer.install_bat
```
- [Ansible Galaxy](https://galaxy.ansible.com/aeimer/install_bat)
- [GitHub](https://github.com/aeimer/ansible-install-bat)
これは以下のディストリビューションで動作するはずです:
- Debian/Ubuntu
- ARM (eg. Raspberry PI)
- Arch Linux
- Void Linux
- FreeBSD
- MacOS
### From binaries
多くの異なるアーキテクチャのためのプレビルドバージョンを[リリースページ](https://github.com/sharkdp/bat/releases)からチェックしてみてください。静的にリンクされている多くのバイナリも利用できます: ファイル名に `musl` を含むアーカイブを探します。
### From source
`bat` をソースからビルドしたいならば、Rust 1.29 以上の環境が必要です。そして、 `cargo` をビルドに対して使用します:
```bash
cargo install bat
```
`cmake` と `libz` 開発パッケージ(`libz-dev` または `libz-devel`)が正しくビルドをするためにインストールする必要があるかもしれません。
## カスタマイズ
### ハイライト テーマ
`bat --list-themes` を使うと現在利用可能なシンタックスハイライトのテーマを入手できます。 `TwoDark` テーマを選ぶためには `--theme=TwoDark` オプションをつけるか `BAT_THEME` という環境変数に `TwoDark` を代入する必要があります。 シェルの起動ファイルに `export BAT_THEME="TwoDark"` と定義すればその設定が変わることはないでしょう。あるいは、 `bat` の[設定ファイル](https://github.com/sharkdp/bat#configuration-file)を利用してください。
もし、ファイルにより異なるテーマを利用したい場合は、以下の[`fzf`](https://github.com/junegunn/fzf)を利用した以下のコマンドを使うことができます:
``` bash
bat --list-themes | fzf --preview="bat --theme={} --color=always /path/to/file"
```
`bat` はデフォルトだと黒い背景色のターミナルに適しています。しかし、`GitHub` や `OneHalfLight` のような白い背景色のテーマでもいい感じにすることができます。
以下のカスタムテーマを参考にしてみてください。
['Adding new themes' section below](https://github.com/sharkdp/bat#adding-new-themes)
### 出力のスタイル
`--style` を使うことで `bat` の表示の見た目を変更することができます。例えば、 `--style=numbers,changes` と入力します。すると、Gitの差分と行番号だけが表示され、グリッド線とファイルヘッダーは表示されません。
環境変数に `BAT_STYLE` を定義するとこれらの設定を永続的に使用することができます。
[設定ファイル](https://github.com/sharkdp/bat#configuration-file)を参考にしても良いでしょう。
### 新しい構文の追加 / 言語の定義
`bat` はシンタックスハイライトのための[`syntext`](https://github.com/trishume/syntect/)という最高にイケてるライブラリを使用しています。`syntect` はSublime Textのために作られた[`.sublime-syntax` file](https://www.sublimetext.com/docs/3/syntax.html)テーマです。新しい構文を定義するために以下の手順を行います。
構文定義ファイルを入れておくためのフォルダを作る:
```bash
mkdir -p "$(bat --config-dir)/syntaxes"
cd "$(bat --config-dir)/syntaxes"
# Put new '.sublime-syntax' language definition files
# in this folder (or its subdirectories), for example:
git clone https://github.com/tellnobody1/sublime-purescript-syntax
```
次のコマンドを使用して、これらのファイルをバイナリキャッシュに解析します:
```bash
bat cache --build
```
最後に `bat --list-languages` と入力すると新しい言語が利用可能かどうかチェックします。
デフォルトの設定に戻したいときは以下のコマンドを実行します:
```bash
bat cache --clear
```
### 新しいテーマの追加
これは構文を新しく定義するやり方と非常に似ています。
まず、新しいシンタックスハイライトのテーマのフォルダを作ります:
```bash
mkdir -p "$(bat --config-dir)/themes"
cd "$(bat --config-dir)/themes"
# Download a theme in '.tmTheme' format, for example:
git clone https://github.com/greggb/sublime-snazzy
# Update the binary cache
bat cache --build
```
最後に、 `bat --list-themes` で新しいテーマが利用可能がチェックします
### 異なるページャーの使用
`bat` は環境変数 `PAGER` に使用するページャーを明記します。
この環境変数が定義されていない場合、デフォルトで `less` が使用されます。もし、異なるページャーが使用したい場合は、`PAGER` を修正してください。または、`PAGER` を上書きする環境変数として `BAT_PAGER` を定義することも可能です。
もし、ページャーにコマンドライン引数を渡したい場合は、 `PAGER`/`BAT_PAGER` 環境変数を定義してください:
```bash
export BAT_PAGER="less -RF"
```
環境変数を利用する代わりに、 `bat` の[設定ファイル](https://github.com/sharkdp/bat#configuration-file)の `--pager` オプションを使用することも可能です。
**注意**: デフォルトにより、ページャーが `less` にセットされているならば `bat` は以下のコマンドラインを受け付けるでしょう。
ページャーのオプション: `-R`/`--RAW-CONTROL-CHARS`, `-F`/`--quit-if-one-screen` , `-X`/`--no-init`
最初の `-R` はANSIカラーを正しく解釈するために必要です。2番目の `-F` は出力サイズがターミナルの縦のサイズよりも小さいならば `less` に即座に終了するように命令します。したがって、少量のファイルのためにページャーを終了する `q` を押す必要がありません。3番目のオプションの `-X` は `less` の古いバージョンの機能である `--quit-if-one-screen` でバグを修正するために必要です。運の悪いことに、これは `less` のマウス-ホイールのサポートを無効にします。もし、マウス-ホイール スクローリングを有効にしたいなら、`-R` だけをオプションとしてつけてください(ただし、これは `--quit-if-one-screen` を無効にするでしょう)。または、 `less` の最近バージョンを利用し、 `-RF` をつけてください。 これは望ましいことに `--quit-if-one-screen` と マウス-ホイールスクローリングの両方を有効にするでしょう。
スクロールが未だ動作しないのであれば、加えて `-S` オプションを追加してみてください。
## 設定ファイル
`bat` は設定ファイルでカスタマイズすることが可能です。ファイルの場所はOSに依存します。使用しているOSのデフォルトパスを調べるには以下のコマンドを実行してください:
```
bat --config-file
```
また、環境変数 `BAT_CONFIG_PATH` に設定ファイルの場所を明記することもできます:
```bash
export BAT_CONFIG_PATH="/path/to/bat.conf"
```
### フォーマット
この設定ファイルはコマンドライン引数の単純なリストです。 `bat --help` を利用すると、利用可能なオプションとその値を閲覧することができます。さらに、`#` でコメント文を加えることができます。
設定ファイルの例:
```bash
# Set the theme to "TwoDark"
--theme="TwoDark"
# Show line numbers, Git modifications and file header (but no grid)
--style="numbers,changes,header"
# Use italic text on the terminal (not supported on all terminals)
--italic-text=always
# Add mouse scrolling support in less (does not work with older
# versions of "less")
--pager="less -FR"
# Use C++ syntax (instead of C) for .h header files
--map-syntax h:cpp
# Use "gitignore" highlighting for ".ignore" files
--map-syntax .ignore:.gitignore
```
## Windows での `bat` の利用
Windows 上で `bat` はほとんど動作しますが、いくつかの機能は設定を必要をする場合があります。
### ページング
Windows only includes a very limited pager in the form of `more`. You can download a Windows binary
for `less` [from its homepage](http://www.greenwoodsoftware.com/less/download.html) or [through
Chocolatey](https://chocolatey.org/packages/Less). To use it, place the binary in a directory in
your `PATH` or [define an environment variable](#using-a-different-pager).
### 色
Windows 10 は[v1151](https://en.wikipedia.org/wiki/Windows_10_version_history#Version_1511_(November_Update))からbashの新しいバージョンと同様に `conhost.exe`(コマンドプロンプト)と PowerShell の色をネイティブサポートしていません。Windows の新しいバージョンでは、[Cmder](http://cmder.net/)を使うことができます。これは[ConEmu](https://conemu.github.io/)を含んでいます。
**注意:** Git と MSYS の `less` はWindows上で色を正しく解釈しません。もし、あなたが他のページャーをインストールしていないのであれば、 `--paging=never` オプションを付け加えるまたは `BAT_PAGER` に空文字を設定することでページングを完全に無効にできます。
### Cygwin
Windows上の `bat` は Cygwin のunix風のpath(`/cygdrive/*`)をネイティブサポートしていません。
絶対的なcygwinパスを引数として受けたときに、 `bat` は以下のエラーを返すでしょう: `The system cannot find the path specified. (os error 3)`
wrapperを作成するまたは以下の関数を `.bash_profile` に追記することでこの問題を解決することができます:
```shell
bat() {
local index
local args=("$@")
for index in $(seq 0 ${#args[@]}) ; do
case "${args[index]}" in
-*) continue;;
*) [ -e "${args[index]}" ] && args[index]="$(cygpath --windows "${args[index]}")";;
esac
done
command bat "${args[@]}"
}
```
## トラブルシューティング
### ターミナルと色
`bat` はターミナルがトゥルーカラーをサポートしている/していない関係なくサポートします。しかし、シンタックスハイライトのテーマの色が8-bitカラーに最適化されていない場合、24-bitであるトゥルーカラーをサポートしているターミナルを使用することを強く推奨します(`terminator`, `konsole`, `iTerm2`, ...)。
この[記事](https://gist.github.com/XVilka/8346728)には24-bitカラーがサポートされているターミナルの一覧が掲載されています。
本当の色をターミナルにセットするために、環境変数 `COLORTERM` に `truecolor` か `24bit` のどちらかを代入してください。さもなければ、 `bat` はどの色を使うのか決定することができません。または、24-bit エスケープシーケンスがサポートされません(そして、8-bit colorに戻ります)。
### 行番号とグリッド線がほとんど見えない
異なるテーマを試してみてください(`bat --list-themes` でテーマを閲覧できます)。 `OneHalfDark` と `OneHalfLight` テーマはグリッド線と線の色を明るくします。
## 開発
```bash
# Recursive clone to retrieve all submodules
git clone --recursive https://github.com/sharkdp/bat
# Build (debug version)
cd bat
cargo build
# Run unit tests and integration tests
cargo test
# Install (release version)
cargo install
# Build a bat binary with modified syntaxes and themes
bash assets/create.sh
cargo install -f
```
## プロジェクトの目標と既存の類似したOSS
`bat` は以下の目標を達成しようと試みています:
- 美しい高度なシンタックスハイライトの提供
- ファイルの差分を表示するためのGitとの連携
- (POSIX) `cat` との完全互換
- ユーザーフレンドリーがコマンドラインインターフェースの提供
既存の類似したOSSはたくさんあります。
`bat` とこれらを比較した表が[こちら](alternatives.md)にあります。
+2 -1
View File
@@ -9,7 +9,7 @@ if you are not looking for a program like `bat`, this comparison might not be fo
| Drop-in `cat` replacement | :heavy_check_mark: [*](https://github.com/sharkdp/bat/issues/134) | :x: | :x: | (:heavy_check_mark:) | :x: | :x: [*](https://github.com/rstacruz/hicat/issues/6) | :x: | :x: | | Drop-in `cat` replacement | :heavy_check_mark: [*](https://github.com/sharkdp/bat/issues/134) | :x: | :x: | (:heavy_check_mark:) | :x: | :x: [*](https://github.com/rstacruz/hicat/issues/6) | :x: | :x: |
| Git integration | :heavy_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | | Git integration | :heavy_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :x: |
| Automatic paging | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: | :x: | :x: | | Automatic paging | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: | :x: | :x: |
| Languages (circa) | 100 | 300 | 200 | 7 | 80 | 130 | 30 | 130 | | Languages (circa) | 110 | 300 | 200 | 7 | 80 | 130 | 30 | 130 |
| Extensible (languages, themes) | :heavy_check_mark: | (:heavy_check_mark:) | (:heavy_check_mark:) | :x: | (:heavy_check_mark:) | :x: | :x: | :x: | | Extensible (languages, themes) | :heavy_check_mark: | (:heavy_check_mark:) | (:heavy_check_mark:) | :x: | (:heavy_check_mark:) | :x: | :x: | :x: |
| Advanced highlighting (e.g. nested syntaxes) | :heavy_check_mark: | :heavy_check_mark: | (:heavy_check_mark:) ? | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | Advanced highlighting (e.g. nested syntaxes) | :heavy_check_mark: | :heavy_check_mark: | (:heavy_check_mark:) ? | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Execution time [ms] (`jquery-3.3.1.js`) | 624 | 789 | 400 | 80 | 300 | 316 | 157 | 695 | | Execution time [ms] (`jquery-3.3.1.js`) | 624 | 789 | 400 | 80 | 300 | 316 | 157 | 695 |
@@ -21,3 +21,4 @@ request.
Some other alternatives that are also related, but not yet included in the table: Some other alternatives that are also related, but not yet included in the table:
- [lesspipe](https://github.com/wofr06/lesspipe) - [lesspipe](https://github.com/wofr06/lesspipe)
- [vimpager](https://github.com/rkitover/vimpager)
+64 -42
View File
@@ -10,27 +10,35 @@ bat [OPTIONS] [FILE]...
bat <SUBCOMMAND> bat <SUBCOMMAND>
.SH "OPTIONS" .SH "OPTIONS"
.HP .HP
General remarks
.IP
Command-line options like '-l'/'--language' that take values can be specified as
either '--language value', '--language=value', '-l value' or '-lvalue'.
.HP
\fB\-l\fR, \fB\-\-language\fR <language> \fB\-l\fR, \fB\-\-language\fR <language>
.IP .IP
Explicitly set the language for syntax highlighting. The language can be specified as a Explicitly set the language for syntax highlighting. The language can be
name (like 'C++' or 'LaTeX') or possible file extension (like 'cpp', 'hpp' or 'md'). Use specified as a name (like 'C++' or 'LaTeX') or possible file extension
\&'\-\-list\-languages' to show all supported language names and file extensions. (like 'cpp', 'hpp' or 'md'). Use '\-\-list\-languages' to show all supported
language names and file extensions.
.HP .HP
\fB\-\-list\-languages\fR \fB\-L\fR, \fB\-\-list\-languages\fR
.IP .IP
Display a list of supported languages for syntax highlighting. Display a list of supported languages for syntax highlighting.
.HP .HP
\fB\-m\fR, \fB\-\-map\-syntax\fR <from:to>... \fB\-m\fR, \fB\-\-map\-syntax\fR <from:to>...
.IP .IP
Map a file extension or file name to an existing syntax. For example, to highlight Map a file extension or file name to an existing syntax. For example, to
*.conf files with the INI syntax, use '\-m conf:ini'. To highlight files named highlight *.conf files with the INI syntax, use '\-m conf:ini'. To
\&'.myignore' with the Git Ignore syntax, use '\-m .myignore:gitignore'. highlight files named '.myignore' with the Git Ignore syntax, use '\-m
\&.myignore:gitignore'.
.HP .HP
\fB\-\-theme\fR <theme> \fB\-\-theme\fR <theme>
.IP .IP
Set the theme for syntax highlighting. Use '\-\-list\-themes' to see all available themes. Set the theme for syntax highlighting. Use '\-\-list\-themes' to see all
To set a default theme, add the '\-\-theme="..."' option to the configuration file or available themes. To set a default theme, add the '\-\-theme="..."' option
export the BAT_THEME environment variable (e.g.: export BAT_THEME="..."). to the configuration file or export the BAT_THEME environment variable
(e.g.: export BAT_THEME="...").
.HP .HP
\fB\-\-list\-themes\fR \fB\-\-list\-themes\fR
.IP .IP
@@ -38,27 +46,31 @@ Display a list of supported themes for syntax highlighting.
.HP .HP
\fB\-\-style\fR <style\-components> \fB\-\-style\fR <style\-components>
.IP .IP
Configure which elements (line numbers, file headers, grid borders, Git modifications, Configure which elements (line numbers, file headers, grid borders, Git
\&..) to display in addition to the file contents. The argument is a comma\-separated list modifications, ..) to display in addition to the file contents. The
of components to display (e.g. 'numbers,changes,grid') or a pre\-defined style ('full'). argument is a comma\-separated list of components to display (e.g.
To set a default style, add the '\-\-style=".."' option to the configuration file or \&'numbers,changes,grid') or a pre\-defined style ('full'). To set a default
export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible style, add the '\-\-style=".."' option to the configuration file or export
values: *auto*, full, plain, changes, header, grid, numbers. the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible
values: *auto*, full, plain, changes, header, grid, numbers, snip.
.HP .HP
\fB\-p\fR, \fB\-\-plain\fR \fB\-p\fR, \fB\-\-plain\fR
.IP .IP
Only show plain style, no decorations. This is an alias for '\-\-style=plain' Only show plain style, no decorations. This is an alias for
\&'\-\-style=plain'. When '\-p' is used twice ('\-pp'), it also disables
automatic paging (alias for '\-\-style=plain \fB\-\-pager\fR=\fI\,never\/\fR').
.HP .HP
\fB\-n\fR, \fB\-\-number\fR \fB\-n\fR, \fB\-\-number\fR
.IP .IP
Only show line numbers, no other decorations. This is an alias for '\-\-style=numbers' Only show line numbers, no other decorations. This is an alias for
\&'\-\-style=numbers'
.HP .HP
\fB\-A\fR, \fB\-\-show\-all\fR \fB\-A\fR, \fB\-\-show\-all\fR
.IP .IP
Show non\-printable characters like space, tab or newline. Use '\-\-tabs' to control the Show non\-printable characters like space, tab or newline. Use '\-\-tabs' to
width of the tab\-placeholders. control the width of the tab\-placeholders.
.HP .HP
\fB\-\-line\-range\fR <N:M>... \fB\-r\fR, \fB\-\-line\-range\fR <N:M>...
.IP .IP
Only print the specified range of lines for each file. For example: Only print the specified range of lines for each file. For example:
.RS .RS
@@ -70,53 +82,63 @@ prints lines 1 to 40
prints lines 40 to the end of the file prints lines 40 to the end of the file
.RE .RE
.HP .HP
\fB\-H\fR, \fB\-\-highlight\-line\fR <N>...
.IP
Highlight the N\-th line with a different background color
.HP
\fB\-\-color\fR <when> \fB\-\-color\fR <when>
.IP .IP
Specify when to use colored output. The automatic mode only enables colors if an Specify when to use colored output. The automatic mode only enables colors
interactive terminal is detected. Possible values: *auto*, never, always. if an interactive terminal is detected. Possible values: *auto*, never,
always.
.HP .HP
\fB\-\-italic\-text\fR <when> \fB\-\-italic\-text\fR <when>
.IP .IP
Specify when to use ANSI sequences for italic text in the output. Possible values: Specify when to use ANSI sequences for italic text in the output. Possible
always, *never*. values: always, *never*.
.HP .HP
\fB\-\-decorations\fR <when> \fB\-\-decorations\fR <when>
.IP .IP
Specify when to use the decorations that have been specified via '\-\-style'. The Specify when to use the decorations that have been specified via
automatic mode only enables decorations if an interactive terminal is detected. Possible \&'\-\-style'. The automatic mode only enables decorations if an interactive
values: *auto*, never, always. terminal is detected. Possible values: *auto*, never, always.
.HP .HP
\fB\-\-paging\fR <when> \fB\-\-paging\fR <when>
.IP .IP
Specify when to use the pager. To control which pager is used, set the PAGER or Specify when to use the pager. To control which pager is used, set the
BAT_PAGER environment variables (the latter takes precedence) or use the '\-\-pager' PAGER or BAT_PAGER environment variables (the latter takes precedence) or
option. To disable the pager permanently, set BAT_PAGER to an empty string or set use the '\-\-pager' option. To disable the pager permanently, set BAT_PAGER
\&'\-\-paging=never' in the configuration file. Possible values: *auto*, never, always. to an empty string or set '\-\-paging=never' in the configuration file.
Possible values: *auto*, never, always.
.HP .HP
\fB\-\-pager\fR <command> \fB\-\-pager\fR <command>
.IP .IP
Determine which pager is used. This option will overwrite the PAGER and BAT_PAGER Determine which pager is used. This option will overwrite the PAGER and
environment variables. The default pager is 'less'. To disable the pager completely, use BAT_PAGER environment variables. The default pager is 'less'. To disable
the '\-\-paging' option. Example: '\-\-pager "less \fB\-RF\fR"'. the pager completely, use the '\-\-paging' option. Example: '\-\-pager "less
\fB\-RF\fR"'.
.HP .HP
\fB\-\-wrap\fR <mode> \fB\-\-wrap\fR <mode>
.IP .IP
Specify the text\-wrapping mode (*auto*, never, character). Specify the text\-wrapping mode (*auto*, never, character). The
\&'\-\-terminal\-width' option can be used in addition to control the output
width.
.HP .HP
\fB\-\-tabs\fR <T> \fB\-\-tabs\fR <T>
.IP .IP
Set the tab width to T spaces. Use a width of 0 to pass tabs through directly Set the tab width to T spaces. Use a width of 0 to pass tabs through
directly
.HP .HP
\fB\-u\fR, \fB\-\-unbuffered\fR \fB\-u\fR, \fB\-\-unbuffered\fR
.IP .IP
This option exists for POSIX\-compliance reasons ('u' is for 'unbuffered'). The output is This option exists for POSIX\-compliance reasons ('u' is for 'unbuffered').
always unbuffered \- this option is simply ignored. The output is always unbuffered \- this option is simply ignored.
.HP .HP
\fB\-\-terminal\-width\fR <width> \fB\-\-terminal\-width\fR <width>
.IP .IP
Explicitly set the width of the terminal instead of determining it automatically. If Explicitly set the width of the terminal instead of determining it
prefixed with '+' or '\-', the value will be treated as an offset to the actual terminal automatically. If prefixed with '+' or '\-', the value will be treated as
width. an offset to the actual terminal width. See also: '\-\-wrap'.
.HP .HP
\fB\-h\fR, \fB\-\-help\fR \fB\-h\fR, \fB\-\-help\fR
.IP .IP
+35 -25
View File
@@ -4,8 +4,8 @@ use std::str::FromStr;
use atty::{self, Stream}; use atty::{self, Stream};
use crate::clap_app;
use clap::ArgMatches; use clap::ArgMatches;
use clap_app;
use wild; use wild;
use console::Term; use console::Term;
@@ -13,14 +13,14 @@ use console::Term;
#[cfg(windows)] #[cfg(windows)]
use ansi_term; use ansi_term;
use assets::BAT_THEME_DEFAULT; use crate::assets::BAT_THEME_DEFAULT;
use config::{get_args_from_config_file, get_args_from_env_var}; use crate::config::{get_args_from_config_file, get_args_from_env_var};
use errors::*; use crate::errors::*;
use inputfile::InputFile; use crate::inputfile::InputFile;
use line_range::{LineRange, LineRanges}; use crate::line_range::{LineRange, LineRanges};
use style::{OutputComponent, OutputComponents, OutputWrap}; use crate::style::{OutputComponent, OutputComponents, OutputWrap};
use syntax_mapping::SyntaxMapping; use crate::syntax_mapping::SyntaxMapping;
use util::transpose; use crate::util::transpose;
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub enum PagingMode { pub enum PagingMode {
@@ -77,7 +77,11 @@ pub struct Config<'a> {
/// Command to start the pager /// Command to start the pager
pub pager: Option<&'a str>, pub pager: Option<&'a str>,
/// Whether or not to use ANSI italics
pub use_italic_text: bool, pub use_italic_text: bool,
/// Lines to highlight
pub highlight_lines: Vec<usize>,
} }
fn is_truecolor_terminal() -> bool { fn is_truecolor_terminal() -> bool {
@@ -116,7 +120,7 @@ impl App {
// Read arguments from bats config file // Read arguments from bats config file
let mut args = get_args_from_env_var() let mut args = get_args_from_env_var()
.unwrap_or_else(|| get_args_from_config_file()) .unwrap_or_else(get_args_from_config_file)
.chain_err(|| "Could not parse configuration file")?; .chain_err(|| "Could not parse configuration file")?;
// Put the zero-th CLI argument (program name) first // Put the zero-th CLI argument (program name) first
@@ -139,7 +143,10 @@ impl App {
Some("always") => PagingMode::Always, Some("always") => PagingMode::Always,
Some("never") => PagingMode::Never, Some("never") => PagingMode::Never,
Some("auto") | _ => { Some("auto") | _ => {
if files.contains(&InputFile::StdIn) { if self.matches.occurrences_of("plain") > 1 {
// If we have -pp as an option when in auto mode, the pager should be disabled.
PagingMode::Never
} else if files.contains(&InputFile::StdIn) {
// If we are reading from stdin, only enable paging if we write to an // If we are reading from stdin, only enable paging if we write to an
// interactive terminal and if we do not *read* from an interactive // interactive terminal and if we do not *read* from an interactive
// terminal. // terminal.
@@ -148,12 +155,10 @@ impl App {
} else { } else {
PagingMode::Never PagingMode::Never
} }
} else if self.interactive_output {
PagingMode::QuitIfOneScreen
} else { } else {
if self.interactive_output { PagingMode::Never
PagingMode::QuitIfOneScreen
} else {
PagingMode::Never
}
} }
} }
}; };
@@ -162,13 +167,13 @@ impl App {
if let Some(values) = self.matches.values_of("map-syntax") { if let Some(values) = self.matches.values_of("map-syntax") {
for from_to in values { for from_to in values {
let parts: Vec<_> = from_to.split(":").collect(); let parts: Vec<_> = from_to.split(':').collect();
if parts.len() != 2 { if parts.len() != 2 {
return Err("Invalid syntax mapping. The format of the -m/--map-syntax option is 'from:to'.".into()); return Err("Invalid syntax mapping. The format of the -m/--map-syntax option is 'from:to'.".into());
} }
syntax_mapping.insert(parts[0].into(), parts[1].into()); syntax_mapping.insert(parts[0], parts[1]);
} }
} }
@@ -209,11 +214,11 @@ impl App {
.matches .matches
.value_of("terminal-width") .value_of("terminal-width")
.and_then(|w| { .and_then(|w| {
if w.starts_with("+") || w.starts_with("-") { if w.starts_with('+') || w.starts_with('-') {
// Treat argument as a delta to the current terminal width // Treat argument as a delta to the current terminal width
w.parse().ok().map(|delta: i16| { w.parse().ok().map(|delta: i16| {
let old_width: u16 = Term::stdout().size().1; let old_width: u16 = Term::stdout().size().1;
let new_width: i32 = old_width as i32 + delta as i32; let new_width: i32 = i32::from(old_width) + i32::from(delta);
if new_width <= 0 { if new_width <= 0 {
old_width as usize old_width as usize
@@ -248,14 +253,14 @@ impl App {
.value_of("theme") .value_of("theme")
.map(String::from) .map(String::from)
.or_else(|| env::var("BAT_THEME").ok()) .or_else(|| env::var("BAT_THEME").ok())
.unwrap_or(String::from(BAT_THEME_DEFAULT)), .unwrap_or_else(|| String::from(BAT_THEME_DEFAULT)),
line_ranges: LineRanges::from( line_ranges: LineRanges::from(
transpose( transpose(
self.matches self.matches
.values_of("line-range") .values_of("line-range")
.map(|vs| vs.map(LineRange::from).collect()), .map(|vs| vs.map(LineRange::from).collect()),
)? )?
.unwrap_or(vec![]), .unwrap_or_else(|| vec![]),
), ),
output_components, output_components,
syntax_mapping, syntax_mapping,
@@ -264,6 +269,11 @@ impl App {
Some("always") => true, Some("always") => true,
_ => false, _ => false,
}, },
highlight_lines: self
.matches
.values_of("highlight-line")
.and_then(|ws| ws.map(|w| w.parse().ok()).collect())
.unwrap_or_default(),
}) })
} }
@@ -297,7 +307,7 @@ impl App {
let env_style_components: Option<Vec<OutputComponent>> = let env_style_components: Option<Vec<OutputComponent>> =
transpose(env::var("BAT_STYLE").ok().map(|style_str| { transpose(env::var("BAT_STYLE").ok().map(|style_str| {
style_str style_str
.split(",") .split(',')
.map(|x| OutputComponent::from_str(&x)) .map(|x| OutputComponent::from_str(&x))
.collect::<Result<Vec<OutputComponent>>>() .collect::<Result<Vec<OutputComponent>>>()
}))?; }))?;
@@ -306,13 +316,13 @@ impl App {
.value_of("style") .value_of("style")
.map(|styles| { .map(|styles| {
styles styles
.split(",") .split(',')
.map(|style| style.parse::<OutputComponent>()) .map(|style| style.parse::<OutputComponent>())
.filter_map(|style| style.ok()) .filter_map(|style| style.ok())
.collect::<Vec<_>>() .collect::<Vec<_>>()
}) })
.or(env_style_components) .or(env_style_components)
.unwrap_or(vec![OutputComponent::Full]) .unwrap_or_else(|| vec![OutputComponent::Full])
.into_iter() .into_iter()
.map(|style| style.components(self.interactive_output)) .map(|style| style.components(self.interactive_output))
.fold(HashSet::new(), |mut acc, components| { .fold(HashSet::new(), |mut acc, components| {
+12 -8
View File
@@ -8,11 +8,11 @@ use syntect::dumps::{dump_to_file, from_binary, from_reader};
use syntect::highlighting::{Theme, ThemeSet}; use syntect::highlighting::{Theme, ThemeSet};
use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder}; use syntect::parsing::{SyntaxReference, SyntaxSet, SyntaxSetBuilder};
use dirs::PROJECT_DIRS; use crate::dirs::PROJECT_DIRS;
use errors::*; use crate::errors::*;
use inputfile::{InputFile, InputFileReader}; use crate::inputfile::{InputFile, InputFileReader};
use syntax_mapping::SyntaxMapping; use crate::syntax_mapping::SyntaxMapping;
pub const BAT_THEME_DEFAULT: &str = "Monokai Extended"; pub const BAT_THEME_DEFAULT: &str = "Monokai Extended";
@@ -40,7 +40,7 @@ impl HighlightingAssets {
let theme_dir = source_dir.join("themes"); let theme_dir = source_dir.join("themes");
let res = theme_set.add_from_folder(&theme_dir); let res = theme_set.add_from_folder(&theme_dir);
if !res.is_ok() { if res.is_err() {
println!( println!(
"No themes were found in '{}', using the default set", "No themes were found in '{}', using the default set",
theme_dir.to_string_lossy() theme_dir.to_string_lossy()
@@ -117,7 +117,7 @@ impl HighlightingAssets {
pub fn save(&self, dir: Option<&Path>) -> Result<()> { pub fn save(&self, dir: Option<&Path>) -> Result<()> {
let target_dir = dir.unwrap_or_else(|| PROJECT_DIRS.cache_dir()); let target_dir = dir.unwrap_or_else(|| PROJECT_DIRS.cache_dir());
let _ = fs::create_dir(target_dir); let _ = fs::create_dir_all(target_dir);
let theme_set_path = target_dir.join("themes.bin"); let theme_set_path = target_dir.join("themes.bin");
let syntax_set_path = target_dir.join("syntaxes.bin"); let syntax_set_path = target_dir.join("syntaxes.bin");
@@ -191,8 +191,8 @@ impl HighlightingAssets {
} else { } else {
None None
}; };
let syntax = ext_syntax.or(line_syntax);
syntax ext_syntax.or(line_syntax)
} }
(None, InputFile::StdIn) => String::from_utf8(reader.first_line.clone()) (None, InputFile::StdIn) => String::from_utf8(reader.first_line.clone())
.ok() .ok()
@@ -216,6 +216,10 @@ pub fn config_dir() -> Cow<'static, str> {
PROJECT_DIRS.config_dir().to_string_lossy() PROJECT_DIRS.config_dir().to_string_lossy()
} }
pub fn cache_dir() -> Cow<'static, str> {
PROJECT_DIRS.cache_dir().to_string_lossy()
}
pub fn clear_assets() { pub fn clear_assets() {
print!("Clearing theme set cache ... "); print!("Clearing theme set cache ... ");
fs::remove_file(theme_set_path()).ok(); fs::remove_file(theme_set_path()).ok();
+64 -25
View File
@@ -18,8 +18,8 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.global_setting(AppSettings::DeriveDisplayOrder) .global_setting(AppSettings::DeriveDisplayOrder)
.global_setting(AppSettings::UnifiedHelpMessage) .global_setting(AppSettings::UnifiedHelpMessage)
.global_setting(AppSettings::HidePossibleValuesInHelp) .global_setting(AppSettings::HidePossibleValuesInHelp)
.setting(AppSettings::InferSubcommands)
.setting(AppSettings::ArgsNegateSubcommands) .setting(AppSettings::ArgsNegateSubcommands)
.setting(AppSettings::AllowExternalSubcommands)
.setting(AppSettings::DisableHelpSubcommand) .setting(AppSettings::DisableHelpSubcommand)
.setting(AppSettings::VersionlessSubcommands) .setting(AppSettings::VersionlessSubcommands)
.max_term_width(100) .max_term_width(100)
@@ -55,6 +55,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.arg( .arg(
Arg::with_name("list-languages") Arg::with_name("list-languages")
.long("list-languages") .long("list-languages")
.short("L")
.conflicts_with("list-themes") .conflicts_with("list-themes")
.help("Display all supported languages.") .help("Display all supported languages.")
.long_help("Display a list of supported languages for syntax highlighting."), .long_help("Display a list of supported languages for syntax highlighting."),
@@ -109,9 +110,9 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.overrides_with("number") .overrides_with("number")
// Cannot use clap's built in validation because we have to turn off clap's delimiters // Cannot use clap's built in validation because we have to turn off clap's delimiters
.validator(|val| { .validator(|val| {
let mut invalid_vals = val.split(",").filter(|style| { let mut invalid_vals = val.split(',').filter(|style| {
!&[ !&[
"auto", "full", "plain", "changes", "header", "grid", "numbers", "auto", "full", "plain", "changes", "header", "grid", "numbers", "snip"
] ]
.contains(style) .contains(style)
}); });
@@ -124,7 +125,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
}) })
.help( .help(
"Comma-separated list of style elements to display \ "Comma-separated list of style elements to display \
(*auto*, full, plain, changes, header, grid, numbers).", (*auto*, full, plain, changes, header, grid, numbers, snip).",
) )
.long_help( .long_help(
"Configure which elements (line numbers, file headers, grid \ "Configure which elements (line numbers, file headers, grid \
@@ -134,7 +135,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
pre-defined style ('full'). To set a default style, add the \ pre-defined style ('full'). To set a default style, add the \
'--style=\"..\"' option to the configuration file or export the \ '--style=\"..\"' option to the configuration file or export the \
BAT_STYLE environment variable (e.g.: export BAT_STYLE=\"..\"). \ BAT_STYLE environment variable (e.g.: export BAT_STYLE=\"..\"). \
Possible values: *auto*, full, plain, changes, header, grid, numbers.", Possible values: *auto*, full, plain, changes, header, grid, numbers, snip.",
), ),
) )
.arg( .arg(
@@ -143,10 +144,12 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.overrides_with("number") .overrides_with("number")
.short("p") .short("p")
.long("plain") .long("plain")
.multiple(true)
.help("Show plain style (alias for '--style=plain').") .help("Show plain style (alias for '--style=plain').")
.long_help( .long_help(
"Only show plain style, no decorations. This is an alias for \ "Only show plain style, no decorations. This is an alias for \
'--style=plain'", '--style=plain'. When '-p' is used twice ('-pp'), it also disables \
automatic paging (alias for '--style=plain --pager=never').",
), ),
) )
.arg( .arg(
@@ -169,12 +172,14 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.help("Show non-printable characters (space, tab, newline, ..).") .help("Show non-printable characters (space, tab, newline, ..).")
.long_help( .long_help(
"Show non-printable characters like space, tab or newline. \ "Show non-printable characters like space, tab or newline. \
Use '--tabs' to control the width of the tab-placeholders.", This option can also be used to print binary files. \
Use '--tabs' to control the width of the tab-placeholders."
), ),
) )
.arg( .arg(
Arg::with_name("line-range") Arg::with_name("line-range")
.long("line-range") .long("line-range")
.short("r")
.multiple(true) .multiple(true)
.takes_value(true) .takes_value(true)
.number_of_values(1) .number_of_values(1)
@@ -188,6 +193,19 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
'--line-range 40:' prints lines 40 to the end of the file", '--line-range 40:' prints lines 40 to the end of the file",
), ),
) )
.arg(
Arg::with_name("highlight-line")
.long("highlight-line")
.short("H")
.takes_value(true)
.number_of_values(1)
.multiple(true)
.value_name("N")
.help("Highlight the given line.")
.long_help(
"Highlight the N-th line with a different background color",
),
)
.arg( .arg(
Arg::with_name("color") Arg::with_name("color")
.long("color") .long("color")
@@ -276,7 +294,9 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.default_value("auto") .default_value("auto")
.hide_default_value(true) .hide_default_value(true)
.help("Specify the text-wrapping mode (*auto*, never, character).") .help("Specify the text-wrapping mode (*auto*, never, character).")
.long_help("Specify the text-wrapping mode (*auto*, never, character)."), .long_help("Specify the text-wrapping mode (*auto*, never, character). \
The '--terminal-width' option can be used in addition to \
control the output width."),
) )
.arg( .arg(
Arg::with_name("tabs") Arg::with_name("tabs")
@@ -315,10 +335,23 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.takes_value(true) .takes_value(true)
.value_name("width") .value_name("width")
.hidden_short_help(true) .hidden_short_help(true)
.allow_hyphen_values(true)
.validator(
|t| {
let is_offset = t.starts_with('+') || t.starts_with('-');
t.parse::<i32>()
.map_err(|_e| "must be an offset or number")
.and_then(|v| if v == 0 && !is_offset {
Err("terminal width cannot be zero".into())
} else {
Ok(())
})
.map_err(|e| e.to_string())
})
.help( .help(
"Explicitly set the width of the terminal instead of determining it \ "Explicitly set the width of the terminal instead of determining it \
automatically. If prefixed with '+' or '-', the value will be treated \ automatically. If prefixed with '+' or '-', the value will be treated \
as an offset to the actual terminal width.", as an offset to the actual terminal width. See also: '--wrap'.",
), ),
) )
.arg( .arg(
@@ -335,17 +368,29 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.hidden(true) .hidden(true)
.help("Show path to the configuration file."), .help("Show path to the configuration file."),
) )
.arg(
Arg::with_name("config-dir")
.long("config-dir")
.hidden(true)
.help("Show bat's configuration directory."),
)
.arg(
Arg::with_name("cache-dir")
.long("cache-dir")
.hidden(true)
.help("Show bat's cache directory."),
)
.subcommand( .subcommand(
SubCommand::with_name("cache") SubCommand::with_name("cache")
.about("Modify the syntax-definition and theme cache") .about("Modify the syntax-definition and theme cache")
.arg( .arg(
Arg::with_name("init") Arg::with_name("build")
.long("init") .long("build")
.short("i") .short("b")
.help("Initialize the syntax/theme cache.") .help("Initialize (or update) the syntax/theme cache.")
.long_help( .long_help(
"Initialize the syntax/theme cache by loading from the \ "Initialize (or update) the syntax/theme cache by loading from \
source directory (default: the configuration directory).", the source directory (default: the configuration directory).",
), ),
) )
.arg( .arg(
@@ -354,21 +399,15 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.short("c") .short("c")
.help("Remove the cached syntax definitions and themes."), .help("Remove the cached syntax definitions and themes."),
) )
.arg(
Arg::with_name("config-dir")
.long("config-dir")
.short("d")
.help("Show bat's configuration directory."),
)
.group( .group(
ArgGroup::with_name("cache-actions") ArgGroup::with_name("cache-actions")
.args(&["init", "clear", "config-dir"]) .args(&["build", "clear"])
.required(arg_group_required), .required(arg_group_required),
) )
.arg( .arg(
Arg::with_name("source") Arg::with_name("source")
.long("source") .long("source")
.requires("init") .requires("build")
.takes_value(true) .takes_value(true)
.value_name("dir") .value_name("dir")
.help("Use a different directory to load syntaxes and themes from."), .help("Use a different directory to load syntaxes and themes from."),
@@ -376,14 +415,14 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.arg( .arg(
Arg::with_name("target") Arg::with_name("target")
.long("target") .long("target")
.requires("init") .requires("build")
.takes_value(true) .takes_value(true)
.value_name("dir") .value_name("dir")
.help( .help(
"Use a different directory to store the cached syntax and theme set.", "Use a different directory to store the cached syntax and theme set.",
), ),
) )
.arg(Arg::with_name("blank").long("blank").requires("init").help( .arg(Arg::with_name("blank").long("blank").requires("build").help(
"Create completely new syntax and theme sets \ "Create completely new syntax and theme sets \
(instead of appending to the default sets).", (instead of appending to the default sets).",
)), )),
+6 -6
View File
@@ -5,15 +5,15 @@ use std::path::PathBuf;
use shell_words; use shell_words;
use dirs::PROJECT_DIRS; use crate::dirs::PROJECT_DIRS;
use util::transpose; use crate::util::transpose;
pub fn config_file() -> PathBuf { pub fn config_file() -> PathBuf {
env::var("BAT_CONFIG_PATH") env::var("BAT_CONFIG_PATH")
.ok() .ok()
.map(PathBuf::from) .map(PathBuf::from)
.filter(|config_path| config_path.is_file()) .filter(|config_path| config_path.is_file())
.unwrap_or(PROJECT_DIRS.config_dir().join("config")) .unwrap_or_else(|| PROJECT_DIRS.config_dir().join("config"))
} }
pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseError> { pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseError> {
@@ -22,19 +22,19 @@ pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseEr
.ok() .ok()
.map(|content| get_args_from_str(&content)), .map(|content| get_args_from_str(&content)),
)? )?
.unwrap_or(vec![])) .unwrap_or_else(|| vec![]))
} }
pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> { pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> {
env::var("BAT_OPTS").ok().map(|s| get_args_from_str(&s)) env::var("BAT_OPTS").ok().map(|s| get_args_from_str(&s))
} }
fn get_args_from_str<'a>(content: &'a str) -> Result<Vec<OsString>, shell_words::ParseError> { fn get_args_from_str(content: &str) -> Result<Vec<OsString>, shell_words::ParseError> {
let args_per_line = content let args_per_line = content
.split('\n') .split('\n')
.map(|line| line.trim()) .map(|line| line.trim())
.filter(|line| !line.is_empty()) .filter(|line| !line.is_empty())
.filter(|line| !line.starts_with("#")) .filter(|line| !line.starts_with('#'))
.map(|line| shell_words::split(line)) .map(|line| shell_words::split(line))
.collect::<Result<Vec<_>, _>>()?; .collect::<Result<Vec<_>, _>>()?;
+45 -12
View File
@@ -1,12 +1,13 @@
use std::io::{self, Write}; use std::io::{self, Write};
use std::path::Path;
use app::Config; use crate::app::{Config, PagingMode};
use assets::HighlightingAssets; use crate::assets::HighlightingAssets;
use errors::*; use crate::errors::*;
use inputfile::{InputFile, InputFileReader}; use crate::inputfile::{InputFile, InputFileReader};
use line_range::{LineRanges, RangeCheckResult}; use crate::line_range::{LineRanges, RangeCheckResult};
use output::OutputType; use crate::output::OutputType;
use printer::{InteractivePrinter, Printer, SimplePrinter}; use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
pub struct Controller<'a> { pub struct Controller<'a> {
config: &'a Config<'a>, config: &'a Config<'a>,
@@ -19,7 +20,22 @@ impl<'b> Controller<'b> {
} }
pub fn run(&self) -> Result<bool> { pub fn run(&self) -> Result<bool> {
let mut output_type = OutputType::from_mode(self.config.paging_mode, self.config.pager)?; // Do not launch the pager if NONE of the input files exist
let mut paging_mode = self.config.paging_mode;
if self.config.paging_mode != PagingMode::Never {
let call_pager = self.config.files.iter().any(|file| {
if let InputFile::Ordinary(path) = file {
return Path::new(path).exists();
} else {
return true;
}
});
if !call_pager {
paging_mode = PagingMode::Never;
}
}
let mut output_type = OutputType::from_mode(paging_mode, self.config.pager)?;
let writer = output_type.handle()?; let writer = output_type.handle()?;
let mut no_errors: bool = true; let mut no_errors: bool = true;
@@ -60,34 +76,51 @@ impl<'b> Controller<'b> {
&self, &self,
reader: InputFileReader, reader: InputFileReader,
printer: &mut P, printer: &mut P,
writer: &mut Write, writer: &mut dyn Write,
input_file: InputFile<'a>, input_file: InputFile<'a>,
) -> Result<()> { ) -> Result<()> {
printer.print_header(writer, input_file)?; printer.print_header(writer, input_file)?;
self.print_file_ranges(printer, writer, reader, &self.config.line_ranges)?; if !reader.first_line.is_empty() {
self.print_file_ranges(printer, writer, reader, &self.config.line_ranges)?;
}
printer.print_footer(writer)?; printer.print_footer(writer)?;
Ok(()) Ok(())
} }
fn print_file_ranges<'a, P: Printer>( fn print_file_ranges<P: Printer>(
&self, &self,
printer: &mut P, printer: &mut P,
writer: &mut Write, writer: &mut dyn Write,
mut reader: InputFileReader, mut reader: InputFileReader,
line_ranges: &LineRanges, line_ranges: &LineRanges,
) -> Result<()> { ) -> Result<()> {
let mut line_buffer = Vec::new(); let mut line_buffer = Vec::new();
let mut line_number: usize = 1; let mut line_number: usize = 1;
let mut first_range: bool = true;
let mut mid_range: bool = false;
while reader.read_line(&mut line_buffer)? { while reader.read_line(&mut line_buffer)? {
match line_ranges.check(line_number) { match line_ranges.check(line_number) {
RangeCheckResult::OutsideRange => { RangeCheckResult::OutsideRange => {
// Call the printer in case we need to call the syntax highlighter // Call the printer in case we need to call the syntax highlighter
// for this line. However, set `out_of_range` to `true`. // for this line. However, set `out_of_range` to `true`.
printer.print_line(true, writer, line_number, &line_buffer)?; printer.print_line(true, writer, line_number, &line_buffer)?;
mid_range = false;
} }
RangeCheckResult::InRange => { RangeCheckResult::InRange => {
if self.config.output_components.snip() {
if first_range {
first_range = false;
mid_range = true;
} else if !mid_range {
mid_range = true;
printer.print_snip(writer)?;
}
}
printer.print_line(false, writer, line_number, &line_buffer)?; printer.print_line(false, writer, line_number, &line_buffer)?;
} }
RangeCheckResult::AfterLastRange => { RangeCheckResult::AfterLastRange => {
+2 -2
View File
@@ -1,6 +1,6 @@
use crate::diff::LineChange;
use crate::printer::{Colors, InteractivePrinter};
use ansi_term::Style; use ansi_term::Style;
use diff::LineChange;
use printer::{Colors, InteractivePrinter};
#[derive(Clone)] #[derive(Clone)]
pub struct DecorationText { pub struct DecorationText {
+1 -1
View File
@@ -34,7 +34,7 @@ pub fn get_git_diff(filename: &str) -> Option<LineChanges> {
let mark_section = let mark_section =
|line_changes: &mut LineChanges, start: u32, end: i32, change: LineChange| { |line_changes: &mut LineChanges, start: u32, end: i32, change: LineChange| {
for line in start..(end + 1) as u32 { for line in start..=end as u32 {
line_changes.insert(line, change); line_changes.insert(line, change);
} }
}; };
+54 -3
View File
@@ -1,6 +1,57 @@
use directories::ProjectDirs; use crate::dirs_rs;
use std::path::{Path, PathBuf};
#[cfg(target_os = "macos")]
use std::env;
/// Wrapper for 'dirs' that treats MacOS more like Linux, by following the XDG specification.
/// This means that the `XDG_CACHE_HOME` and `XDG_CONFIG_HOME` environment variables are
/// checked first. The fallback directories are `~/.cache/bat` and `~/.config/bat`, respectively.
pub struct BatProjectDirs {
cache_dir: PathBuf,
config_dir: PathBuf,
}
impl BatProjectDirs {
fn new() -> Option<BatProjectDirs> {
#[cfg(target_os = "macos")]
let cache_dir_op = env::var_os("XDG_CACHE_HOME")
.map(PathBuf::from)
.filter(|p| p.is_absolute())
.or_else(|| dirs_rs::home_dir().map(|d| d.join(".cache")));
#[cfg(not(target_os = "macos"))]
let cache_dir_op = dirs_rs::cache_dir();
let cache_dir = cache_dir_op.map(|d| d.join("bat"))?;
#[cfg(target_os = "macos")]
let config_dir_op = env::var_os("XDG_CONFIG_HOME")
.map(PathBuf::from)
.filter(|p| p.is_absolute())
.or_else(|| dirs_rs::home_dir().map(|d| d.join(".config")));
#[cfg(not(target_os = "macos"))]
let config_dir_op = dirs_rs::config_dir();
let config_dir = config_dir_op.map(|d| d.join("bat"))?;
Some(BatProjectDirs {
cache_dir,
config_dir,
})
}
pub fn cache_dir(&self) -> &Path {
&self.cache_dir
}
pub fn config_dir(&self) -> &Path {
&self.config_dir
}
}
lazy_static! { lazy_static! {
pub static ref PROJECT_DIRS: ProjectDirs = pub static ref PROJECT_DIRS: BatProjectDirs =
ProjectDirs::from("", "", crate_name!()).expect("Could not get home directory"); BatProjectDirs::new().expect("Could not get home directory");
} }
+10 -6
View File
@@ -3,14 +3,14 @@ use std::io::{self, BufRead, BufReader};
use content_inspector::{self, ContentType}; use content_inspector::{self, ContentType};
use errors::*; use crate::errors::*;
const THEME_PREVIEW_FILE: &[u8] = include_bytes!("../assets/theme_preview.rs"); const THEME_PREVIEW_FILE: &[u8] = include_bytes!("../assets/theme_preview.rs");
pub struct InputFileReader<'a> { pub struct InputFileReader<'a> {
inner: Box<dyn BufRead + 'a>, inner: Box<dyn BufRead + 'a>,
pub first_line: Vec<u8>, pub first_line: Vec<u8>,
pub content_type: ContentType, pub content_type: Option<ContentType>,
} }
impl<'a> InputFileReader<'a> { impl<'a> InputFileReader<'a> {
@@ -18,9 +18,13 @@ impl<'a> InputFileReader<'a> {
let mut first_line = vec![]; let mut first_line = vec![];
reader.read_until(b'\n', &mut first_line).ok(); reader.read_until(b'\n', &mut first_line).ok();
let content_type = content_inspector::inspect(&first_line[..]); let content_type = if first_line.is_empty() {
None
} else {
Some(content_inspector::inspect(&first_line[..]))
};
if content_type == ContentType::UTF_16LE { if content_type == Some(ContentType::UTF_16LE) {
reader.read_until(0x00, &mut first_line).ok(); reader.read_until(0x00, &mut first_line).ok();
} }
@@ -35,7 +39,7 @@ impl<'a> InputFileReader<'a> {
if self.first_line.is_empty() { if self.first_line.is_empty() {
let res = self.inner.read_until(b'\n', buf).map(|size| size > 0)?; let res = self.inner.read_until(b'\n', buf).map(|size| size > 0)?;
if self.content_type == ContentType::UTF_16LE { if self.content_type == Some(ContentType::UTF_16LE) {
self.inner.read_until(0x00, buf).ok(); self.inner.read_until(0x00, buf).ok();
} }
@@ -59,7 +63,7 @@ impl<'a> InputFile<'a> {
match self { match self {
InputFile::StdIn => Ok(InputFileReader::new(stdin.lock())), InputFile::StdIn => Ok(InputFileReader::new(stdin.lock())),
InputFile::Ordinary(filename) => { InputFile::Ordinary(filename) => {
let file = File::open(filename)?; let file = File::open(filename).map_err(|e| format!("'{}': {}", filename, e))?;
if file.metadata()?.is_dir() { if file.metadata()?.is_dir() {
return Err(format!("'{}' is a directory.", filename).into()); return Err(format!("'{}' is a directory.", filename).into());
+5 -11
View File
@@ -1,4 +1,4 @@
use errors::*; use crate::errors::*;
#[derive(Clone)] #[derive(Clone)]
pub struct LineRange { pub struct LineRange {
@@ -109,18 +109,12 @@ impl LineRanges {
} }
pub fn check(&self, line: usize) -> RangeCheckResult { pub fn check(&self, line: usize) -> RangeCheckResult {
if self.ranges.is_empty() { if self.ranges.is_empty() | self.ranges.iter().any(|r| r.is_inside(line)) {
RangeCheckResult::InRange RangeCheckResult::InRange
} else if line < self.largest_upper_bound {
RangeCheckResult::OutsideRange
} else { } else {
if self.ranges.iter().any(|r| r.is_inside(line)) { RangeCheckResult::AfterLastRange
RangeCheckResult::InRange
} else {
if line < self.largest_upper_bound {
RangeCheckResult::OutsideRange
} else {
RangeCheckResult::AfterLastRange
}
}
} }
} }
} }
+62 -52
View File
@@ -14,7 +14,7 @@ extern crate ansi_term;
extern crate atty; extern crate atty;
extern crate console; extern crate console;
extern crate content_inspector; extern crate content_inspector;
extern crate directories; extern crate dirs as dirs_rs;
extern crate encoding; extern crate encoding;
extern crate git2; extern crate git2;
extern crate shell_words; extern crate shell_words;
@@ -48,12 +48,12 @@ use std::process;
use ansi_term::Colour::Green; use ansi_term::Colour::Green;
use ansi_term::Style; use ansi_term::Style;
use app::{App, Config}; use crate::app::{App, Config};
use assets::{clear_assets, config_dir, HighlightingAssets}; use crate::assets::{cache_dir, clear_assets, config_dir, HighlightingAssets};
use config::config_file; use crate::config::config_file;
use controller::Controller; use crate::controller::Controller;
use inputfile::InputFile; use crate::inputfile::InputFile;
use style::{OutputComponent, OutputComponents}; use crate::style::{OutputComponent, OutputComponents};
mod errors { mod errors {
error_chain! { error_chain! {
@@ -67,7 +67,7 @@ mod errors {
pub fn handle_error(error: &Error) { pub fn handle_error(error: &Error) {
match error { match error {
&Error(ErrorKind::Io(ref io_error), _) Error(ErrorKind::Io(ref io_error), _)
if io_error.kind() == super::io::ErrorKind::BrokenPipe => if io_error.kind() == super::io::ErrorKind::BrokenPipe =>
{ {
super::process::exit(0); super::process::exit(0);
@@ -80,10 +80,10 @@ mod errors {
} }
} }
use errors::*; use crate::errors::*;
fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> { fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
if matches.is_present("init") { if matches.is_present("build") {
let source_dir = matches.value_of("source").map(Path::new); let source_dir = matches.value_of("source").map(Path::new);
let target_dir = matches.value_of("target").map(Path::new); let target_dir = matches.value_of("target").map(Path::new);
@@ -93,8 +93,6 @@ fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
assets.save(target_dir)?; assets.save(target_dir)?;
} else if matches.is_present("clear") { } else if matches.is_present("clear") {
clear_assets(); clear_assets();
} else if matches.is_present("config-dir") {
writeln!(io::stdout(), "{}", config_dir())?;
} }
Ok(()) Ok(())
@@ -110,48 +108,54 @@ pub fn list_languages(config: &Config) -> Result<()> {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
languages.sort_by_key(|lang| lang.name.to_uppercase()); languages.sort_by_key(|lang| lang.name.to_uppercase());
let longest = languages
.iter()
.map(|syntax| syntax.name.len())
.max()
.unwrap_or(32); // Fallback width if they have no language definitions.
let comma_separator = ", ";
let separator = " ";
// Line-wrapping for the possible file extension overflow.
let desired_width = config.term_width - longest - separator.len();
let stdout = io::stdout(); let stdout = io::stdout();
let mut stdout = stdout.lock(); let mut stdout = stdout.lock();
let style = if config.colored_output { if config.loop_through {
Green.normal() for lang in languages {
} else { write!(stdout, "{}:{}\n", lang.name, lang.file_extensions.join(","))?;
Style::default() }
}; } else {
let longest = languages
for lang in languages { .iter()
write!(stdout, "{:width$}{}", lang.name, separator, width = longest)?; .map(|syntax| syntax.name.len())
.max()
// Number of characters on this line so far, wrap before `desired_width` .unwrap_or(32); // Fallback width if they have no language definitions.
let mut num_chars = 0;
let comma_separator = ", ";
let mut extension = lang.file_extensions.iter().peekable(); let separator = " ";
while let Some(word) = extension.next() { // Line-wrapping for the possible file extension overflow.
// If we can't fit this word in, then create a line break and align it in. let desired_width = config.term_width - longest - separator.len();
let new_chars = word.len() + comma_separator.len();
if num_chars + new_chars >= desired_width { let style = if config.colored_output {
num_chars = 0; Green.normal()
write!(stdout, "\n{:width$}{}", "", separator, width = longest)?; } else {
} Style::default()
};
num_chars += new_chars;
write!(stdout, "{}", style.paint(&word[..]))?; for lang in languages {
if extension.peek().is_some() { write!(stdout, "{:width$}{}", lang.name, separator, width = longest)?;
write!(stdout, "{}", comma_separator)?;
} // Number of characters on this line so far, wrap before `desired_width`
let mut num_chars = 0;
let mut extension = lang.file_extensions.iter().peekable();
while let Some(word) = extension.next() {
// If we can't fit this word in, then create a line break and align it in.
let new_chars = word.len() + comma_separator.len();
if num_chars + new_chars >= desired_width {
num_chars = 0;
write!(stdout, "\n{:width$}{}", "", separator, width = longest)?;
}
num_chars += new_chars;
write!(stdout, "{}", style.paint(&word[..]))?;
if extension.peek().is_some() {
write!(stdout, "{}", comma_separator)?;
}
}
writeln!(stdout)?;
} }
writeln!(stdout)?;
} }
Ok(()) Ok(())
@@ -195,8 +199,8 @@ fn run_controller(config: &Config) -> Result<bool> {
controller.run() controller.run()
} }
/// Returns `Err(..)` upon fatal errors. Otherwise, returns `Some(true)` on full success and /// Returns `Err(..)` upon fatal errors. Otherwise, returns `Ok(true)` on full success and
/// `Some(false)` if any intermediate errors occurred (were printed). /// `Ok(false)` if any intermediate errors occurred (were printed).
fn run() -> Result<bool> { fn run() -> Result<bool> {
let app = App::new()?; let app = App::new()?;
@@ -229,6 +233,12 @@ fn run() -> Result<bool> {
} else if app.matches.is_present("config-file") { } else if app.matches.is_present("config-file") {
println!("{}", config_file().to_string_lossy()); println!("{}", config_file().to_string_lossy());
Ok(true)
} else if app.matches.is_present("config-dir") {
writeln!(io::stdout(), "{}", config_dir())?;
Ok(true)
} else if app.matches.is_present("cache-dir") {
writeln!(io::stdout(), "{}", cache_dir())?;
Ok(true) Ok(true)
} else { } else {
run_controller(&config) run_controller(&config)
+36 -14
View File
@@ -6,8 +6,8 @@ use std::process::{Child, Command, Stdio};
use shell_words; use shell_words;
use app::PagingMode; use crate::app::PagingMode;
use errors::*; use crate::errors::*;
pub enum OutputType { pub enum OutputType {
Pager(Child), Pager(Child),
@@ -26,43 +26,65 @@ impl OutputType {
/// Try to launch the pager. Fall back to stdout in case of errors. /// Try to launch the pager. Fall back to stdout in case of errors.
fn try_pager(quit_if_one_screen: bool, pager_from_config: Option<&str>) -> Result<Self> { fn try_pager(quit_if_one_screen: bool, pager_from_config: Option<&str>) -> Result<Self> {
let pager_from_env = env::var("BAT_PAGER").or_else(|_| env::var("PAGER")); let mut replace_arguments_to_less = false;
let pager_from_env = match (env::var("BAT_PAGER"), env::var("PAGER")) {
(Ok(bat_pager), _) => Some(bat_pager),
(_, Ok(pager)) => {
// less needs to be called with the '-R' option in order to properly interpret the
// ANSI color sequences printed by bat. If someone has set PAGER="less -F", we
// therefore need to overwrite the arguments and add '-R'.
//
// We only do this for PAGER (as it is not specific to 'bat'), not for BAT_PAGER
// or bats '--pager' command line option.
replace_arguments_to_less = true;
Some(pager)
}
_ => None,
};
let pager_from_config = pager_from_config.map(|p| p.to_string());
if pager_from_config.is_some() {
replace_arguments_to_less = false;
}
let pager = pager_from_config let pager = pager_from_config
.map(|p| p.to_string()) .or(pager_from_env)
.or(pager_from_env.ok()) .unwrap_or_else(|| String::from("less"));
.unwrap_or(String::from("less"));
let pagerflags = shell_words::split(&pager) let pagerflags =
.chain_err(|| "Could not parse (BAT_)PAGER environment variable.")?; shell_words::split(&pager).chain_err(|| "Could not parse pager command.")?;
match pagerflags.split_first() { match pagerflags.split_first() {
Some((pager_name, mut args)) => { Some((pager_name, args)) => {
let mut pager_path = PathBuf::from(pager_name); let mut pager_path = PathBuf::from(pager_name);
if pager_path.file_stem() == Some(&OsString::from("bat")) { if pager_path.file_stem() == Some(&OsString::from("bat")) {
pager_path = PathBuf::from("less"); pager_path = PathBuf::from("less");
args = &[];
} }
let is_less = pager_path.file_stem() == Some(&OsString::from("less")); let is_less = pager_path.file_stem() == Some(&OsString::from("less"));
let mut process = if is_less { let mut process = if is_less {
let mut p = Command::new(&pager_path); let mut p = Command::new(&pager_path);
if args.is_empty() { if args.is_empty() || replace_arguments_to_less {
p.args(vec!["--RAW-CONTROL-CHARS", "--no-init"]); p.args(vec!["--RAW-CONTROL-CHARS", "--no-init"]);
if quit_if_one_screen { if quit_if_one_screen {
p.arg("--quit-if-one-screen"); p.arg("--quit-if-one-screen");
} }
} else {
p.args(args);
} }
p.env("LESSCHARSET", "UTF-8"); p.env("LESSCHARSET", "UTF-8");
p p
} else { } else {
Command::new(&pager_path) let mut p = Command::new(&pager_path);
p.args(args);
p
}; };
Ok(process Ok(process
.args(args)
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.spawn() .spawn()
.map(OutputType::Pager) .map(OutputType::Pager)
@@ -76,7 +98,7 @@ impl OutputType {
OutputType::Stdout(io::stdout()) OutputType::Stdout(io::stdout())
} }
pub fn handle(&mut self) -> Result<&mut Write> { pub fn handle(&mut self) -> Result<&mut dyn Write> {
Ok(match *self { Ok(match *self {
OutputType::Pager(ref mut command) => command OutputType::Pager(ref mut command) => command
.stdin .stdin
+101 -27
View File
@@ -33,41 +33,115 @@ pub fn expand_tabs(line: &str, width: usize, cursor: &mut usize) -> String {
buffer buffer
} }
pub fn replace_nonprintable(input: &str, tab_width: usize) -> String { fn try_parse_utf8_char(input: &[u8]) -> Option<(char, usize)> {
let str_from_utf8 = |seq| std::str::from_utf8(seq).ok();
let decoded = None
.or(input.get(0..1).and_then(str_from_utf8).map(|c| (c, 1)))
.or(input.get(0..2).and_then(str_from_utf8).map(|c| (c, 2)))
.or(input.get(0..3).and_then(str_from_utf8).map(|c| (c, 3)))
.or(input.get(0..4).and_then(str_from_utf8).map(|c| (c, 4)));
let decoded_char = decoded.map(|(seq, n)| (seq.chars().next().unwrap(), n));
decoded_char
}
pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String {
let mut output = String::new(); let mut output = String::new();
let tab_width = if tab_width == 0 { 4 } else { tab_width }; let tab_width = if tab_width == 0 { 4 } else { tab_width };
for chr in input.chars() { let mut idx = 0;
match chr { let len = input.len();
// space while idx < len {
' ' => output.push('•'), if let Some((chr, skip_ahead)) = try_parse_utf8_char(&input[idx..]) {
// tab idx += skip_ahead;
'\t' => {
if tab_width == 1 { match chr {
output.push('↹'); // space
} else { ' ' => output.push('•'),
output.push('├'); // tab
output.push_str(&"".repeat(tab_width - 2)); '\t' => {
output.push('┤'); if tab_width == 1 {
output.push('↹');
} else {
output.push('├');
output.push_str(&"".repeat(tab_width - 2));
output.push('┤');
}
} }
// line feed
'\x0A' => output.push('␊'),
// carriage return
'\x0D' => output.push('␍'),
// null
'\x00' => output.push('␀'),
// bell
'\x07' => output.push('␇'),
// backspace
'\x08' => output.push('␈'),
// escape
'\x1B' => output.push('␛'),
// printable ASCII
c if c.is_ascii_alphanumeric()
|| c.is_ascii_punctuation()
|| c.is_ascii_graphic() =>
{
output.push(c)
}
// everything else
c => output.push_str(&c.escape_unicode().collect::<String>()),
} }
// line feed } else {
'\x0A' => output.push('␊'), output.push_str(&format!("\\x{:02X}", input[idx]));
// carriage return idx += 1;
'\x0D' => output.push('␍'),
// null
'\x00' => output.push('␀'),
// bell
'\x07' => output.push('␇'),
// backspace
'\x08' => output.push('␈'),
// escape
'\x1B' => output.push('␛'),
// anything else
_ => output.push(chr),
} }
} }
output output
} }
#[test]
fn test_try_parse_utf8_char() {
assert_eq!(try_parse_utf8_char(&[0x20]), Some((' ', 1)));
assert_eq!(try_parse_utf8_char(&[0x20, 0x20]), Some((' ', 1)));
assert_eq!(try_parse_utf8_char(&[0x20, 0xef]), Some((' ', 1)));
assert_eq!(try_parse_utf8_char(&[0x00]), Some(('\x00', 1)));
assert_eq!(try_parse_utf8_char(&[0x1b]), Some(('\x1b', 1)));
assert_eq!(try_parse_utf8_char(&[0xc3, 0xa4]), Some(('ä', 2)));
assert_eq!(try_parse_utf8_char(&[0xc3, 0xa4, 0xef]), Some(('ä', 2)));
assert_eq!(try_parse_utf8_char(&[0xc3, 0xa4, 0x20]), Some(('ä', 2)));
assert_eq!(try_parse_utf8_char(&[0xe2, 0x82, 0xac]), Some(('€', 3)));
assert_eq!(
try_parse_utf8_char(&[0xe2, 0x82, 0xac, 0xef]),
Some(('€', 3))
);
assert_eq!(
try_parse_utf8_char(&[0xe2, 0x82, 0xac, 0x20]),
Some(('€', 3))
);
assert_eq!(try_parse_utf8_char(&[0xe2, 0x88, 0xb0]), Some(('∰', 3)));
assert_eq!(
try_parse_utf8_char(&[0xf0, 0x9f, 0x8c, 0x82]),
Some(('🌂', 4))
);
assert_eq!(
try_parse_utf8_char(&[0xf0, 0x9f, 0x8c, 0x82, 0xef]),
Some(('🌂', 4))
);
assert_eq!(
try_parse_utf8_char(&[0xf0, 0x9f, 0x8c, 0x82, 0x20]),
Some(('🌂', 4))
);
assert_eq!(try_parse_utf8_char(&[]), None);
assert_eq!(try_parse_utf8_char(&[0xef]), None);
assert_eq!(try_parse_utf8_char(&[0xef, 0x20]), None);
assert_eq!(try_parse_utf8_char(&[0xf0, 0xf0]), None);
}
+188 -51
View File
@@ -7,6 +7,7 @@ use ansi_term::Style;
use console::AnsiCodeIterator; use console::AnsiCodeIterator;
use syntect::easy::HighlightLines; use syntect::easy::HighlightLines;
use syntect::highlighting::Color;
use syntect::highlighting::Theme; use syntect::highlighting::Theme;
use syntect::parsing::SyntaxSet; use syntect::parsing::SyntaxSet;
@@ -15,24 +16,29 @@ use content_inspector::ContentType;
use encoding::all::{UTF_16BE, UTF_16LE}; use encoding::all::{UTF_16BE, UTF_16LE};
use encoding::{DecoderTrap, Encoding}; use encoding::{DecoderTrap, Encoding};
use app::Config; use crate::app::Config;
use assets::HighlightingAssets; use crate::assets::HighlightingAssets;
use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration}; use crate::decorations::{
use diff::get_git_diff; Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration,
use diff::LineChanges; };
use errors::*; use crate::diff::get_git_diff;
use inputfile::{InputFile, InputFileReader}; use crate::diff::LineChanges;
use preprocessor::{expand_tabs, replace_nonprintable}; use crate::errors::*;
use style::OutputWrap; use crate::inputfile::{InputFile, InputFileReader};
use terminal::{as_terminal_escaped, to_ansi_color}; use crate::preprocessor::{expand_tabs, replace_nonprintable};
use crate::style::OutputWrap;
use crate::terminal::{as_terminal_escaped, to_ansi_color};
pub trait Printer { pub trait Printer {
fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()>; fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;
fn print_footer(&mut self, handle: &mut Write) -> Result<()>; fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()>;
fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()>;
fn print_line( fn print_line(
&mut self, &mut self,
out_of_range: bool, out_of_range: bool,
handle: &mut Write, handle: &mut dyn Write,
line_number: usize, line_number: usize,
line_buffer: &[u8], line_buffer: &[u8],
) -> Result<()>; ) -> Result<()>;
@@ -47,23 +53,27 @@ impl SimplePrinter {
} }
impl Printer for SimplePrinter { impl Printer for SimplePrinter {
fn print_header(&mut self, _handle: &mut Write, _file: InputFile) -> Result<()> { fn print_header(&mut self, _handle: &mut dyn Write, _file: InputFile) -> Result<()> {
Ok(()) Ok(())
} }
fn print_footer(&mut self, _handle: &mut Write) -> Result<()> { fn print_footer(&mut self, _handle: &mut dyn Write) -> Result<()> {
Ok(())
}
fn print_snip(&mut self, _handle: &mut dyn Write) -> Result<()> {
Ok(()) Ok(())
} }
fn print_line( fn print_line(
&mut self, &mut self,
out_of_range: bool, out_of_range: bool,
handle: &mut Write, handle: &mut dyn Write,
_line_number: usize, _line_number: usize,
line_buffer: &[u8], line_buffer: &[u8],
) -> Result<()> { ) -> Result<()> {
if !out_of_range { if !out_of_range {
handle.write(line_buffer)?; handle.write_all(line_buffer)?;
} }
Ok(()) Ok(())
} }
@@ -75,10 +85,11 @@ pub struct InteractivePrinter<'a> {
decorations: Vec<Box<dyn Decoration>>, decorations: Vec<Box<dyn Decoration>>,
panel_width: usize, panel_width: usize,
ansi_prefix_sgr: String, ansi_prefix_sgr: String,
content_type: ContentType, content_type: Option<ContentType>,
pub line_changes: Option<LineChanges>, pub line_changes: Option<LineChanges>,
highlighter: Option<HighlightLines<'a>>, highlighter: Option<HighlightLines<'a>>,
syntax_set: &'a SyntaxSet, syntax_set: &'a SyntaxSet,
background_color_highlight: Option<Color>,
} }
impl<'a> InteractivePrinter<'a> { impl<'a> InteractivePrinter<'a> {
@@ -90,6 +101,8 @@ impl<'a> InteractivePrinter<'a> {
) -> Self { ) -> Self {
let theme = assets.get_theme(&config.theme); let theme = assets.get_theme(&config.theme);
let background_color_highlight = theme.settings.line_highlight;
let colors = if config.colored_output { let colors = if config.colored_output {
Colors::colored(theme, config.true_color) Colors::colored(theme, config.true_color)
} else { } else {
@@ -128,7 +141,10 @@ impl<'a> InteractivePrinter<'a> {
let mut line_changes = None; let mut line_changes = None;
let highlighter = if reader.content_type.is_binary() { let highlighter = if reader
.content_type
.map_or(false, |c| c.is_binary() && !config.show_nonprintable)
{
None None
} else { } else {
// Get the Git modifications // Get the Git modifications
@@ -156,10 +172,11 @@ impl<'a> InteractivePrinter<'a> {
line_changes, line_changes,
highlighter, highlighter,
syntax_set: &assets.syntax_set, syntax_set: &assets.syntax_set,
background_color_highlight,
} }
} }
fn print_horizontal_line(&mut self, handle: &mut Write, grid_char: char) -> Result<()> { fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> {
if self.panel_width == 0 { if self.panel_width == 0 {
writeln!( writeln!(
handle, handle,
@@ -175,6 +192,24 @@ impl<'a> InteractivePrinter<'a> {
Ok(()) Ok(())
} }
fn create_fake_panel(&self, text: &str) -> String {
if self.panel_width == 0 {
"".to_string()
} else {
let text_truncated: String = text.chars().take(self.panel_width - 1).collect();
let text_filled: String = format!(
"{}{}",
text_truncated,
" ".repeat(self.panel_width - 1 - text_truncated.len())
);
if self.config.output_components.grid() {
format!("{}", text_filled)
} else {
format!("{}", text_filled)
}
}
}
fn preprocess(&self, text: &str, cursor: &mut usize) -> String { fn preprocess(&self, text: &str, cursor: &mut usize) -> String {
if self.config.tab_width > 0 { if self.config.tab_width > 0 {
expand_tabs(text, self.config.tab_width, cursor) expand_tabs(text, self.config.tab_width, cursor)
@@ -185,8 +220,27 @@ impl<'a> InteractivePrinter<'a> {
} }
impl<'a> Printer for InteractivePrinter<'a> { impl<'a> Printer for InteractivePrinter<'a> {
fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()> { fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()> {
if !self.config.output_components.header() { if !self.config.output_components.header() {
if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
let input = match file {
InputFile::Ordinary(filename) => format!("file '{}'", filename),
_ => "STDIN".into(),
};
writeln!(
handle,
"{}: Binary content from {} will not be printed to the terminal \
(but will be present if the output of 'bat' is piped). You can use 'bat -A' \
to show the binary file contents.",
Yellow.paint("[bat warning]"),
input
)?;
} else {
if self.config.output_components.grid() {
self.print_horizontal_line(handle, '┬')?;
}
}
return Ok(()); return Ok(());
} }
@@ -211,9 +265,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
}; };
let mode = match self.content_type { let mode = match self.content_type {
ContentType::BINARY => " <BINARY>", Some(ContentType::BINARY) => " <BINARY>",
ContentType::UTF_16LE => " <UTF-16LE>", Some(ContentType::UTF_16LE) => " <UTF-16LE>",
ContentType::UTF_16BE => " <UTF-16BE>", Some(ContentType::UTF_16BE) => " <UTF-16BE>",
None => " <EMPTY>",
_ => "", _ => "",
}; };
@@ -226,7 +281,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
)?; )?;
if self.config.output_components.grid() { if self.config.output_components.grid() {
if self.content_type.is_text() { if self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable {
self.print_horizontal_line(handle, '┼')?; self.print_horizontal_line(handle, '┼')?;
} else { } else {
self.print_horizontal_line(handle, '┴')?; self.print_horizontal_line(handle, '┴')?;
@@ -236,38 +291,64 @@ impl<'a> Printer for InteractivePrinter<'a> {
Ok(()) Ok(())
} }
fn print_footer(&mut self, handle: &mut Write) -> Result<()> { fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()> {
if self.config.output_components.grid() && self.content_type.is_text() { if self.config.output_components.grid()
&& (self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable)
{
self.print_horizontal_line(handle, '┴') self.print_horizontal_line(handle, '┴')
} else { } else {
Ok(()) Ok(())
} }
} }
fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()> {
let panel = self.create_fake_panel(" ...");
let panel_count = panel.chars().count();
let title = "8<";
let title_count = title.chars().count();
let snip_left = "".repeat((self.config.term_width - panel_count - (title_count / 2)) / 4);
let snip_left_count = snip_left.chars().count(); // Can't use .len() with Unicode.
let snip_right =
"".repeat((self.config.term_width - panel_count - snip_left_count - title_count) / 2);
write!(
handle,
"{}\n",
self.colors
.grid
.paint(format!("{}{}{}{}", panel, snip_left, title, snip_right))
)?;
Ok(())
}
fn print_line( fn print_line(
&mut self, &mut self,
out_of_range: bool, out_of_range: bool,
handle: &mut Write, handle: &mut dyn Write,
line_number: usize, line_number: usize,
line_buffer: &[u8], line_buffer: &[u8],
) -> Result<()> { ) -> Result<()> {
let mut line = match self.content_type { let line = if self.config.show_nonprintable {
ContentType::BINARY => { replace_nonprintable(&line_buffer, self.config.tab_width)
return Ok(()); } else {
match self.content_type {
Some(ContentType::BINARY) | None => {
return Ok(());
}
Some(ContentType::UTF_16LE) => UTF_16LE
.decode(&line_buffer, DecoderTrap::Replace)
.map_err(|_| "Invalid UTF-16LE")?,
Some(ContentType::UTF_16BE) => UTF_16BE
.decode(&line_buffer, DecoderTrap::Replace)
.map_err(|_| "Invalid UTF-16BE")?,
_ => String::from_utf8_lossy(&line_buffer).to_string(),
} }
ContentType::UTF_16LE => UTF_16LE
.decode(&line_buffer, DecoderTrap::Strict)
.unwrap_or("Invalid UTF-16LE".into()),
ContentType::UTF_16BE => UTF_16BE
.decode(&line_buffer, DecoderTrap::Strict)
.unwrap_or("Invalid UTF-16BE".into()),
_ => String::from_utf8_lossy(&line_buffer).to_string(),
}; };
if self.config.show_nonprintable {
line = replace_nonprintable(&mut line, self.config.tab_width);
}
let regions = { let regions = {
let highlighter = match self.highlighter { let highlighter = match self.highlighter {
Some(ref mut highlighter) => highlighter, Some(ref mut highlighter) => highlighter,
@@ -287,6 +368,17 @@ impl<'a> Printer for InteractivePrinter<'a> {
let mut cursor_total: usize = 0; let mut cursor_total: usize = 0;
let mut panel_wrap: Option<String> = None; let mut panel_wrap: Option<String> = None;
// Line highlighting
let highlight_this_line = self
.config
.highlight_lines
.iter()
.any(|&l| l == line_number);
let background_color = self
.background_color_highlight
.filter(|_| highlight_this_line);
// Line decorations. // Line decorations.
if self.panel_width > 0 { if self.panel_width > 0 {
let decorations = self let decorations = self
@@ -309,40 +401,72 @@ impl<'a> Printer for InteractivePrinter<'a> {
for &(style, region) in regions.iter() { for &(style, region) in regions.iter() {
let text = &*self.preprocess(region, &mut cursor_total); let text = &*self.preprocess(region, &mut cursor_total);
let text_trimmed = text.trim_end_matches(|c| c == '\r' || c == '\n');
write!( write!(
handle, handle,
"{}", "{}",
as_terminal_escaped(style, &*text, true_color, colored_output, italics,) as_terminal_escaped(
style,
text_trimmed,
true_color,
colored_output,
italics,
background_color
)
)?; )?;
if text.len() != text_trimmed.len() {
if let Some(background_color) = background_color {
let mut ansi_style = Style::default();
ansi_style.background = Some(to_ansi_color(background_color, true_color));
let width = if cursor_total <= cursor_max {
cursor_max - cursor_total + 1
} else {
0
};
write!(handle, "{}", ansi_style.paint(" ".repeat(width)))?;
}
write!(handle, "{}", &text[text_trimmed.len()..])?;
}
} }
if line.bytes().next_back() != Some(b'\n') { if line.bytes().next_back() != Some(b'\n') {
write!(handle, "\n")?; writeln!(handle)?;
} }
} else { } else {
for &(style, region) in regions.iter() { for &(style, region) in regions.iter() {
let mut ansi_iterator = AnsiCodeIterator::new(region); let ansi_iterator = AnsiCodeIterator::new(region);
let mut ansi_prefix: String = String::new(); let mut ansi_prefix: String = String::new();
for chunk in ansi_iterator { for chunk in ansi_iterator {
match chunk { match chunk {
// ANSI escape passthrough. // ANSI escape passthrough.
(text, true) => { (text, true) => {
if text.chars().last().map_or(false, |c| c == 'm') { let is_ansi_csi = text.starts_with("\x1B[");
if is_ansi_csi && text.ends_with('m') {
// It's an ANSI SGR sequence.
// We should be mostly safe to just append these together.
ansi_prefix.push_str(text); ansi_prefix.push_str(text);
if text == "\x1B[0m" { if text == "\x1B[0m" {
self.ansi_prefix_sgr = "\x1B[0m".to_owned(); self.ansi_prefix_sgr = "\x1B[0m".to_owned();
} else { } else {
self.ansi_prefix_sgr.push_str(text); self.ansi_prefix_sgr.push_str(text);
} }
} else { } else if is_ansi_csi {
// It's a regular CSI sequence.
// We should be mostly safe to just append these together.
ansi_prefix.push_str(text); ansi_prefix.push_str(text);
} else {
// It's probably a VT100 code.
// Passing it through is the safest bet.
write!(handle, "{}", text)?;
} }
} }
// Regular text. // Regular text.
(text, false) => { (text, false) => {
let text = self.preprocess( let text = self.preprocess(
text.trim_right_matches(|c| c == '\r' || c == '\n'), text.trim_end_matches(|c| c == '\r' || c == '\n'),
&mut cursor_total, &mut cursor_total,
); );
@@ -368,7 +492,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
), ),
self.config.true_color, self.config.true_color,
self.config.colored_output, self.config.colored_output,
self.config.use_italic_text self.config.use_italic_text,
background_color
) )
)?; )?;
break; break;
@@ -408,7 +533,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
), ),
self.config.true_color, self.config.true_color,
self.config.colored_output, self.config.colored_output,
self.config.use_italic_text self.config.use_italic_text,
background_color
), ),
panel_wrap.clone().unwrap() panel_wrap.clone().unwrap()
)?; )?;
@@ -421,7 +547,18 @@ impl<'a> Printer for InteractivePrinter<'a> {
} }
} }
write!(handle, "\n")?; if let Some(background_color) = background_color {
let mut ansi_style = Style::default();
ansi_style.background =
Some(to_ansi_color(background_color, self.config.true_color));
write!(
handle,
"{}",
ansi_style.paint(" ".repeat(cursor_max - cursor))
)?;
}
writeln!(handle)?;
} }
Ok(()) Ok(())
+11 -3
View File
@@ -1,7 +1,7 @@
use std::collections::HashSet; use std::collections::HashSet;
use std::str::FromStr; use std::str::FromStr;
use errors::*; use crate::errors::*;
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)] #[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
pub enum OutputComponent { pub enum OutputComponent {
@@ -10,6 +10,7 @@ pub enum OutputComponent {
Grid, Grid,
Header, Header,
Numbers, Numbers,
Snip,
Full, Full,
Plain, Plain,
} }
@@ -21,8 +22,8 @@ pub enum OutputWrap {
} }
impl OutputComponent { impl OutputComponent {
pub fn components(&self, interactive_terminal: bool) -> &'static [OutputComponent] { pub fn components(self, interactive_terminal: bool) -> &'static [OutputComponent] {
match *self { match self {
OutputComponent::Auto => { OutputComponent::Auto => {
if interactive_terminal { if interactive_terminal {
OutputComponent::Full.components(interactive_terminal) OutputComponent::Full.components(interactive_terminal)
@@ -34,11 +35,13 @@ impl OutputComponent {
OutputComponent::Grid => &[OutputComponent::Grid], OutputComponent::Grid => &[OutputComponent::Grid],
OutputComponent::Header => &[OutputComponent::Header], OutputComponent::Header => &[OutputComponent::Header],
OutputComponent::Numbers => &[OutputComponent::Numbers], OutputComponent::Numbers => &[OutputComponent::Numbers],
OutputComponent::Snip => &[OutputComponent::Snip],
OutputComponent::Full => &[ OutputComponent::Full => &[
OutputComponent::Changes, OutputComponent::Changes,
OutputComponent::Grid, OutputComponent::Grid,
OutputComponent::Header, OutputComponent::Header,
OutputComponent::Numbers, OutputComponent::Numbers,
OutputComponent::Snip,
], ],
OutputComponent::Plain => &[], OutputComponent::Plain => &[],
} }
@@ -55,6 +58,7 @@ impl FromStr for OutputComponent {
"grid" => Ok(OutputComponent::Grid), "grid" => Ok(OutputComponent::Grid),
"header" => Ok(OutputComponent::Header), "header" => Ok(OutputComponent::Header),
"numbers" => Ok(OutputComponent::Numbers), "numbers" => Ok(OutputComponent::Numbers),
"snip" => Ok(OutputComponent::Snip),
"full" => Ok(OutputComponent::Full), "full" => Ok(OutputComponent::Full),
"plain" => Ok(OutputComponent::Plain), "plain" => Ok(OutputComponent::Plain),
_ => Err(format!("Unknown style '{}'", s).into()), _ => Err(format!("Unknown style '{}'", s).into()),
@@ -82,6 +86,10 @@ impl OutputComponents {
self.0.contains(&OutputComponent::Numbers) self.0.contains(&OutputComponent::Numbers)
} }
pub fn snip(&self) -> bool {
self.0.contains(&OutputComponent::Snip)
}
pub fn plain(&self) -> bool { pub fn plain(&self) -> bool {
self.0.iter().all(|c| c == &OutputComponent::Plain) self.0.iter().all(|c| c == &OutputComponent::Plain)
} }
+11 -11
View File
@@ -1,32 +1,32 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::collections::HashMap; use std::collections::HashMap;
#[derive(Debug, Clone)] #[derive(Debug, Clone, Default)]
pub struct SyntaxMapping(HashMap<String, String>); pub struct SyntaxMapping(HashMap<String, String>);
impl SyntaxMapping { impl SyntaxMapping {
pub fn new() -> SyntaxMapping { pub fn new() -> SyntaxMapping {
SyntaxMapping(HashMap::new()) Default::default()
} }
pub fn insert(&mut self, from: String, to: String) -> Option<String> { pub fn insert(&mut self, from: impl Into<String>, to: impl Into<String>) -> Option<String> {
self.0.insert(from, to) self.0.insert(from.into(), to.into())
} }
pub fn replace<'a>(&self, input: &'a str) -> Cow<'a, str> { pub fn replace<'a>(&self, input: impl Into<Cow<'a, str>>) -> Cow<'a, str> {
let mut out = Cow::from(input); let input = input.into();
if let Some(value) = self.0.get(input) { match self.0.get(input.as_ref()) {
out = Cow::from(value.clone()) Some(s) => Cow::from(s.clone()),
None => input,
} }
out
} }
} }
#[test] #[test]
fn basic() { fn basic() {
let mut map = SyntaxMapping::new(); let mut map = SyntaxMapping::new();
map.insert("Cargo.lock".into(), "toml".into()); map.insert("Cargo.lock", "toml");
map.insert(".ignore".into(), ".gitignore".into()); map.insert(".ignore", ".gitignore");
assert_eq!("toml", map.replace("Cargo.lock")); assert_eq!("toml", map.replace("Cargo.lock"));
assert_eq!("other.lock", map.replace("other.lock")); assert_eq!("other.lock", map.replace("other.lock"));
+10 -2
View File
@@ -6,7 +6,13 @@ use ansi_term::{self, Style};
use syntect::highlighting::{self, FontStyle}; use syntect::highlighting::{self, FontStyle};
pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term::Colour { pub fn to_ansi_color(color: highlighting::Color, true_color: bool) -> ansi_term::Colour {
if true_color { if color.a == 0 {
// Themes can specify one of the user-configurable terminal colors by
// encoding them as #RRGGBBAA with AA set to 00 (transparent) and RR set
// to the color palette number. The built-in themes ansi-light,
// ansi-dark, and base16 use this.
Fixed(color.r)
} else if true_color {
RGB(color.r, color.g, color.b) RGB(color.r, color.g, color.b)
} else { } else {
Fixed(ansi_colours::ansi256_from_rgb((color.r, color.g, color.b))) Fixed(ansi_colours::ansi256_from_rgb((color.r, color.g, color.b)))
@@ -19,8 +25,9 @@ pub fn as_terminal_escaped(
true_color: bool, true_color: bool,
colored: bool, colored: bool,
italics: bool, italics: bool,
background_color: Option<highlighting::Color>,
) -> String { ) -> String {
let style = if !colored { let mut style = if !colored {
Style::default() Style::default()
} else { } else {
let color = to_ansi_color(style.foreground, true_color); let color = to_ansi_color(style.foreground, true_color);
@@ -36,5 +43,6 @@ pub fn as_terminal_escaped(
} }
}; };
style.background = background_color.map(|c| to_ansi_color(c, true_color));
style.paint(text).to_string() style.paint(text).to_string()
} }
+4
View File
@@ -0,0 +1,4 @@
examples/* linguist-vendored
snapshots/* linguist-vendored
benchmarks/* linguist-vendored
benchmarks/test-src/* linguist-vendored
-1
View File
@@ -1 +0,0 @@
test-src/* linguist-vendored
+1
View File
@@ -0,0 +1 @@
test
+1
View File
@@ -0,0 +1 @@
test
View File
+1
View File
@@ -0,0 +1 @@
Single Line
Binary file not shown.
+130
View File
@@ -76,6 +76,79 @@ fn concatenate_stdin() {
.stdout("hello world\nstdin\nhello world\n"); .stdout("hello world\nstdin\nhello world\n");
} }
#[test]
fn concatenate_empty_first() {
bat()
.arg("empty.txt")
.arg("test.txt")
.assert()
.success()
.stdout("hello world\n");
}
#[test]
fn concatenate_empty_last() {
bat()
.arg("test.txt")
.arg("empty.txt")
.assert()
.success()
.stdout("hello world\n");
}
#[test]
fn concatenate_empty_both() {
bat()
.arg("empty.txt")
.arg("empty.txt")
.assert()
.success()
.stdout("");
}
#[test]
fn concatenate_empty_between() {
bat()
.arg("test.txt")
.arg("empty.txt")
.arg("test.txt")
.assert()
.success()
.stdout("hello world\nhello world\n");
}
#[test]
fn concatenate_empty_first_and_last() {
bat()
.arg("empty.txt")
.arg("test.txt")
.arg("empty.txt")
.assert()
.success()
.stdout("hello world\n");
}
#[test]
fn concatenate_single_line() {
bat()
.arg("single-line.txt")
.arg("single-line.txt")
.assert()
.success()
.stdout("Single LineSingle Line");
}
#[test]
fn concatenate_single_line_empty() {
bat()
.arg("single-line.txt")
.arg("empty.txt")
.arg("single-line.txt")
.assert()
.success()
.stdout("Single LineSingle Line");
}
#[test] #[test]
fn line_numbers() { fn line_numbers() {
bat() bat()
@@ -363,3 +436,60 @@ fn config_read_arguments_from_file() {
.success() .success()
.stdout("dummy-pager-from-config\n"); .stdout("dummy-pager-from-config\n");
} }
#[test]
fn utf16() {
// The output will be converted to UTF-8 with a leading UTF-8 BOM
bat()
.arg("--plain")
.arg("--decorations=always")
.arg("test_UTF-16LE.txt")
.assert()
.success()
.stdout(std::str::from_utf8(b"\xEF\xBB\xBFhello world\n").unwrap());
}
#[test]
fn can_print_file_named_cache() {
bat_with_config()
.arg("cache")
.assert()
.success()
.stdout("test\n")
.stderr("");
}
#[test]
fn can_print_file_starting_with_cache() {
bat_with_config()
.arg("cache.c")
.assert()
.success()
.stdout("test\n")
.stderr("");
}
#[test]
fn does_not_print_unwanted_file_named_cache() {
bat_with_config().arg("cach").assert().failure();
}
#[test]
fn snip() {
bat()
.arg("multiline.txt")
.arg("--style=numbers,snip")
.arg("--decorations=always")
.arg("--line-range=1:2")
.arg("--line-range=4:")
.arg("--terminal-width=80")
.assert()
.success()
.stdout(
" 1 line 1
2 line 2
... 8<
4 line 4
",
);
}
+1 -1
View File
@@ -1,6 +1,6 @@
mod tester; mod tester;
use tester::BatTester; use crate::tester::BatTester;
macro_rules! snapshot_tests { macro_rules! snapshot_tests {
($($test_name: ident: $style: expr,)*) => { ($($test_name: ident: $style: expr,)*) => {
@@ -1,3 +1,4 @@
──┬─────────────────────────────────────────────────────────────────────────────
│ struct Rectangle { │ struct Rectangle {
│ width: u32, │ width: u32,
│ height: u32, │ height: u32,
@@ -1,3 +1,4 @@
───────┬────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle { 1 │ struct Rectangle {
2 │ width: u32, 2 │ width: u32,
3 │ height: u32, 3 │ height: u32,
+1
View File
@@ -1,3 +1,4 @@
────────────────────────────────────────────────────────────────────────────────
struct Rectangle { struct Rectangle {
width: u32, width: u32,
height: u32, height: u32,
@@ -1,3 +1,4 @@
─────┬──────────────────────────────────────────────────────────────────────────
1 │ struct Rectangle { 1 │ struct Rectangle {
2 │ width: u32, 2 │ width: u32,
3 │ height: u32, 3 │ height: u32,