diff --git a/Cargo.lock b/Cargo.lock index beb0eb31..edc3ca34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2616,7 +2616,7 @@ dependencies = [ [[package]] name = "yazi-adaptor" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "arc-swap", @@ -2634,7 +2634,7 @@ dependencies = [ [[package]] name = "yazi-config" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "arc-swap", @@ -2659,7 +2659,7 @@ dependencies = [ [[package]] name = "yazi-core" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "base64", @@ -2688,7 +2688,7 @@ dependencies = [ [[package]] name = "yazi-fm" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "better-panic", @@ -2715,7 +2715,7 @@ dependencies = [ [[package]] name = "yazi-plugin" -version = "0.2.1" +version = "0.2.2" dependencies = [ "ansi-to-tui", "anyhow", @@ -2748,7 +2748,7 @@ checksum = "f4b6c8e12e39ac0f79fa96f36e5b88e0da8d230691abd729eec709b43c74f632" [[package]] name = "yazi-scheduler" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "async-priority-channel", @@ -2769,7 +2769,7 @@ dependencies = [ [[package]] name = "yazi-shared" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "bitflags 2.4.1", diff --git a/scripts/bump.sh b/scripts/bump.sh index 7dd2c8f9..fd698e71 100755 --- a/scripts/bump.sh +++ b/scripts/bump.sh @@ -7,5 +7,7 @@ cd $SCRIPT_DIR/.. echo "Bumping version: $1" TOML_FILES="$(git ls-files '*Cargo.toml')" -perl -pi -e "s/^version .*= .*\$/version = \"$1\"/" $TOML_FILES -perl -pi -e "s/^(yazi-[a-z]+)\\s*=\\s*{.*\$/\\1 = { path = \"..\/\\1\", version = \"$1\" }/" $TOML_FILES +perl -pi -e "s/^version .*= .*\$/version = \"$1\"/" -- $TOML_FILES +perl -pi -e "s/^(yazi-[a-z]+)\\s*=\\s*{.*\$/\\1 = { path = \"..\/\\1\", version = \"$1\" }/" -- $TOML_FILES + +ESLINT_USE_FLAT_CONFIG=true eslint -c ~/.config/rules/eslint/eslint.config.cjs --fix -- $TOML_FILES diff --git a/yazi-adaptor/Cargo.toml b/yazi-adaptor/Cargo.toml index ea3f12c3..29a8922e 100644 --- a/yazi-adaptor/Cargo.toml +++ b/yazi-adaptor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yazi-adaptor" -version = "0.2.1" +version = "0.2.2" edition = "2021" license = "MIT" authors = [ "sxyazi " ] @@ -9,8 +9,8 @@ homepage = "https://yazi-rs.github.io" repository = "https://github.com/sxyazi/yazi" [dependencies] -yazi-config = { path = "../yazi-config", version = "0.2.1" } -yazi-shared = { path = "../yazi-shared", version = "0.2.1" } +yazi-config = { path = "../yazi-config", version = "0.2.2" } +yazi-shared = { path = "../yazi-shared", version = "0.2.2" } # External dependencies anyhow = "^1" diff --git a/yazi-config/Cargo.toml b/yazi-config/Cargo.toml index 8a96bf64..3b893774 100644 --- a/yazi-config/Cargo.toml +++ b/yazi-config/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yazi-config" -version = "0.2.1" +version = "0.2.2" edition = "2021" license = "MIT" authors = [ "sxyazi " ] @@ -9,7 +9,7 @@ homepage = "https://yazi-rs.github.io" repository = "https://github.com/sxyazi/yazi" [dependencies] -yazi-shared = { path = "../yazi-shared", version = "0.2.1" } +yazi-shared = { path = "../yazi-shared", version = "0.2.2" } # External dependencies anyhow = "^1" diff --git a/yazi-config/src/keymap/keymap.rs b/yazi-config/src/keymap/keymap.rs index b5f2c5e2..f3b7adcf 100644 --- a/yazi-config/src/keymap/keymap.rs +++ b/yazi-config/src/keymap/keymap.rs @@ -2,7 +2,7 @@ use serde::{Deserialize, Deserializer}; use yazi_shared::Layer; use super::Control; -use crate::MERGED_KEYMAP; +use crate::{Preset, MERGED_KEYMAP}; #[derive(Debug)] pub struct Keymap { @@ -30,12 +30,29 @@ impl<'de> Deserialize<'de> for Keymap { } #[derive(Deserialize)] struct Inner { - keymap: Vec, + keymap: Vec, + #[serde(default)] + prepend_keymap: Vec, + #[serde(default)] + append_keymap: Vec, } - let shadow = Shadow::deserialize(deserializer)?; + let mut shadow = Shadow::deserialize(deserializer)?; - // TODO: remove this when v0.2.0 is released -- + #[rustfmt::skip] + Preset::mix(&mut shadow.manager.keymap, shadow.manager.prepend_keymap, shadow.manager.append_keymap); + #[rustfmt::skip] + Preset::mix(&mut shadow.tasks.keymap, shadow.tasks.prepend_keymap, shadow.tasks.append_keymap); + #[rustfmt::skip] + Preset::mix(&mut shadow.select.keymap, shadow.select.prepend_keymap, shadow.select.append_keymap); + #[rustfmt::skip] + Preset::mix(&mut shadow.input.keymap, shadow.input.prepend_keymap, shadow.input.append_keymap); + #[rustfmt::skip] + Preset::mix(&mut shadow.help.keymap, shadow.help.prepend_keymap, shadow.help.append_keymap); + #[rustfmt::skip] + Preset::mix(&mut shadow.completion.keymap, shadow.completion.prepend_keymap, shadow.completion.append_keymap); + + // TODO: remove this when v0.2.3 is released -- if !shadow.input.keymap.iter().any(|c| c.on() == "") { println!( "WARNING: Default keybinding for `` is missing, please add a `{}` to the `[input]` section of `keymap.toml`. @@ -43,7 +60,15 @@ In Yazi v0.2.0, `` previously hardcoded within the input component ha r#"{ on = [ "" ], exec = "backspace" }"# ); } - // TODO: -- remove this when v0.2.0 is released + // TODO: -- remove this when v0.2.3 is released + + // TODO: remove this when v0.2.3 is released -- + if shadow.manager.keymap.iter().any(|c| c.exec().contains("--empty=name")) { + println!( + "WARNING: `rename --empty=name` is deprecated in Yazi v0.2.2, please use `rename --empty=stem` instead.", + ); + } + // TODO: -- remove this when v0.2.3 is released Ok(Self { manager: shadow.manager.keymap, diff --git a/yazi-config/src/plugin/plugin.rs b/yazi-config/src/plugin/plugin.rs index 8c73ab80..85c9d2c4 100644 --- a/yazi-config/src/plugin/plugin.rs +++ b/yazi-config/src/plugin/plugin.rs @@ -3,7 +3,7 @@ use std::path::Path; use serde::Deserialize; use yazi_shared::{event::Exec, Condition, MIME_DIR}; -use crate::{pattern::Pattern, plugin::MAX_PRELOADERS, Priority, MERGED_YAZI}; +use crate::{pattern::Pattern, plugin::MAX_PRELOADERS, Preset, Priority, MERGED_YAZI}; #[derive(Deserialize)] pub struct Plugin { @@ -30,6 +30,11 @@ pub struct PluginRule { impl Default for Plugin { fn default() -> Self { + #[derive(Deserialize)] + struct Outer { + plugin: Shadow, + } + #[derive(Deserialize)] struct Shadow { preloaders: Vec, @@ -45,24 +50,9 @@ impl Default for Plugin { append_previewers: Vec, } - #[derive(Deserialize)] - struct Outer { - plugin: Shadow, - } - let mut shadow = toml::from_str::(&MERGED_YAZI).unwrap().plugin; - shadow.preloaders = shadow - .prepend_preloaders - .into_iter() - .chain(shadow.preloaders) - .chain(shadow.append_preloaders) - .collect(); - shadow.previewers = shadow - .prepend_previewers - .into_iter() - .chain(shadow.previewers) - .chain(shadow.append_previewers) - .collect(); + Preset::mix(&mut shadow.preloaders, shadow.prepend_preloaders, shadow.append_preloaders); + Preset::mix(&mut shadow.previewers, shadow.prepend_previewers, shadow.append_previewers); if shadow.preloaders.len() > MAX_PRELOADERS as usize { panic!("Too many preloaders"); diff --git a/yazi-config/src/preset.rs b/yazi-config/src/preset.rs index 3ad63f79..52427287 100644 --- a/yazi-config/src/preset.rs +++ b/yazi-config/src/preset.rs @@ -1,4 +1,4 @@ -use std::fs; +use std::{fs, mem}; use toml::Table; @@ -7,6 +7,26 @@ use crate::BOOT; pub(crate) struct Preset; impl Preset { + #[inline] + pub(crate) fn keymap() -> String { + Self::merge_str("keymap.toml", include_str!("../preset/keymap.toml")) + } + + #[inline] + pub(crate) fn theme() -> String { + Self::merge_str("theme.toml", include_str!("../preset/theme.toml")) + } + + #[inline] + pub(crate) fn yazi() -> String { + Self::merge_str("yazi.toml", include_str!("../preset/yazi.toml")) + } + + #[inline] + pub(crate) fn mix(a: &mut Vec, b: Vec, c: Vec) { + *a = b.into_iter().chain(mem::take(a)).chain(c).collect(); + } + fn merge(a: &mut Table, b: &Table, max: u8) { for (k, v) in b { let Some(a) = a.get_mut(k) else { @@ -14,7 +34,7 @@ impl Preset { continue; }; - if k == "icons" || max <= 1 { + if max <= 1 { continue; } @@ -36,19 +56,4 @@ impl Preset { Self::merge(&mut user, &base, 2); user.to_string() } - - #[inline] - pub(crate) fn keymap() -> String { - Self::merge_str("keymap.toml", include_str!("../preset/keymap.toml")) - } - - #[inline] - pub(crate) fn theme() -> String { - Self::merge_str("theme.toml", include_str!("../preset/theme.toml")) - } - - #[inline] - pub(crate) fn yazi() -> String { - Self::merge_str("yazi.toml", include_str!("../preset/yazi.toml")) - } } diff --git a/yazi-core/Cargo.toml b/yazi-core/Cargo.toml index a79b232a..573a5288 100644 --- a/yazi-core/Cargo.toml +++ b/yazi-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yazi-core" -version = "0.2.1" +version = "0.2.2" edition = "2021" license = "MIT" authors = [ "sxyazi " ] @@ -9,11 +9,11 @@ homepage = "https://yazi-rs.github.io" repository = "https://github.com/sxyazi/yazi" [dependencies] -yazi-adaptor = { path = "../yazi-adaptor", version = "0.2.1" } -yazi-config = { path = "../yazi-config", version = "0.2.1" } -yazi-plugin = { path = "../yazi-plugin", version = "0.2.1" } -yazi-scheduler = { path = "../yazi-scheduler", version = "0.2.1" } -yazi-shared = { path = "../yazi-shared", version = "0.2.1" } +yazi-adaptor = { path = "../yazi-adaptor", version = "0.2.2" } +yazi-config = { path = "../yazi-config", version = "0.2.2" } +yazi-plugin = { path = "../yazi-plugin", version = "0.2.2" } +yazi-scheduler = { path = "../yazi-scheduler", version = "0.2.2" } +yazi-shared = { path = "../yazi-shared", version = "0.2.2" } # External dependencies anyhow = "^1" diff --git a/yazi-core/src/manager/commands/rename.rs b/yazi-core/src/manager/commands/rename.rs index 14f2e0f1..a4b56119 100644 --- a/yazi-core/src/manager/commands/rename.rs +++ b/yazi-core/src/manager/commands/rename.rs @@ -33,7 +33,7 @@ impl Manager { let ext = url.extension(); match by { - "name" => ext.map_or_else(String::new, |s| format!(".{}", s.to_string_lossy().into_owned())), + "stem" => ext.map_or_else(String::new, |s| format!(".{}", s.to_string_lossy().into_owned())), "ext" if ext.is_some() => format!("{}.", url.file_stem().unwrap().to_string_lossy()), "dot_ext" if ext.is_some() => url.file_stem().unwrap().to_string_lossy().into_owned(), _ => url.file_name().map_or_else(String::new, |s| s.to_string_lossy().into_owned()), diff --git a/yazi-fm/Cargo.toml b/yazi-fm/Cargo.toml index 83b1cdec..adca7683 100644 --- a/yazi-fm/Cargo.toml +++ b/yazi-fm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yazi-fm" -version = "0.2.1" +version = "0.2.2" edition = "2021" license = "MIT" authors = [ "sxyazi " ] @@ -9,12 +9,12 @@ homepage = "https://yazi-rs.github.io" repository = "https://github.com/sxyazi/yazi" [dependencies] -yazi-adaptor = { path = "../yazi-adaptor", version = "0.2.1" } -yazi-config = { path = "../yazi-config", version = "0.2.1" } -yazi-core = { path = "../yazi-core", version = "0.2.1" } -yazi-plugin = { path = "../yazi-plugin", version = "0.2.1" } -yazi-scheduler = { path = "../yazi-scheduler", version = "0.2.1" } -yazi-shared = { path = "../yazi-shared", version = "0.2.1" } +yazi-adaptor = { path = "../yazi-adaptor", version = "0.2.2" } +yazi-config = { path = "../yazi-config", version = "0.2.2" } +yazi-core = { path = "../yazi-core", version = "0.2.2" } +yazi-plugin = { path = "../yazi-plugin", version = "0.2.2" } +yazi-scheduler = { path = "../yazi-scheduler", version = "0.2.2" } +yazi-shared = { path = "../yazi-shared", version = "0.2.2" } # External dependencies anyhow = "^1" diff --git a/yazi-plugin/Cargo.toml b/yazi-plugin/Cargo.toml index 4d47b863..0235eb41 100644 --- a/yazi-plugin/Cargo.toml +++ b/yazi-plugin/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yazi-plugin" -version = "0.2.1" +version = "0.2.2" edition = "2021" license = "MIT" authors = [ "sxyazi " ] @@ -9,9 +9,9 @@ homepage = "https://yazi-rs.github.io" repository = "https://github.com/sxyazi/yazi" [dependencies] -yazi-adaptor = { path = "../yazi-adaptor", version = "0.2.1" } -yazi-config = { path = "../yazi-config", version = "0.2.1" } -yazi-shared = { path = "../yazi-shared", version = "0.2.1" } +yazi-adaptor = { path = "../yazi-adaptor", version = "0.2.2" } +yazi-config = { path = "../yazi-config", version = "0.2.2" } +yazi-shared = { path = "../yazi-shared", version = "0.2.2" } # External dependencies ansi-to-tui = "^3" diff --git a/yazi-scheduler/Cargo.toml b/yazi-scheduler/Cargo.toml index 9237ab3b..be0a828f 100644 --- a/yazi-scheduler/Cargo.toml +++ b/yazi-scheduler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yazi-scheduler" -version = "0.2.1" +version = "0.2.2" edition = "2021" license = "MIT" authors = [ "sxyazi " ] @@ -9,10 +9,10 @@ homepage = "https://yazi-rs.github.io" repository = "https://github.com/sxyazi/yazi" [dependencies] -yazi-adaptor = { path = "../yazi-adaptor", version = "0.2.1" } -yazi-config = { path = "../yazi-config", version = "0.2.1" } -yazi-shared = { path = "../yazi-shared", version = "0.2.1" } -yazi-plugin = { path = "../yazi-plugin", version = "0.2.1" } +yazi-adaptor = { path = "../yazi-adaptor", version = "0.2.2" } +yazi-config = { path = "../yazi-config", version = "0.2.2" } +yazi-shared = { path = "../yazi-shared", version = "0.2.2" } +yazi-plugin = { path = "../yazi-plugin", version = "0.2.2" } # External dependencies anyhow = "^1" diff --git a/yazi-shared/Cargo.toml b/yazi-shared/Cargo.toml index 05e64b9a..7ce99f74 100644 --- a/yazi-shared/Cargo.toml +++ b/yazi-shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yazi-shared" -version = "0.2.1" +version = "0.2.2" edition = "2021" license = "MIT" authors = [ "sxyazi " ]