summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Peter <sharkdp@users.noreply.github.com>2020-10-30 19:36:27 +0100
committerGitHub <noreply@github.com>2020-10-30 19:36:27 +0100
commit3a612f063eb157a35b4d09d4dcf2b04ed1604388 (patch)
treea1128b792bde1ea9051e6e60c9efc555f6755ea6
parent9daea73bbab6e3f4ad6761bcf9702cc7a9811489 (diff)
parent8e8131590ca9922c996c33ad7a5076f57a619e42 (diff)
Merge branch 'master' into master
-rw-r--r--.github/workflows/CICD.yml5
-rw-r--r--.gitmodules6
-rw-r--r--CHANGELOG.md9
-rw-r--r--CONTRIBUTING.md48
-rw-r--r--README.md17
-rw-r--r--assets/syntaxes/02_Extra/Manpage.sublime-syntax22
m---------assets/syntaxes/02_Extra/Svelte0
-rw-r--r--assets/syntaxes/02_Extra/syntax_test_man.man32
-rw-r--r--assets/themes.binbin16672 -> 18538 bytes
m---------assets/themes/Coldark0
-rw-r--r--src/bin/bat/main.rs8
-rw-r--r--src/error.rs4
-rw-r--r--src/output.rs4
-rw-r--r--tests/assets.rs4
-rw-r--r--tests/integration_tests.rs10
-rw-r--r--tests/syntax-tests/highlighted/D/test.d44
-rw-r--r--tests/syntax-tests/highlighted/EtcGroup/test.group67
-rw-r--r--tests/syntax-tests/highlighted/Git Attributes/example.gitattributes16
-rw-r--r--tests/syntax-tests/highlighted/Git Config/text.gitconfig107
-rw-r--r--tests/syntax-tests/highlighted/Graphviz DOT/test_digraph.dot41
-rw-r--r--tests/syntax-tests/highlighted/Graphviz DOT/test_graph.dot3
-rw-r--r--tests/syntax-tests/highlighted/MATLAB/test.matlab34
-rw-r--r--tests/syntax-tests/highlighted/Manpage/bat-0.16.man6
-rw-r--r--tests/syntax-tests/highlighted/Manpage/select-2.man98
-rw-r--r--tests/syntax-tests/highlighted/PowerShell/test.ps125
-rw-r--r--tests/syntax-tests/highlighted/QML/BatSyntaxTest.qml219
-rw-r--r--tests/syntax-tests/highlighted/SLS/test.sls57
-rw-r--r--tests/syntax-tests/highlighted/Svelte/App.svelte57
-rw-r--r--tests/syntax-tests/highlighted/Vue/example.vue55
-rw-r--r--tests/syntax-tests/highlighted/nginx/nginx.conf140
-rw-r--r--tests/syntax-tests/highlighted/nix/test.nix15
-rw-r--r--tests/syntax-tests/highlighted/orgmode/test.org38
-rw-r--r--tests/syntax-tests/source/D/test.d44
-rw-r--r--tests/syntax-tests/source/EtcGroup/test.group67
-rw-r--r--tests/syntax-tests/source/Git Attributes/example.gitattributes16
-rw-r--r--tests/syntax-tests/source/Git Config/LICENSE.md1
-rw-r--r--tests/syntax-tests/source/Git Config/text.gitconfig107
-rw-r--r--tests/syntax-tests/source/Graphviz DOT/LICENSE.md22
-rw-r--r--tests/syntax-tests/source/Graphviz DOT/test_digraph.dot41
-rw-r--r--tests/syntax-tests/source/Graphviz DOT/test_graph.dot3
-rw-r--r--tests/syntax-tests/source/MATLAB/LICENSE.md27
-rw-r--r--tests/syntax-tests/source/MATLAB/test.matlab34
-rwxr-xr-xtests/syntax-tests/source/PowerShell/test.ps1bin0 -> 1430 bytes
-rw-r--r--tests/syntax-tests/source/QML/BatSyntaxTest.qml219
-rw-r--r--tests/syntax-tests/source/SLS/test.sls57
-rw-r--r--tests/syntax-tests/source/Svelte/App.svelte57
-rw-r--r--tests/syntax-tests/source/Svelte/LICENSE14
-rw-r--r--tests/syntax-tests/source/Vue/example.vue55
-rw-r--r--tests/syntax-tests/source/nginx/nginx.conf140
-rw-r--r--tests/syntax-tests/source/nix/test.nix15
-rw-r--r--tests/syntax-tests/source/orgmode/test.org38
51 files changed, 2083 insertions, 65 deletions
diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml
index 5ff77927..19d4e927 100644
--- a/.github/workflows/CICD.yml
+++ b/.github/workflows/CICD.yml
@@ -58,6 +58,11 @@ jobs:
with:
command: test
args: --release
+ - name: Run ignored-by-default unit tests with new syntaxes and themes
+ uses: actions-rs/cargo@v1
+ with:
+ command: test
+ args: --release -- --ignored
- name: Syntax highlighting regression test
run: tests/syntax-tests/regression_test.sh
- name: List of languages
diff --git a/.gitmodules b/.gitmodules
index e00573c6..4981c20e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -200,3 +200,9 @@
[submodule "assets/syntaxes/02_Extra/Ninja"]
path = assets/syntaxes/02_Extra/Ninja
url = https://github.com/pope/SublimeNinja.git
+[submodule "assets/syntaxes/02_Extra/Svelte"]
+ path = assets/syntaxes/02_Extra/Svelte
+ url = https://github.com/corneliusio/svelte-sublime
+[submodule "assets/themes/Coldark"]
+ path = assets/themes/Coldark
+ url = https://github.com/ArmandPhilippot/coldark-bat.git \ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0971c859..478324c4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,5 @@
# unreleased
-- Add Note to refer to see detailed help with --help (and vice versa with -h). see #1215 (@henil)
## Features
@@ -8,14 +7,22 @@
## Bugfixes
+- Throws an error when `bat` is being used as `pager`, see #1343 (@adrian-rivera)
+
## Other
+- Add note to refer to see detailed help with `--help` (and vice versa with `-h`), see #1215 (@henil)
+- Add a `Contributors` section to `README`, see #1348 (@adrian-rivera)
+
## Syntaxes
- Manpage syntax highlighting has been improved, see #1315 (@keith-hall)
+- Add Svelte file syntax, see #1285 (@kjmph)
## New themes
+- Coldark, see #1329 (@armandphilippot)
+
## `bat` as a library
## Packaging
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..dca1d0f3
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,48 @@
+# Contributing
+
+Thank you for considering to contribute to `bat`!
+
+
+
+## Add an entry to the changelog
+
+If your contribution changes the behavior of `bat` (as opposed to a typo-fix
+in the documentation), please update the [`CHANGELOG.md`](CHANGELOG.md) file
+and describe your changes. This makes the release proess much easier and
+therefore helps to get your changes into a new `bat` release faster.
+
+The top of the `CHANGELOG` contains a *"unreleased"* section with a few
+subsections (Features, Bugfixes, …). Please add your entry to the subsection
+that best describes your change
+
+Entries follow this format:
+```
+- Short description of what has been changed, see #123 (@user)
+```
+Here, `#123` is the number of the original issue and/or your pull request.
+Please replace `@user` by your GitHub username.
+
+
+## Development
+
+Please check out the [Development](https://github.com/sharkdp/bat#development)
+section in the README.
+
+
+## Adding a new feature
+
+Please consider opening a
+[feature request ticket](https://github.com/sharkdp/bat/issues/new?assignees=&labels=feature-request&template=feature_request.md)
+first in order to give us a chance to discuss the feature first.
+
+
+## Adding new syntaxes/languages or themes
+
+Before you make a pull request that adds a new syntax or theme, please read
+the [Customization](https://github.com/sharkdp/bat#customization) section
+in the README first.
+
+If you really think that a particular syntax or theme should be added for all
+users, please read the corresponding
+[documentation](https://github.com/sharkdp/bat/blob/master/doc/assets.md)
+first.
diff --git a/README.md b/README.md
index b2f7e74f..f04e6a1c 100644
--- a/README.md
+++ b/README.md
@@ -131,7 +131,18 @@ highlighting:
git show v0.6.0:src/main.rs | bat -l rs
```
-Note that syntax highlighting within diffs is currently not supported. If you are looking for this, check out [`delta`](https://github.com/dandavison/delta).
+#### `git diff`
+
+You can combine `bat` with `git diff` to view lines around code changes with proper syntax
+highlighting:
+```bash
+batdiff() {
+ git diff --name-only --diff-filter=d | xargs bat --diff
+}
+```
+If you prefer to use this as a separate tool, check out `batdiff` in [`bat-extras`](https://github.com/eth-p/bat-extras).
+
+If you are looking for more support for git and diff operations, check out [`delta`](https://github.com/dandavison/delta).
#### `xclip`
@@ -665,6 +676,10 @@ bash assets/create.sh
cargo install --path . --locked --force
```
+## Contributing
+
+Take a look at the [`CONTRIBUTING.md`](CONTRIBUTING.md) guide.
+
## Maintainers
- [sharkdp](https://github.com/sharkdp)
diff --git a/assets/syntaxes/02_Extra/Manpage.sublime-syntax b/assets/syntaxes/02_Extra/Manpage.sublime-syntax
index ea0bcb3c..d92eea22 100644
--- a/assets/syntaxes/02_Extra/Manpage.sublime-syntax
+++ b/assets/syntaxes/02_Extra/Manpage.sublime-syntax
@@ -34,11 +34,11 @@ contexts:
scope: markup.heading.title.man
- match: \s\s
pop: true
- - match: '(?=\S)'
+ - match: '(?=\S|$)'
pop: true
- match: '$'
- push: body
+ set: body
body:
# English, ..., ..., ..., Russian, ...
@@ -48,14 +48,16 @@ contexts:
embed: synopsis
escape: '(?={{section_heading}})'
+ - match: '^(?:USAGE)'
+ scope: markup.heading.synopsis.man
+ embed: synopsis
+ escape: '(?={{section_heading}})'
- match: '{{section_heading}}'
scope: markup.heading.other.man
embed: options # some man pages put command line options under the description heading
escape: '(?={{section_heading}})'
- - include: function-call
-
function-call:
- match: '\b([A-Za-z0-9_\-]+)(\()([^)]*)(\))'
captures:
@@ -83,6 +85,7 @@ contexts:
- match: ''
pop: true
- include: function-call
+ - include: c-code
expect-command-line-option:
- match: '[A-Za-z0-9-]+'
@@ -127,9 +130,15 @@ contexts:
- match: '$|(?=[],]|{{command_line_option}})'
pop: true
+ c-code:
+ - match: '^(?=\s+(?:#include\b|#define\b|/\*|struct\s+(\w+\s*)?\{))'
+ embed: scope:source.c
+ #embed_scope: source.c.embedded.man
+ #escape: ^(?!#|\1|\s*(?:$|/\*|#include\b|#define\b))
+ escape: ^(?=\s*(?:\(.*\.\)\s*$|[A-Z](?![A-Z])))
+
synopsis:
- - match: '^(?=\s+(?:#include|/\*))'
- push: scope:source.c
+ - include: c-code
- match: \[
scope: punctuation.section.brackets.begin.man
push: command-line-option-or-pipe
@@ -140,6 +149,7 @@ contexts:
captures:
1: keyword.operator.logical.man
#- match: (?={{command_line_option}})
+ - match: \w+-\w+
- match: (?=-)
push:
- match: (?=\s*\|)
diff --git a/assets/syntaxes/02_Extra/Svelte b/assets/syntaxes/02_Extra/Svelte
new file mode 160000
+Subproject bf92f5b7b69c8ea641d6822fd6d12cc2d934195
diff --git a/assets/syntaxes/02_Extra/syntax_test_man.man b/assets/syntaxes/02_Extra/syntax_test_man.man
index a4c8f91d..ee8bada3 100644
--- a/assets/syntaxes/02_Extra/syntax_test_man.man
+++ b/assets/syntaxes/02_Extra/syntax_test_man.man
@@ -5,7 +5,7 @@ SOMETHING(8) System Manager's Manual SOMETHING(8)
# ^^^^^^^ meta.preprocessor
NAME
-#^^^ markup.heading.title
+#^^^ markup.heading.other
example - do something useful
SYNOPSIS
@@ -45,9 +45,16 @@ SYNOPSIS
[--quiet] [--debug] [--help|-h] [--version] [--conf FILE]
/* According to POSIX.1-2001, POSIX.1-2008 */
-# ^^ source comment.block punctuation.definition.comment
+# ^^ source.c comment.block punctuation.definition.comment
#include <sys/select.h>
-# ^^^^^^^^ source meta.preprocessor.include keyword.control.import.include
+# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include
+ struct timeval {
+# ^^^^^^ source.c storage.type
+
+ time_t tv_sec; /* seconds */
+ suseconds_t tv_usec; /* microseconds */
+ };
+
DESCRIPTION
@@ -123,3 +130,22 @@ OPTIONS
# ^^^ variable.parameter
# ^^ - variable
output NUM (default 3) lines of copied context
+
+EXAMPLE
+ #include <stdio.h>
+# ^^^^^^^^ source.c meta.preprocessor.include keyword.control.import.include
+
+ (This is not C code.)
+# ^^^^^^^^^^^^^^^^^^^^^^ - source.c
+
+ struct timeval {
+ time_t tv_sec; /* seconds */
+ suseconds_t tv_usec; /* microseconds */
+ };
+# ^ source.c punctuation.terminator
+
+ The corresponding argument for pselect() has the following type:
+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - source.c
+ #define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN |
+ EPOLLHUP | EPOLLERR)
+# ^ source.c meta.preprocessor.macro meta.group punctuation.section.group.end
diff --git a/assets/themes.bin b/assets/themes.bin
index b8683424..bc291724 100644
--- a/assets/themes.bin
+++ b/assets/themes.bin
Binary files differ
diff --git a/assets/themes/Coldark b/assets/themes/Coldark
new file mode 160000
+Subproject b4a1c74d8d5bdd136ec530e5905b81027247254
diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs
index 50c39371..eb6f75bc 100644
--- a/src/bin/bat/main.rs
+++ b/src/bin/bat/main.rs
@@ -205,6 +205,14 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
writeln!(stdout, "{}", theme)?;
}
}
+ writeln!(
+ stdout,
+ "Further themes can be installed to '{}', \
+ and are added to the cache with `bat cache --build`. \
+ For more information, see:\n\n \
+ https://github.com/sharkdp/bat#adding-new-themes",
+ config_file().join("themes").to_string_lossy()
+ )?;
Ok(())
}
diff --git a/src/error.rs b/src/error.rs
index 2e73b85b..3e5b3711 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -20,6 +20,10 @@ error_chain! {
description("unknown syntax"),
display("unknown syntax: '{}'", name)
}
+ InvalidPagerValueBat {
+ description("invalid value `bat` for pager property"),
+ display("Use of bat as a pager is disallowed in order to avoid infinite recursion problems")
+ }
}
}
diff --git a/src/output.rs b/src/output.rs
index b0d5974e..689371b9 100644
--- a/src/output.rs
+++ b/src/output.rs
@@ -85,10 +85,10 @@ impl OutputType {
match pagerflags.split_first() {
Some((pager_name, args)) => {
- let mut pager_path = PathBuf::from(pager_name);
+ let pager_path = PathBuf::from(pager_name);
if pager_path.file_stem() == Some(&OsString::from("bat")) {
- pager_path = PathBuf::from("less");
+ return Err(ErrorKind::InvalidPagerValueBat.into());
}
let is_less = pager_path.file_stem() == Some(&OsString::from("less"));
diff --git a/tests/assets.rs b/tests/assets.rs
index 7ced769c..55b5399e 100644
--- a/tests/assets.rs
+++ b/tests/assets.rs
@@ -1,7 +1,9 @@
use bat::assets::HighlightingAssets;
/// This test ensures that we are not accidentally removing themes due to submodule updates.
+/// It is 'ignore'd by default because it requires themes.bin to be up-to-date.
#[test]
+#[ignore]
fn all_themes_are_present() {
let assets = HighlightingAssets::from_binary();
@@ -12,6 +14,8 @@ fn all_themes_are_present() {
themes,
vec![
"1337",
+ "Coldark-Cold",
+ "Coldark-Dark",
"DarkNeon",
"Dracula",
"GitHub",
diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs
index da0690ef..09ac8498 100644
--- a/tests/integration_tests.rs
+++ b/tests/integration_tests.rs
@@ -406,6 +406,16 @@ fn pager_disable() {
}
#[test]
+fn pager_value_bat() {
+ bat()
+ .arg("--pager=bat")
+ .arg("--paging=always")
+ .arg("test.txt")
+ .assert()
+ .failure();
+}
+
+#[test]
fn alias_pager_disable() {
bat()
.env("PAGER", "echo other-pager")
diff --git a/tests/syntax-tests/highlighted/D/test.d b/tests/syntax-tests/highlighted/D/test.d
new file mode 100644
index 00000000..da347147
--- /dev/null
+++ b/tests/syntax-tests/highlighted/D/test.d
@@ -0,0 +1,44 @@
+// selective import
+import std.stdio : writeln, writefln;
+// non-selective import
+import std.algorithm;
+
+/* a multiline comment
+*
+* this function is safe because it doesn't use pointer arithmetic
+*/
+int the_ultimate_answer() @safe {
+ // assert1on
+ assert(1 != 2);
+ // now we can safely return our answer 
+ return 42;
+}
+
+void main()
+{
+ // function call with string literal
+ writeln("Hello World!");
+
+ // an int array declaration
+ int[] arr1 = [1, 2, 3];
+ // an immutable double
+ immutable double pi = 3.14;
+ // a mutable double
+ double d1 = pi;
+ // a pointer
+ double* dp1 = &d1;
+ // another pointer to the same thingy
+ auto a1 = &d1;
+ // a constant bool
+ const bool b1 = true;
+ if (b1) {
+ // another function call 
+ writefln("%s\n%s\n%s\n", arr1, d1, the_ultimate_answer());
+ }
+ else if (!b1) {
+ writeln("this seems wrong");
+ }
+ else {
+ writeln("I'm giving up, this is too crazy for me");
+ }
+}
diff --git a/tests/syntax-tests/highlighted/EtcGroup/test.group b/tests/syntax-tests/highlighted/EtcGroup/test.group
new file mode 100644
index 00000000..5049c80e
--- /dev/null
+++ b/tests/syntax-tests/highlighted/EtcGroup/test.group
@@ -0,0 +1,67 @@
+root:x:0:root
+sys:x:3:bin
+mem:x:8:
+ftp:x:11:
+mail:x:12:
+log:x:19:
+smmsp:x:25:
+proc:x:26:polkitd
+games:x:50:
+lock:x:54:
+network:x:90:
+floppy:x:94:
+scanner:x:96:
+power:x:98:
+adm:x:999:daemon
+wheel:x:998:username
+kmem:x:997:
+tty:x:5:
+utmp:x:996:
+audio:x:995:mpd,username
+disk:x:994:
+input:x:993:
+kvm:x:992:
+lp:x:991:
+optical:x:990:username
+render:x:989:
+storage:x:988:username
+uucp:x:987:
+video:x:986:user