Commit Graph

494 Commits

Author SHA1 Message Date
Martin Nordholts
2dd2994b2f Merge remote-tracking branch 'origin/master' into feature/668/add-systemwide-config 2022-09-04 20:44:23 +02:00
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.
2022-09-03 12:33:38 +02:00
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.
2022-08-29 18:49:29 +02:00
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.
2022-08-25 19:27:55 +02:00
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.
2022-08-25 19:27:55 +02:00
Christopher Acosta
9a924b445b
Make --map-syntax and --ignored-suffix work together (#2260)
* Make --map-syntax and --ignored-suffix work together

* Minor refactor
2022-08-16 22:42:15 +02:00
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>
2022-08-14 21:09:13 +02:00
yuvalmo
c4d9d7561b Color fstab dump and pass fields correctly (#2246)
Was missing the number 2 as a valid option in those fields.
2022-07-25 21:33:51 +02:00
Kian-Meng Ang
f93d650708 Fix typos 2022-06-12 16:38:33 +02:00
Cre3per
ed4997c77c
Add syntax mapping from NSE to Lua (#2214) 2022-06-04 14:12:42 +02:00
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
2022-05-24 19:29:03 +02:00
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.
2022-05-11 17:39:01 +02:00
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
2022-05-07 13:43:11 +02:00
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>
2022-05-05 20:29:17 +02:00
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
2022-05-04 21:31:32 +02:00
Keith Hall
b5294f1cb2
Skip syntax highlighting for long lines (#2165)
* Skip highlighting for long lines

* Run cargo fmt, update changelog
2022-05-04 07:59:24 +02:00
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
2022-04-26 19:42:18 +02:00
Keith Hall
c0ec03e08a Syntax: [Log] highlight escape characters in double quoted strings 2022-03-22 22:20:39 +02:00
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.
2022-03-10 20:55:11 +01:00
David Peter
6330f36495 Updated test names 2022-03-06 20:03:00 +01:00
Patrick Hilhorst
e7df748b6d correctly handle multiple tabs in one line 2022-03-06 20:03:00 +01:00
Patrick Hilhorst
67124f8513 add show_all_tabstops_long integration test 2022-03-06 20:03:00 +01:00
Patrick Hilhorst
16f940c2d3 add show_all_tabstops integration test 2022-03-06 20:03:00 +01:00
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>
2022-02-26 17:01:00 +01:00
ltdk
e4f6fb2afe Add JQ syntax highlighting 2022-02-14 19:14:19 +01:00
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
2022-02-14 19:02:14 +01:00
Mahdi Dibaiee
312c8ef01f
Add new --style called header-filesize and display it by default (#1988)
Also rename `header` to `header-filename`.

Related to #1701
2022-02-07 20:48:57 +01:00
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.
2022-02-03 08:00:14 +01:00
Firegem
0c19d3e51a Add autogenerated highlighted folder 2022-01-06 13:08:38 +01:00
Firegem
e73c3d2378 Add a test file for nimble 2022-01-06 13:08:38 +01:00
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>
2021-12-12 19:41:04 +01:00
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>
2021-12-12 18:58:30 +01:00
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.
2021-12-11 14:00:45 +01:00
Ethan P
63ad53817d
Improved ANSI passthrough (#1596)
Improve handling of ANSI passthrough. Fix ANSI passthrough for --wrap=never. Add test for ANSI passthrough.
2021-12-08 16:06:42 +01:00
Martin Nordholts
6d0eb0749e run-benchmarks: Benchmark both --wrap=character and --wrap=never 2021-12-08 15:45:46 +01:00
Martin Nordholts
36c1ea4599 run-benchmarks.sh: Don't benchmark startup time syntaxes twice 2021-12-08 12:02:11 +01:00
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.
2021-12-06 08:40:43 +01:00
Martin Nordholts
ce89fb2751 CICD: Add check for accidental inclusion of GPL:ed code 2021-11-28 21:04:37 +01:00
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.
2021-11-28 16:28:14 +01:00
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
2021-11-27 10:39:17 +01:00
Martin Nordholts
206bf5b8d6 run-benchmarks.sh: Add new test 'Startup time with syntax highlighting' 2021-11-26 20:14:30 +01:00
David Peter
d2175d6382 Add test for ANSI sequence loop-through 2021-11-23 08:14:49 +01:00
David Peter
b3aefd2d41 Add Python highlighting test 2021-11-23 08:14:49 +01:00
David Peter
f7eb55aa01 Rename jquery file 2021-11-23 08:14:49 +01:00
David Peter
5e63d67960 Remove jquery-3.3.1.min.js benchmark 2021-11-23 08:14:49 +01:00
David Peter
6fd78ea3f6 Clean benchmarking environment 2021-11-23 08:14:49 +01:00
David Peter
b12503a46a Markdown (and JSON) reports 2021-11-23 08:14:49 +01:00
David Peter
ea2faf45e4 Simplify cargo-target-dir extraction 2021-11-23 08:14:49 +01:00
David Peter
1822c981da Move comparison.sh benchmark script to documentation 2021-11-23 08:14:49 +01:00
Shun Sakai
619cf6e6d6 Add MediaWiki syntax 2021-11-22 19:46:29 +01:00
Bojan Đurđević
d6ed5e6746
Support for ignored-suffix CLI arguments (#1892) 2021-11-19 17:05:23 +01:00
David Peter
0b63ad5e8b create_highlighted_versions: fix misleading/wrong error message 2021-10-24 12:24:46 +02:00
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.
2021-10-23 13:35:32 +02:00
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.
2021-10-23 13:35:32 +02:00
Diva M
2339d78bf4 update snapshot tests 2021-10-17 21:21:23 +02:00
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
2021-10-06 06:50:11 +02:00
Georgy Komarov
d04a83de7b Add Racket syntax 2021-10-03 19:17:26 +02:00
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.
2021-09-22 22:18:01 +02:00
Martin Nordholts
9ed9a6fc3d
Simplify HighlightingAssets::get_syntax() first_line logic (#1852)
And make self.get_first_line_syntax() be called lazily.
2021-09-16 17:01:12 +02:00
David Peter
27f046ec03 Consolidate environment variable lists
We want to make sure that all of our test environments are clean from
possible outside modification. This consolidates the list of used
environment variables in Rust-based and Python-based integration tests.

Note that there is also a similar list in `src/bin/bat/main.rs` which
is even more exhaustive (for bug report collection). However, some
of these variables can not possibly have an effect on test environments.
2021-09-07 20:17:16 +02:00
Martin Nordholts
d935ea1cda
Add regression testing for the custom assets functionality (#1829)
The test is following the same steps regular users are instructed to follow:
https://github.com/sharkdp/bat/blob/master/README.md#adding-new-syntaxes--language-definitions
2021-09-07 17:01:15 +02:00
Ville Skyttä
7c41bd72da assets: add Debian ucf backups to ignored suffixes
Refs https://manpages.debian.org/bullseye/ucf/ucf.1.en.html
2021-08-29 19:55:00 +02:00
a1346054
51edacb5eb style: trim excess whitespace 2021-08-21 23:07:37 +02:00
a1346054
5197ef9048 fix: spelling 2021-08-21 23:07:37 +02:00
a1346054
19678527e5 chore(find-slow-to-highlight-files.py): be explicit about using python3
In many distros, `python` no longer leads to anything, and instead
`python2` or `python3` need to be explicitly run.
2021-08-21 23:07:37 +02:00
Martin Nordholts
f5c1cb2dff Run 'cargo fmt' 2021-08-19 07:18:05 +02:00
Keith Hall
133b06e945 Fix syslog syntax highlighting when no colon after "process" 2021-08-16 22:15:39 +03:00
Mario Finelli
699f1e65cc Add slim syntax test 2021-08-16 06:16:53 +02:00
Bill Risher
6c62ed5608 revamped integration test, made CHANGELOG changes 2021-08-14 22:02:58 +02:00
Bill Risher
bf78288e9e feat(config): added recognition of $BAT_CONFIG_DIR 2021-08-14 22:02:58 +02:00
Ville Skyttä
2d92a4dbb3 Allow colon in syslog loghost
Makes it work with IPv6 addresses.
2021-08-11 21:36:43 +03:00
Ville Skyttä
f508ddf66d Allow period in syslog loghost
Makes it work with FQDN's and IPv4 addresses.
2021-08-11 16:43:04 +03:00
Ville Skyttä
02218c916c Allow period in syslog process name 2021-08-11 16:41:56 +03:00
Martin Nordholts
89217e0d58 Make --no-paging and --no-pager work again 2021-08-09 13:37:56 +02:00
Martin Nordholts
bd797c75a4 integration_tests: Add diagnostic_sanity_check() 2021-08-07 20:07:46 +02:00
Layle | Luca
51c7eb7ac1
Included LLVM syntax highlighting submodule and added regression tests 2021-08-05 20:20:33 +02:00
Keith Hall
6d5ff671e7 Add HTTP Request/Response syntax as a git submodule 2021-07-29 21:36:16 +02:00
Martin Nordholts
b040efff79 Support a hidden arg --no-custom-assets that skips loading assets from the cache 2021-07-29 08:27:02 +02:00
Martin Nordholts
a81009607a HighlightingAssets: Make .syntaxes() and syntax_for_file_name() failable
Or rather, introduce new versions of these methods and deprecate the old ones.

This is preparation to enable robust and user-friendly support for lazy-loading.
With lazy-loading, we don't know if the SyntaxSet is valid until after we try to
use it, so wherever we try to use it, we need to return a Result. See discussion
about panics in #1747.
2021-07-29 08:26:18 +02:00
Sarvesh MD
f464b1ba39 Update battest.py
Add decorator test `@classmethod` and fixed spellings.
2021-07-26 08:44:05 +02:00
Ville Skyttä
7537e309d8 Add groff syntax
The syntax is named "Man Page" upstream, but our man page syntax is
different, it's for rendered man pages. Rename to Groff and remove
`.man` from extensions.
2021-07-25 13:27:30 +02:00
David Peter
64763eafbe Update Julia syntax test 2021-07-13 09:07:29 +02:00
Ville Skyttä
ddb39ef2f6 Add syntax tests for ignored filename suffixes 2021-07-09 06:34:11 +02:00
Mohamed Abdelnour
12ecb325c9 Modify Linguist overrides 2021-06-14 08:36:20 +02:00
Mohamed Abdelnour
c18afcb01a Add Verilog syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
63043d4a60 Add varlink syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
76034880ae Add TypeScriptReact syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
768189859a Add Stylus syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
6e5a2a5c51 Add Strace syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
9935c4984c Add Robot Framework syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
a0a5e30c39 Add Rego syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
4126bbeead Add Puppet syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
a5b79295d7 Add NAnt Build File syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
e917784932 Add Literate Haskell syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
f46b90d28d Add jsonnet syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
64cbfbed47 Add Java Server Page (JSP) syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
1ced35ec76 Add 'NOTICE' to list of file names to skip 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
16d346773b Add Fortran Namelist syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
b02120cf66 Add Fortran (Fixed Form) syntax test file 2021-06-01 22:36:56 +02:00
Mohamed Abdelnour
702b5caf2d Add Fortran (Modern) syntax test file 2021-06-01 22:36:56 +02:00