Turns out GitHub is clever enough to pick up clippy warnings from us
just running it, and showing them in PRs under a "Unchanged files with
check annotations (beta)" header.
The only warnings currently shown are style warnings, and we agreed we
don't want to risk putting off contributors over style issues. So
explicitly allow (don't warn in the logs for) this category of clippy
lints.
This means that the only clippy categories left that prints warnings
(Warn) are:
clippy::complexity
clippy::perf
And the only category of lints that fails the CI build (Deny) remains to
be:
clippy::correctness
See https://rust-lang.github.io/rust-clippy/master/index.html for a
catalog of all lints.
This will fix#614 by making it clear what is wrong by showing the
following error message:
Failed to load one or more themes from
'/Users/me/.config/bat/themes' (reason: 'Invalid syntax theme
settings')
We also need to add a check if theme_dir.exists(), otherwise an absent
dir will seem like an error:
Failed to load one or more themes from
'/Users/me/.config/bat/themes' (reason: 'IO error for
operation on /Users/me/.config/bat/themes: No such file or
directory (os error 2)')
(This is the same check we already have for syntax_dir.)
To trigger/verify the changed code, run
bat --list-languages # or -L
This is the last clippy warning in the code that you get if you run
cargo clippy --all-targets --all-features -- --allow clippy::style
so by fixing it it becomes easier to spot when a new warning is
introduced (that does not belong to the clippy category clippy::style).
And by making it easy to spot new warnings, we increase chance of such
regressions not ending up in the code base.
Only the 'correctness' category of lints are 'deny' by default. This is
the only clippy lints we want to enforce for now. The other ones we just
want to print in the logs. So remove any --deny and --allow arguments.
See discussion in #1410.
Run the linter on the minimum supported rust version; otherwise we will
get lint warnings for things that require a too high Rust toolchain
version to fix.
Allow the following checks, since we already violate them our code:
- clippy::new-without-default
- clippy::match-bool
- clippy::if_same_then_else
Eventually we should fix these lint issues and then disallow them to
prevent them from coming back in other places.
The clippy args used is recommended here:
https://github.com/rust-lang/rust-clippy#travis-ci
**NOTES:**
- PR is not yet merged in upstream repository (https://github.com/SalGnt/Sublime-VimL/pull/12),
but sublime-syntax file is already updated with changes.
- Updated syntax test files are added as well
This fixes#1064
Adds a syntax highlighting test for VimL
with source file based on parts of my own configuration
changed to cover as much of syntax as possible.
**NOTES:**
Last line of source (`syntax enable`) does not get highlighted,
since `syntax` keyword is not part of highlighting rules.
Related to #1213
This macro is intended to be package-internal and is not to be
considered part of the public lib API.
Use it in three places to reduce code duplication. However, main reason
for this refactoring is to allow us to fix#1063 without duplicating the
code yet another time.
The macro can also be used for the "Binary content from {} will not be
printed to the terminal" message if that message starts to use eprintln!
instead (if ever).
To trigger/verify the changed code, the following commands can be used:
cargo run -- --theme=ansi-light tests/examples/single-line.txt
cargo run -- --theme=does-not-exist tests/examples/single-line.txt
cargo run -- --style=grid,rule tests/examples/single-line.txt
This is a regression test for the fix for issue #299. If that fix is
reverted, currently only one test ('header_padding') fails. But that
test is for a different use case, so add a dedicated regression test for
the particular use case issue #299 is about.
This combines ansi-light and ansi-dark into a single theme that works
with both light and dark backgrounds. Instead of specifying white/black,
the ansi theme uses the terminal's default foreground/background color
by setting alpha=01, i.e. #00000001. This is in addition to the alpha=00
encoding where red contains an ANSI color palette number.
Now, `--theme ansi-light` and `--theme ansi-dark` will print a
deprecation notice and use ansi instead (unless the user has a custom
theme named ansi-light or ansi-dark, which would take precedence).
SC2155: Declare and assign separately to avoid masking return values.
SC2164: Use cd ... || exit in case cd fails.
SC2230: which is non-standard. Use builtin 'command -v' instead.
The macOS version of mktemp does not recognize the --suffix option.
Using pure -d should work since, it seems [1], macOS 10.11 however.
So to make the script work on macOS, stop using the --suffix option.
The downside is of course that the temporary dir will have an anonymous
name, but I see no risk of confusion given how short-lived the usage of
the dir is, and given the context it is used.
[1] https://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x
This fixes#1438.
Note however, that using a pager such as less will add a newline itself.
So to actually not print a newline for such files, you need to either
disable paging:
bat --style=plain --paging=never no-newline-at-end-of-file.txt
or use a "pager" that does not add a newline:
bat --style=plain --pager=cat no-newline-at-end-of-file.txt
Note that we also update syntax tests file since a bunch of them had
missing newlines on the last lines.
Since it has a functional role, we can not just replace it, we must keep
it around. This also allows us to simplify the code slightly.
We must fix this before we fix#1438 since otherwise the \n will be
missing with --style=plain, since we will stop adding it if it is
missing.