Commit Graph

69 Commits

Author SHA1 Message Date
cyqsimon 26ac179548
Add note on thread synchronization 2024-02-26 11:31:30 +08:00
cyqsimon 2b4339663c
Builtin glob matchers build offload, v2 2024-02-21 14:56:37 +08:00
cyqsimon e4d637a3d8
Reverse precedence of syntax mappings specified on CLI 2024-01-18 22:41:57 +08:00
cyqsimon f0a6fe216d
Benchmark prototype 2023-12-11 10:38:59 +08:00
cyqsimon 8a08025091
Disable `builtin_mappings_are_lazily_evaluated` for ARM builds 2023-12-11 10:21:06 +08:00
cyqsimon 586c804b1e
Add test: `builtin_mappings_are_lazily_evaluated` 2023-12-11 10:21:06 +08:00
cyqsimon e30161ac3c
Add test: `builtin_mappings_matcher_only_compile_once` 2023-12-11 10:21:06 +08:00
cyqsimon 3865908439
Add test: `custom_mappings_precedence` 2023-12-11 10:21:06 +08:00
cyqsimon 9474b4cf8b
Rename & sort syntax mapping tests 2023-12-11 10:21:06 +08:00
cyqsimon b48bda21a3
Add test: `all_fixed_builtin_mappings_can_compile` 2023-12-11 10:21:06 +08:00
cyqsimon 36073a3d95
Document another rule ignore condition 2023-12-11 10:21:06 +08:00
cyqsimon 1f10d846a3
Fix tests
1. for override test, test for something in `common`
2. move git mappings to `common`
2023-12-11 10:21:05 +08:00
cyqsimon ad628c0471
Fix iterator lifetime incompatibility 2023-12-11 10:21:05 +08:00
cyqsimon f483d2df42
Lazily compile `GlobMatcher`s 2023-12-11 10:21:05 +08:00
cyqsimon cfd622d6e1
Migrate `SyntaxMapping` impl to new system
Most existing builtins are removed but not yet ported, so the test
`user_can_override_builtin_mappings` should fail. It should pass once the old
rules have been ported.
2023-12-11 10:21:05 +08:00
cyqsimon 1c7c9a6b6d
Split `syntax_mapping/builtin.rs` 2023-12-11 10:21:05 +08:00
cyqsimon de6d418d42
Remove `BuiltinMatcher` enum
Explanation added as comments in code
Using plain `Lazy<Option<GlobMatcher>>` is just better
2023-12-11 10:21:04 +08:00
cyqsimon 7e1fbcfe95
Fix visibility for `SyntaxMapping::get_syntax_for`
This change was made in 31fb708, but then was reverted (I assume incorrectly)
in 6246485.
2023-12-11 10:21:04 +08:00
cyqsimon 64840fbbae
`join_segments` -> `build_glob_string`
- this is a more descriptive name
2023-12-11 10:20:11 +08:00
cyqsimon 9478d2dfe8
Isolate variables at compile time 2023-12-11 10:20:11 +08:00
cyqsimon d24501ab5e
`include!` generated mappings in source 2023-12-11 10:20:11 +08:00
Linda_pp 9f795dd947
Associate `*.sarif` files with `json` syntax (#2695)
* Associate `*.sarif` files with `json` syntax

* Update changelog for #2695
2023-10-04 09:34:40 +02:00
Nicolas AMBRY 5a240f36b9
Case insensitive `--map-syntax` (#2650)
Co-authored-by: Nicolas AMBRY <nicolas.ambry@atos.net>
2023-09-14 16:04:43 +02:00
Orion Yeung 9ba3b6ed13
No duplicate keys test, fixes #2643 (#2647)
* moved unit tests to conditional compile

made module `tests` and conditionally compiled

* added test to check for duplicate keys in builtin

checks all pairs in GlobMatcher::mappings via `GlobMatcher::glob`s `Eq`
panics at first match

```rs
SyntaxMapping {
  mappings: Vec<(
    GlobMatcher {
      glob: Glob, ...,
    }, ...,
  }, ...,
}
```

* output more info with test failure

* dont duplicatively add git config path

* use guard in match for adding builtin git config syntax mapping

---------

Co-authored-by: Orion Yeung <11580988+orionyeung001@users.noreply.github.com>
2023-09-01 21:11:41 +02:00
Orion Yeung f21d3502e1 Add `*.ron` syntax mapping
Add a mapping to use `Rust` for rusty object notation, identified by `.ron` extension. See [#2427](https://github.com/sharkdp/bat/issues/2427).
2023-09-01 17:57:46 +02:00
WinterCore d580445aef fix: Add syntax mapping `jsonl` => `json` 2023-09-01 17:45:41 +02:00
John Higgins b1fbcc8a6e
fix for issue #2633 2023-08-02 00:04:55 -07:00
einfachIrgendwer0815 c46c53320b
Add `Containerfile` syntax mapping 2023-07-02 13:50:37 +02:00
cyqsimon f8c700027e
Add `os-release` syntax mapping 2023-06-01 13:17:22 +08:00
Kid 839e62cff8 Map `fish_history` to YAML 2022-09-04 22:22:18 +02:00
David Peter 48541b8507 Fix clippy suggestions
Leads to a performance improvement for `bat -A`:

    | Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
    |:---|---:|---:|---:|---:|
    | `./bat-master --no-config -A ./bat-master` | 259.8 ± 1.1 | 258.4 | 261.7 | 1.15 ± 0.01 |
    | `./bat-2301 --no-config -A ./bat-master` | 225.6 ± 1.8 | 224.0 | 229.5 | 1.00 |
2022-09-04 14:28:44 +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
Cre3per ed4997c77c
Add syntax mapping from NSE to Lua (#2214) 2022-06-04 14:12:42 +02:00
cyqsimon 3ae05333b0
Add mapping for Unix mail spool (#2156) 2022-04-27 22:51:10 +02:00
TruncatedDinosour cde239e809
Syntax: add clang-format (#2076)
Highlight .clang-format files as YAML

Co-authored-by: Ari Archer <truncateddinosour@gmail.com>
Co-authored-by: David Peter <mail@david-peter.de>
2022-03-06 20:01:49 +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
Martin Nordholts 68528983d7 Mark `MappingTarget` as `#[non_exhaustive]` for increased semver flexibility
This will allow us to add new enum variants in the future without breaking
semver compatibility. See
https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute

Since we already added an enum variant since v0.18.3, now is a good time to mark
it as `#[non_exhaustive]`.
2022-01-04 08:19:51 +01:00
Bojan Đurđević d6ed5e6746
Support for ignored-suffix CLI arguments (#1892) 2021-11-19 17:05:23 +01:00
cbolgiano 7fe4fdf33d
Introduce MapExtensionToUnknown MappingTarget (#1889)
Co-authored-by: Martin Nordholts <enselic@gmail.com>
2021-10-25 17:59:12 +02:00
Marcin Puc 4baa346aae Use deref coercion to simplify some argument passing 2021-09-12 15:50:10 +02:00
Marcin Puc 7956485e37 Improve iterator usage 2021-09-12 15:50:10 +02:00
David Peter 94496df3b0 Fix broken resolv.conf highlighting
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.
2021-02-16 22:15:31 +01:00
David Peter 7eabb5e05a Highlight *.pac files as JavaScript
closes #1515
2021-02-16 21:52:52 +01:00
sharkdp 30993a8bfc Simplify code 2020-10-01 21:06:37 +02:00
sharkdp 2258fb2713 Remove .unwrap() in insert call to prevent crashes 2020-10-01 21:06:37 +02:00
sharkdp a46191b8bf Remove .unwrap() to prevent crashes 2020-10-01 21:06:37 +02:00
sharkdp 9c4c3e965b Remove non-working unit test 2020-10-01 21:06:37 +02:00
Ahmed El Gabri 31acbe20d3 Support XDG_CONFIG_HOME git config files 2020-10-01 21:06:37 +02:00
sharkdp 71b2089384 Code formatting 2020-09-20 20:47:21 +02:00
Kienyew 31fb7087f1 Revert to previous commit 2020-09-20 12:14:21 +02:00