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.
* 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
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.
* 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
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.
* 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>
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.
* 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>
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.
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
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.
* 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
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.
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.
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.
Do not ignore `BAT_CONFIG_PATH` if it doesn't exist. Both when
generating a new config file with `--generate-config-file` and
when attempting to read the config.
Also, provide a better error message in case the file can not
be created.
closes#1550
closes#1510
The change in `create_highlighted_versions.py` fixes a "unknown theme
"'1337'" warning. The single quotes were wrong. `bat` was always falling
back to the default theme, so let's use that for now.
Fixed by implementing the proposal by sharkdp:
* Allow PAGER=bat, but ignore the setting in bat and simply default to
less. Unless of course, BAT_PAGER or --pager is used to overwrite the
value of PAGER.
* Disallow the usage of bat within BAT_PAGER and --pager.
Right now all tests pass even if we e.g. return
Ok(OutputType::stdout())
instead of doing
.chain_err(|| "Could not parse pager command.")?
so add a test to make sure this functionality don't break.