From 0af1df52582283201b2b73638a11c14030fd0f44 Mon Sep 17 00:00:00 2001 From: Andy Kipp Date: Wed, 31 Jan 2024 14:07:56 +0100 Subject: [PATCH 01/10] Create xonsh.toml --- src/syntax_mapping/builtins/common/xonsh.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/syntax_mapping/builtins/common/xonsh.toml 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"] From 695cf1f387a970e2706c908d9597bfad85eb97ee Mon Sep 17 00:00:00 2001 From: Andy Kipp Date: Wed, 31 Jan 2024 14:12:00 +0100 Subject: [PATCH 02/10] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8015b14d..06db2cbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - `cmd-help`: scope subcommands followed by other terms, and other misc improvements, see #2819 (@victor-gp) - Upgrade JQ syntax, see #2820 (@dependabot[bot]) +- Associate `xsh` files with `xonsh` syntax that is Python, see #2840 (@anki-code). ## Themes From a5bd9f51be047089a85eab121e0a1a52d213b203 Mon Sep 17 00:00:00 2001 From: mxaddict Date: Sun, 11 Feb 2024 04:57:42 +0800 Subject: [PATCH 03/10] Added JSONC and aws credentials to the syntax mappings --- CHANGELOG.md | 2 ++ src/syntax_mapping/builtins/common/50-aws-credentials.toml | 2 ++ .../builtins/common/{50-jsonl.toml => 50-json.toml} | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 src/syntax_mapping/builtins/common/50-aws-credentials.toml rename src/syntax_mapping/builtins/common/{50-jsonl.toml => 50-json.toml} (65%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6e13469..80923878 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ - Pull in fix for unsafe-libyaml security advisory, see #2812 (@dtolnay) - Update git-version dependency to use Syn v2, see #2816 (@dtolnay) - Update git2 dependency to v0.18.2, see #2852 (@eth-p) +- Added auto detect syntax for `.jsonc` #2795 (@mxaddict) +- Added auto detect syntax for `.aws/{config,credentials}` #2795 (@mxaddict) ## Syntaxes 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"] From 875046e4cdf002b86c36c67fa78442d3090b87ee Mon Sep 17 00:00:00 2001 From: einfachIrgendwer0815 <85333734+einfachIrgendwer0815@users.noreply.github.com> Date: Sat, 3 Feb 2024 22:51:02 +0100 Subject: [PATCH 04/10] Mention which style components are the default --- doc/long-help.txt | 3 +++ src/bin/bat/clap_app.rs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/doc/long-help.txt b/doc/long-help.txt index 247120fb..a68fa175 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 e8222a1d..0bd876ff 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 \ From 75cdabaf13ed45bbf45db8761c6dcbad0e720d0d Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:24:51 +0800 Subject: [PATCH 05/10] Relax syntax mapping rule restrictions to allow brace expansion --- build/syntax_mapping.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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}""#); } From 81aa24310cc87cb66bdcdb93cef6b1650394aabb Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:33:02 +0800 Subject: [PATCH 06/10] Write changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec8348d5..164a5006 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - Pull in fix for unsafe-libyaml security advisory, see #2812 (@dtolnay) - Update git-version dependency to use Syn v2, see #2816 (@dtolnay) - Update git2 dependency to v0.18.2, see #2852 (@eth-p) +- Relax syntax mapping rule restrictions to allow brace expansion #2865 (@cyqsimon) ## Syntaxes From 152d69fe9887a78a4df683afcfd7c2e919f3ca9a Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:49:12 +0800 Subject: [PATCH 07/10] Add syntax mapping for podman quadlets --- src/syntax_mapping/builtins/linux/50-podman-quadlet.toml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/syntax_mapping/builtins/linux/50-podman-quadlet.toml 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}", +] From d499191b0a0f1871a9955af4fb316ba09792a297 Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Tue, 20 Feb 2024 14:54:43 +0800 Subject: [PATCH 08/10] Write changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 164a5006..63824e81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - `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) ## Themes From 92915e22e72496ab256146708f711ad3322f12d7 Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Wed, 21 Feb 2024 00:18:45 +0800 Subject: [PATCH 09/10] Map containers `.conf` files to TOML syntax --- src/syntax_mapping/builtins/linux/50-containers.toml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/syntax_mapping/builtins/linux/50-containers.toml 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", +] From 511cd30105aa2529efcd040a4516c6a0a2a8107f Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Wed, 21 Feb 2024 00:26:23 +0800 Subject: [PATCH 10/10] Write changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec8348d5..f00204c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ - `cmd-help`: scope subcommands followed by other terms, and other misc improvements, see #2819 (@victor-gp) - Upgrade JQ syntax, see #2820 (@dependabot[bot]) +- Map containers .conf files to TOML syntax #2867 (@cyqsimon) ## Themes