Commit Graph

536 Commits (master)

Author SHA1 Message Date
Anomalocaridid e32ad0b048
Add `$LESSOPEN` and `$LESSCLOSE` support (#2444) 9 months ago
einfachIrgendwer0815 4b04f901fe Add test for `BAT_PAGING` 9 months ago
Jan T. Sott 32c0e1fb45 update highlighted test file 9 months ago
Jan T. Sott 34440f1b0c update highlighted test file 9 months ago
Jan T. Sott f1d6cc7a64 add test files for NSIS syntax 9 months ago
Keith Hall b65a02681a Add crontab syntax 1 year ago
einfachIrgendwer0815 8f99a78cf1
Print non-printable characters using caret notation (#2443)
When the new flag is set, non-printable characters are printed using caret notation.
1 year ago
Keith Hall 5e77ca37e8 More consistent scoping in commands section in Manpages 1 year ago
Keith Hall 52ef1bc0d6 Scope environment variable and commands sections in Manpages 1 year ago
David Peter 5cd77662b5
Merge pull request #2430 from Enselic/blessable-help
Require changes to `-h` and `--help` to be blessed
1 year ago
Martin Nordholts 4e34b362f8 Require changes to `-h` and `--help` to be blessed
From now on, any changes to the help texts will be visible in PR diffs,
which will make it very easy to review, and very hard to accidentally
miss changes to help texts.

If a contributor makes a change to help texts, the `cargo test` failure
text they will see contains instructions on how to update the blessed
help texts:

    error: expect test failed
       --> ../doc/long-help.txt

    You can update all `expect!` tests by running:

        env UPDATE_EXPECT=1 cargo test

In short, to update blessed help texts, one simply does

    env UPDATE_EXPECT=1 cargo test

Do not run the tests if the `git` feature is missing, since then
`--diff` will be missing from `--help`. And do not run the tests on
Windows, because then the help text will contain the term `.exe`.

Move man page step to after cargo doc step so that the man page exists
when we look for it.
1 year ago
Víctor González Prieto 3ffa7edbd5 Bump cmd-help syntax to latest
This update includes an overhaul of scope names to better support the
set of themes included with bat.

You can find a visual diff for every theme in this PR:
https://github.com/victor-gp/cmd-help-sublime-syntax/pull/17

This commit updates the cmd-help syntax test because the scopes (-> colors)
have changed.
2 years ago
Miles Liu e39178b101
Fix `bat cache --clear` not clearing the `--target` dir if specified 2 years ago
David Peter accc1b6d10
Merge pull request #2366 from Freed-Wu/vimhelp
Add VimHelp.sublime-syntax and its test
2 years ago
Aaron Kollasch 1224403aa1
Update comments in tests/integration_tests.rs 2 years ago
Aaron Kollasch 1a07baf5f2
Update tests/integration_tests.rs
Co-authored-by: David Peter <sharkdp@users.noreply.github.com>
2 years ago
Aaron Kollasch bad2292950
Add tests for --theme > BAT_THEME > config 2 years ago
Aaron Kollasch e773b48135
Fix cache subcommand and add tests
Treat the cache subcommand differently from --no-config:
For --no-config, insert args from selected environment variables
For cache, don't insert args
2 years ago
Aaron Kollasch 76aad7c74f
Improve correctness and add more tests 2 years ago
Aaron Kollasch 36ccc6a31e
Allow env vars to override config but not args 2 years ago
David Peter 4724d50e1d
Merge pull request #2361 from Freed-Wu/main
Add Requirementstxt.sublime-syntax and its test.
2 years ago
David Peter 14742a82bd
Merge branch 'master' into master 2 years ago
David Peter 8e15c9c501
Merge pull request #2316 from dkm/pr/ada_syntax
Add syntax support for Ada
2 years ago
David Peter 3c9c960612
Merge pull request #2309 from johnmatthiggins/master
Added -S flag for truncating long lines
2 years ago
Wu Zhenyu 37da5659c5 Add VimHelp.sublime-syntax and its test 2 years ago
Wu Zhenyu 6010b334c6 Add Requirementstxt.sublime-syntax and its test. 2 years ago
BANO.notIT 31f964f468 fix(syntax): Use variable.other for TodoTxt attrs 2 years ago
BANO.notIT 316f1b3601 test(syntax): Generate normal highlight for bat 2 years ago
BANO.notIT 1a85b4c3b5 test(syntax): Add partially working test 2 years ago
John Higgins bf114f5844
Added helper function for -S flag tests 2 years ago
wzy f215d07366
Improve Manpage.sublime-syntax, Fix #2353 (#2364)
* Improve Manpage.sublime-syntax, Fix #2353

* Add highlight tests for fzf-0.33.0
2 years ago
John Higgins 236a2c5794
Fixed inverted logic on -S and --chop-long-lines 2 years ago
John Higgins 03216c9c18
Merge branch 'sharkdp:master' into master 2 years ago
John Higgins 8f31ffa9df
Added integration tests 2 years ago
Marc Poulhiès 06b403aa92 Add syntax support for Ada
Add submodule with sublime syntax.

Add corresponding tests for both Ada (in adb/ads) and for the companion tool
gpr.

fixes #1300

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2 years ago
Martin Nordholts 352309b056 Revert "Remove code that tries to handle ANSI escape inputs"
This reverts commit 8174e02279. Turns out
it is needed for a common use case, see
https://github.com/sharkdp/bat/issues/2307.

It is not a clean revert, because I adjust CHANGELOG.md and also add a
comment to the test. I also had to resolve a small `use` conflict.
2 years ago
dag-h 08386daa3a
Strip BOM from output in interactive mode (#1938)
* Strip BOM from output in interactive mode

* Strip BOM when not loop_through, add regression tests

* Update CHANGELOG.md

* Only strip BOM from beginning of first line

* Fix integration test on macOS that relied on color scheme

* Fix integration test on Windows that relied on detected terminal width

* Fix syntax test that was failing due to a previously wrong (now fixed) highlighting

Co-authored-by: David Peter <mail@david-peter.de>
Co-authored-by: Martin Nordholts <enselic@gmail.com>
2 years ago
Kid d6d8b61131 Fix highlight test 2 years ago
Kid 839e62cff8 Map `fish_history` to YAML 2 years ago
David Peter ca9843fa83
Merge pull request #2236 from kidonng/patch-1
Add `.mts` and `.cts` to TypeScript file extensions
2 years ago
Kid d7b6519422 Add `.mts` and `.cts` to TypeScript file extensions
See also:

https://github.com/github/linguist/pull/5905
2 years ago
Martin Nordholts 799bb1639c Try to fix all warnings 2 years ago
Martin Nordholts 2dd2994b2f Merge remote-tracking branch 'origin/master' into feature/668/add-systemwide-config 2 years ago
Martin Nordholts 49875d6ce7
Make `bat::PrettyPrinter::syntaxes()` iterate over new `bat::Syntax` struct (#2222)
We can't keep `syntect::parsing::SyntaxReference` as part of the public
API, because that might prevent us from bumping to syntect 6.0.0 without
also bumping bat to v2.0.0, once we reach v1.0.0.

So introduce a new stripped down struct `Syntax` and return that
instead. Let it be fully owned to make the API simple. It is not going
to be in a hot code path anyway.

I have looked at all code of our 27 dependents but I can't find a single
instance of this method being used, so this change should be safe for
v1.0.0.
2 years ago
Martin Nordholts 899fdbb347
Remove code that tries to handle ANSI escape inputs (#2189)
Syntax highlighting is broken when input contains ANSI escape characters
anyway, so there is not much point in trying to handle ANSI escapes in
input.
2 years ago
Martin Nordholts 621ab6078f CI: Check MSRV without git feature enabled
git2-rs MSRV policy is to only support latest stable rust (see
https://github.com/rust-lang/git2-rs#rust-version-requirements), so it
does not make sense to run our MSRV tests with git enabled.
2 years ago
Martin Nordholts 020492f7e6 tests/tester: Do not build as tests
mod tester does not contains any tests, so do not build the module as
containing tests. Instead use the mod.rs approach described in
https://doc.rust-lang.org/book/ch11-03-test-organization.html#submodules-in-integration-tests.
2 years ago
Christopher Acosta 9a924b445b
Make --map-syntax and --ignored-suffix work together (#2260)
* Make --map-syntax and --ignored-suffix work together

* Minor refactor
2 years ago
Marie Katrine Ekeberg 9c7ca33929
Make `--no-paging`/`-P` override `--paging=...` if passed as a later arg (#2201)
* Make the no-paging option override earlier paging options

* Update CHANGELOG.md

Co-authored-by: Martin Nordholts <enselic@gmail.com>
2 years ago
yuvalmo c4d9d7561b Color `fstab` dump and pass fields correctly (#2246)
Was missing the number 2 as a valid option in those fields.
2 years ago
Kian-Meng Ang f93d650708 Fix typos 2 years ago
Cre3per ed4997c77c
Add syntax mapping from NSE to Lua (#2214) 2 years ago
Martin Nordholts 3339eee2dc
Make the default macOS theme depend on Dark Mode (#2197)
* Make the default macOS theme depend on Dark Mode

We frequently get complaints from macOS users that bat does not work on
their default macOS terminal background, which is white.

Pay the price of slightly increased startup time to get a better default
on macOS. To avoid the slightly increased startup time, simply specify a
theme explicitly via `--theme`, `BAT_THEME`, or `~/.config/bat`.

Note that if there is an error when we check if Dark Mode is enabled, we
behave the same as on Windows and Linux; assume that the terminal
background is dark. This harmonizes behavior across platforms, and makes
bat behave the same as before, when Dark Mode was always assumed to be
enabled.

* src/assets.rs: Fix typo

* Update CHANGELOG.md
2 years ago
Martin Nordholts 5fe9b3e1b3 Make `INI` syntax register as handler of `.inf` files
We need to type `inf` and `INF` as strings in `INI.sublime-syntax`,
otherwise `yaml-rust` interprets them as real numbers ("infinity") and
they do not get registered as file extensions:

    /Users/martin/src/yaml-rust # https://github.com/chyh1990/yaml-rust
    % cargo run --example dump_yaml ~/src/bat/assets/syntaxes/02_Extra/INI.sublime-syntax
    ---
    String("name"):
        String("INI")
    String("file_extensions"):
            String("ini")
            String("INI")
            Real("inf")
            Real("INF")
    ...

Also add a regression test.
2 years ago
Martin Nordholts 7334ab4542
Bump to syntect 5.0.0 to e.g. start lazy-loading syntaxes (#2181)
* Bump to syntect 5.0.0 to e.g. start lazy-loading themes

Closes #915
Closes #951
Closes #1846
Closes #1854

* Typo fix formated -> formatted

* Update CHANGELOG.md
2 years ago
dependabot[bot] ef3e398b2b
Bump assets/syntaxes/02_Extra/Zig from `87ecbca` to `1a4a384` (#2136)
* Bump assets/syntaxes/02_Extra/Zig from `87ecbca` to `1a4a384`

Bumps [assets/syntaxes/02_Extra/Zig](https://github.com/ziglang/sublime-zig-language) from `87ecbca` to `1a4a384`.
- [Release notes](https://github.com/ziglang/sublime-zig-language/releases)
- [Commits](87ecbcae6f...1a4a38445f)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/Zig
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update tests/syntax-tests/highlighted/Zig/example.zig and CHANGELOG.md

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Martin Nordholts <enselic@gmail.com>
2 years ago
Isaac Horvath adea895026
Add a --style=default option (#2119)
* Add a --style=default option

* Added --style=default test and CHANGELOG entry

* Format CHANGELOG.md options with quotes

Co-authored-by: Martin Nordholts <enselic@gmail.com>

* Update help text for '--style'

* Make --style=default the default option

* Update style descriptions: "basic" -> "recommended"

* Add integration test for --style=default as default

* Update clap long help for --style
2 years ago
Keith Hall b5294f1cb2
Skip syntax highlighting for long lines (#2165)
* Skip highlighting for long lines

* Run cargo fmt, update changelog
2 years ago
Víctor González Prieto b0898900ce
Syntax: add cmd-help (#2148)
* Add cmd-help syntax

To highlight command --help messages.

* README.md: mention help message highlighting

* README.md: edit help message highlighting
2 years ago
Keith Hall c0ec03e08a Syntax: [Log] highlight escape characters in double quoted strings 2 years ago
Patrick Pichler 6b660ef63a Add test for systemwide config file support
There is now a new stage in the CICD workflow present, which will build
`bat` with the `BAT_SYSTEM_CONFIG_PREFIX` set to load the config file
from `/tests/examples/system_config/bat/config`, plus a basic set of
tests, to ensure the feature is working as expected. By default the
tests are set to ignored, as they need special setup before they can be
run.
2 years ago
David Peter 6330f36495 Updated test names 2 years ago
Patrick Hilhorst e7df748b6d correctly handle multiple tabs in one line 2 years ago
Patrick Hilhorst 67124f8513 add show_all_tabstops_long integration test 2 years ago
Patrick Hilhorst 16f940c2d3 add show_all_tabstops integration test 2 years ago
cyqsimon 14ddda0a8b
Recognize files in `$XDG_CONFIG_HOME/git/` and `$HOME/.config/git/` better (#2067)
* git global config - lookup $XDG_CONFIG_HOME faithfully

* Use `bool::then`

* Cover both `$XDG_CONFIG_HOME` & `$HOME/.config`

* Remove unused import

* Global git config tests

* Added trailing newline

* Fix git config test

* Wrote to changelog

* Revert change of `Result::ok` to `Result::unwrap`

* Apply suggestions from code review

Co-authored-by: Martin Nordholts <enselic@gmail.com>

* Guard against empty `$HOME`

Co-authored-by: Martin Nordholts <enselic@gmail.com>
2 years ago
ltdk e4f6fb2afe Add JQ syntax highlighting 2 years ago
Mahdi Dibaiee d21f1e8f17
Underline highlighted lines in ANSI theme (#1985)
* Underline highlighted lines in ANSI theme

* add test for ansi highlight underline, fix underscore in plain
2 years ago
Mahdi Dibaiee 312c8ef01f
Add new `--style` called `header-filesize` and display it by default (#1988)
Also rename `header` to `header-filename`.

Related to #1701
2 years ago
Martin Nordholts 0fa99518ce run-benchmarks.sh: Use `python3` oneliner instead of `jq`
I am setting up a new computer and thus are missing a lot of tools. I
noticed we rely on `jq` being installed, which is a bit annoying when it
is not installed yet.

We can quite easily get rid of this dependecy on `jq` by using a simple
`python3` oneliner.
2 years ago
Firegem 0c19d3e51a Add autogenerated `highlighted` folder 2 years ago
Firegem e73c3d2378 Add a test file for nimble 2 years ago
dependabot[bot] a02713dc15
Bump assets/syntaxes/02_Extra/PowerShell from `4a0a076` to `742f0b5` (#1935)
* Bump assets/syntaxes/02_Extra/PowerShell from `4a0a076` to `742f0b5`

Bumps [assets/syntaxes/02_Extra/PowerShell](https://github.com/PowerShell/EditorSyntax) from `4a0a076` to `742f0b5`.
- [Release notes](https://github.com/PowerShell/EditorSyntax/releases)
- [Commits](4a0a076661...742f0b5d4b)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/PowerShell
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Do machine-conversion from .tmLanguage to .sublime-syntax

The new .sublime-syntax file is a pure "Tools" -> "Developer" -> "New Syntax
from ..." conversion from a licenced version of Sublime Text, Version 3.1.1,
Build 3176 with the .tmLanguage as the source file. No manual changes has been
made.

* Update regression test and add CHANGELOG.md entry

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Martin Nordholts <enselic@gmail.com>
3 years ago
dependabot[bot] ee1f5a9e89
Bump assets/syntaxes/02_Extra/SCSS_Sass from `63819a1` to `d3d9404` (#1766)
* Bump assets/syntaxes/02_Extra/SCSS_Sass from `63819a1` to `d3d9404`

Bumps [assets/syntaxes/02_Extra/SCSS_Sass](https://github.com/braver/SublimeSass) from `63819a1` to `d3d9404`.
- [Release notes](https://github.com/braver/SublimeSass/releases)
- [Commits](63819a1ab6...d3d9404640)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/SCSS_Sass
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update regression test and add CHANGELOG.md entry

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Martin Nordholts <enselic@gmail.com>
3 years ago
Martin Nordholts a3ea798246
Credit syntax definition and theme authors with new `--acknowledgements` option (#1971)
The text that is printed is generated when building assets, by analyzing LICENSE
and NOTICE files that comes with syntaxes and themes.

We take this opportunity to also add a NOTICE file as defined by Apache License 2.0.
3 years ago
Ethan P 63ad53817d
Improved ANSI passthrough (#1596)
Improve handling of ANSI passthrough. Fix ANSI passthrough for --wrap=never. Add test for ANSI passthrough.
3 years ago
Martin Nordholts 6d0eb0749e run-benchmarks: Benchmark both --wrap=character and --wrap=never 3 years ago
Martin Nordholts 36c1ea4599 run-benchmarks.sh: Don't benchmark startup time syntaxes twice 3 years ago
Ersikan 29711c178a
Better syntax highlighting for Dart (#1959)
Remove unmaintained Dart syntax submodule. Add elMuso/Dartlight as submodule. Update Dart syntax highlighting. Add changes to changelog.
3 years ago
Martin Nordholts ce89fb2751 CICD: Add check for accidental inclusion of GPL:ed code 3 years ago
David Peter 3338699257 Remove the 'requirements.txt' syntax
This is needed because the syntax is only available under GPL v3.0,
which is not compatible with `bat`s license.
3 years ago
Martin Nordholts 747b15436a run-benchmarks.sh: Add third 'Startup time' variant
Using Markdown for a startup test is useful since it has so many dependencies on
other syntaxes. So such a test makes sure that lazy-loading of syntaxes work.

It is however also useful to measure the startup time of bat when the time to
load a syntax is very small, and the measured startup time has mostly non-syntax
related causes. Such as:
 * Parsing arguments
 * Setting up syntax mapping
 * Loading themes

This commit adds such a test. It uses the CpuInfo syntax which is very small.
Only 14 lines, compared to the 1581 lines that Markdown is (not including the
size of its included syntaxes).

This command can be used to get an approximation of the size of syntaxes, and
thus how expensive they are to load:

    find -name *.sublime-syntax -print0 | xargs --null wc -l | sort -n -r
3 years ago
Martin Nordholts 206bf5b8d6 run-benchmarks.sh: Add new test 'Startup time with syntax highlighting' 3 years ago
David Peter d2175d6382 Add test for ANSI sequence loop-through 3 years ago
David Peter b3aefd2d41 Add Python highlighting test 3 years ago
David Peter f7eb55aa01 Rename jquery file 3 years ago
David Peter 5e63d67960 Remove jquery-3.3.1.min.js benchmark 3 years ago
David Peter 6fd78ea3f6 Clean benchmarking environment 3 years ago
David Peter b12503a46a Markdown (and JSON) reports 3 years ago
David Peter ea2faf45e4 Simplify cargo-target-dir extraction 3 years ago
David Peter 1822c981da Move comparison.sh benchmark script to documentation 3 years ago
Shun Sakai 619cf6e6d6 Add MediaWiki syntax 3 years ago
Bojan Đurđević d6ed5e6746
Support for ignored-suffix CLI arguments (#1892) 3 years ago
David Peter 0b63ad5e8b create_highlighted_versions: fix misleading/wrong error message 3 years ago
Martin Nordholts dde770aa21 Add bat panic regression test for Svelte files with embedded LiveScript
Without a LiveScript syntax present, the Svelte test will now fail with a panic.
3 years ago
Martin Nordholts 6eb2cc9cac Add LiveScript syntax
The file `LiveScript.sublime-syntax` is a pure export from a licenced version
of Sublime Text, Version 3.1.1, Build 3176 with
assets/syntaxes/02_Extra/LiveScript/Syntaxes/LiveScript.tmLanguage as the source
file.
3 years ago
Diva M 2339d78bf4 update snapshot tests 3 years ago
Martin Nordholts 994c21a5e1
syntax-tests: Make CpuInfo test actually work (#1887)
* syntax-tests: Make CpuInfo test actually work

File extension matching is case-sensitive, so extension needs to be .cpuinfo for
the syntax to actually be used.

* Also fix MemInfo
3 years ago
Georgy Komarov d04a83de7b Add Racket syntax 3 years ago
David Peter 44a332c1c4 Parallelize syntax regression tests
The syntax highlighting regression tests can be trivially parallelized.
On my notebook (8 core), this results in a 3.9x speedup.
3 years ago