diff --git a/CHANGELOG.md b/CHANGELOG.md index 03c7d6b1..3c95cf9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,12 +27,18 @@ - Update git-version dependency to use Syn v2, see #2816 (@dtolnay) - Update git2 dependency to v0.18.2, see #2852 (@eth-p) - Improve performance when color output disabled, see #2397 and #2857 (@eth-p) +- Relax syntax mapping rule restrictions to allow brace expansion #2865 (@cyqsimon) - Apply clippy fixes #2864 (@cyqsimon) ## Syntaxes - `cmd-help`: scope subcommands followed by other terms, and other misc improvements, see #2819 (@victor-gp) - Upgrade JQ syntax, see #2820 (@dependabot[bot]) +- Add syntax mapping for quadman quadlets #2866 (@cyqsimon) +- Map containers .conf files to TOML syntax #2867 (@cyqsimon) +- Associate `xsh` files with `xonsh` syntax that is Python, see #2840 (@anki-code). +- Added auto detect syntax for `.jsonc` #2795 (@mxaddict) +- Added auto detect syntax for `.aws/{config,credentials}` #2795 (@mxaddict) ## Themes diff --git a/build/syntax_mapping.rs b/build/syntax_mapping.rs index 959caea8..91a448f6 100644 --- a/build/syntax_mapping.rs +++ b/build/syntax_mapping.rs @@ -53,14 +53,16 @@ struct Matcher(Vec); /// /// Note that this implementation is rather strict: it will greedily interpret /// every valid environment variable replacement as such, then immediately -/// hard-error if it finds a '$', '{', or '}' anywhere in the remaining text -/// segments. +/// hard-error if it finds a '$' anywhere in the remaining text segments. /// /// The reason for this strictness is I currently cannot think of a valid reason -/// why you would ever need '$', '{', or '}' as plaintext in a glob pattern. -/// Therefore any such occurrences are likely human errors. +/// why you would ever need '$' as plaintext in a glob pattern. Therefore any +/// such occurrences are likely human errors. /// /// If we later discover some edge cases, it's okay to make it more permissive. +/// +/// Revision history: +/// - 2024-02-20: allow `{` and `}` (glob brace expansion) impl FromStr for Matcher { type Err = anyhow::Error; fn from_str(s: &str) -> Result { @@ -106,7 +108,7 @@ impl FromStr for Matcher { if non_empty_segments .iter() .filter_map(Seg::text) - .any(|t| t.contains(['$', '{', '}'])) + .any(|t| t.contains('$')) { bail!(r#"Invalid matcher: "{s}""#); } diff --git a/doc/long-help.txt b/doc/long-help.txt index 3ac4a40f..1aae60d8 100644 --- a/doc/long-help.txt +++ b/doc/long-help.txt @@ -123,6 +123,9 @@ Options: set a default style, add the '--style=".."' option to the configuration file or export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). + By default, the following components are enabled: + changes, grid, header-filename, numbers, snip + Possible values: * default: enables recommended style components (default). diff --git a/src/bin/bat/clap_app.rs b/src/bin/bat/clap_app.rs index 6ceed784..d3cb9276 100644 --- a/src/bin/bat/clap_app.rs +++ b/src/bin/bat/clap_app.rs @@ -432,6 +432,8 @@ pub fn build_app(interactive_output: bool) -> Command { pre-defined style ('full'). To set a default style, add the \ '--style=\"..\"' option to the configuration file or export the \ BAT_STYLE environment variable (e.g.: export BAT_STYLE=\"..\").\n\n\ + By default, the following components are enabled:\n \ + changes, grid, header-filename, numbers, snip\n\n\ Possible values:\n\n \ * default: enables recommended style components (default).\n \ * full: enables all available components.\n \ diff --git a/src/syntax_mapping/builtins/common/50-aws-credentials.toml b/src/syntax_mapping/builtins/common/50-aws-credentials.toml new file mode 100644 index 00000000..a16e6e8f --- /dev/null +++ b/src/syntax_mapping/builtins/common/50-aws-credentials.toml @@ -0,0 +1,2 @@ +[mappings] +"INI" = ["**/.aws/credentials", "**/.aws/config"] diff --git a/src/syntax_mapping/builtins/common/50-jsonl.toml b/src/syntax_mapping/builtins/common/50-json.toml similarity index 65% rename from src/syntax_mapping/builtins/common/50-jsonl.toml rename to src/syntax_mapping/builtins/common/50-json.toml index 4b70a4d0..e604868a 100644 --- a/src/syntax_mapping/builtins/common/50-jsonl.toml +++ b/src/syntax_mapping/builtins/common/50-json.toml @@ -1,3 +1,3 @@ # JSON Lines is a simple variation of JSON #2535 [mappings] -"JSON" = ["*.jsonl"] +"JSON" = ["*.jsonl", "*.jsonc"] diff --git a/src/syntax_mapping/builtins/common/xonsh.toml b/src/syntax_mapping/builtins/common/xonsh.toml new file mode 100644 index 00000000..8e472b41 --- /dev/null +++ b/src/syntax_mapping/builtins/common/xonsh.toml @@ -0,0 +1,3 @@ +# Xonsh shell (https://xon.sh/) +[mappings] +"Python" = ["*.xsh", "*.xonshrc"] diff --git a/src/syntax_mapping/builtins/linux/50-containers.toml b/src/syntax_mapping/builtins/linux/50-containers.toml new file mode 100644 index 00000000..b7170b87 --- /dev/null +++ b/src/syntax_mapping/builtins/linux/50-containers.toml @@ -0,0 +1,8 @@ +# see https://github.com/containers/image/tree/main/docs +[mappings] +"TOML" = [ + "/usr/share/containers/**/*.conf", + "/etc/containers/**/*.conf", + "${HOME}/.config/containers/**/*.conf", + "${XDG_CONFIG_HOME}/containers/**/*.conf", +] diff --git a/src/syntax_mapping/builtins/linux/50-podman-quadlet.toml b/src/syntax_mapping/builtins/linux/50-podman-quadlet.toml new file mode 100644 index 00000000..add74188 --- /dev/null +++ b/src/syntax_mapping/builtins/linux/50-podman-quadlet.toml @@ -0,0 +1,7 @@ +# see `man quadlet` +[mappings] +"INI" = [ + "**/containers/systemd/*.{container,volume,network,kube,image}", + "**/containers/systemd/users/*.{container,volume,network,kube,image}", + "**/containers/systemd/users/*/*.{container,volume,network,kube,image}", +]