Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
332 changes: 332 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

118 changes: 73 additions & 45 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,58 +1,86 @@
[workspace]
resolver = "2"
members = [ "yazi-*" ]
default-members = [ "yazi-fm", "yazi-cli" ]
resolver = "2"
members = ["yazi-*"]
default-members = ["yazi-fm", "yazi-cli"]

[profile.release]
codegen-units = 1
lto = true
panic = "abort"
strip = true
lto = true
panic = "abort"
strip = true

[profile.release-windows]
inherits = "release"
panic = "unwind"
panic = "unwind"

[profile.dev-opt]
inherits = "release"
inherits = "release"
codegen-units = 256
incremental = true
lto = false
incremental = true
lto = false

[workspace.dependencies]
ansi-to-tui = "7.0.0"
anyhow = "1.0.100"
base64 = "0.22.1"
bitflags = { version = "2.9.4", features = [ "serde" ] }
clap = { version = "4.5.48", features = [ "derive" ] }
ansi-to-tui = "7.0.0"
anyhow = "1.0.100"
base64 = "0.22.1"
bitflags = { version = "2.9.4", features = ["serde"] }
clap = { version = "4.5.48", features = ["derive"] }
core-foundation-sys = "0.8.7"
crossterm = { version = "0.29.0", features = [ "event-stream" ] }
dirs = "6.0.0"
foldhash = "0.2.0"
futures = "0.3.31"
globset = "0.4.16"
hashbrown = { version = "0.16.0", features = [ "serde" ] }
indexmap = { version = "2.11.4", features = [ "serde" ] }
libc = "0.2.177"
lru = "0.16.1"
mlua = { version = "0.11.4", features = [ "anyhow", "async", "error-send", "lua54", "macros", "serde" ] }
objc = "0.2.7"
ordered-float = { version = "5.1.0", features = [ "serde" ] }
parking_lot = "0.12.5"
paste = "1.0.15"
percent-encoding = "2.3.2"
ratatui = { version = "0.29.0", features = [ "unstable-rendered-line-info", "unstable-widget-ref" ] }
regex = "1.12.1"
russh = { version = "0.54.5", default-features = false, features = [ "ring", "rsa" ] }
scopeguard = "1.2.0"
serde = { version = "1.0.228", features = [ "derive" ] }
serde_json = "1.0.145"
syntect = { version = "5.3.0", default-features = false, features = [ "parsing", "plist-load", "regex-onig" ] }
tokio = { version = "1.47.1", features = [ "full" ] }
tokio-stream = "0.1.17"
tokio-util = "0.7.16"
toml = { version = "0.9.8" }
tracing = { version = "0.1.41", features = [ "max_level_debug", "release_max_level_debug" ] }
twox-hash = { version = "2.1.2", default-features = false, features = [ "std", "random", "xxhash3_128" ] }
unicode-width = { version = "0.2.0", default-features = false }
uzers = "0.12.1"
crossterm = { version = "0.29.0", features = ["event-stream"] }
dirs = "6.0.0"
foldhash = "0.2.0"
futures = "0.3.31"
git2 = { version = "0.19.0", default-features = false, features = [
"vendored-libgit2",
] }
globset = "0.4.16"
hashbrown = { version = "0.16.0", features = ["serde"] }
ignore = "0.4.23"
indexmap = { version = "2.11.4", features = ["serde"] }
libc = "0.2.177"
lru = "0.16.1"
mlua = { version = "0.11.4", features = [
"anyhow",
"async",
"error-send",
"lua54",
"macros",
"serde",
] }
objc = "0.2.7"
ordered-float = { version = "5.1.0", features = ["serde"] }
parking_lot = "0.12.5"
paste = "1.0.15"
percent-encoding = "2.3.2"
ratatui = { version = "0.29.0", features = [
"unstable-rendered-line-info",
"unstable-widget-ref",
] }
regex = "1.12.1"
russh = { version = "0.54.5", default-features = false, features = [
"ring",
"rsa",
] }
scopeguard = "1.2.0"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.145"
syntect = { version = "5.3.0", default-features = false, features = [
"parsing",
"plist-load",
"regex-onig",
] }
tokio = { version = "1.47.1", features = ["full"] }
tokio-stream = "0.1.17"
tokio-util = "0.7.16"
toml = { version = "0.9.8" }
tracing = { version = "0.1.41", features = [
"max_level_debug",
"release_max_level_debug",
] }
twox-hash = { version = "2.1.2", default-features = false, features = [
"std",
"random",
"xxhash3_128",
] }
unicode-width = { version = "0.2.0", default-features = false }
uzers = "0.12.1"
1 change: 1 addition & 0 deletions yazi-actor/src/mgr/cd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ impl Actor for Cd {
err!(Pubsub::pub_after_cd(tab.id, tab.cwd()));
act!(mgr:hidden, cx)?;
act!(mgr:sort, cx)?;
act!(mgr:ignore, cx)?;
act!(mgr:hover, cx)?;
act!(mgr:refresh, cx)?;
succ!(render!());
Expand Down
155 changes: 155 additions & 0 deletions yazi-actor/src/mgr/ignore.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
use anyhow::Result;
use yazi_config::YAZI;
use yazi_core::tab::Folder;
use yazi_fs::{FolderStage, IgnoreFilter};
use yazi_macro::{act, render, render_and, succ};
use yazi_parser::VoidOpt;
use yazi_shared::{data::Data, url::UrlLike};

use crate::{Actor, Ctx};

pub struct Ignore;

impl Actor for Ignore {
type Options = VoidOpt;

const NAME: &str = "ignore";

fn act(cx: &mut Ctx, _: Self::Options) -> Result<Data> {
let gitignore_enabled = YAZI.mgr.gitignore_enable;
let override_patterns = &YAZI.mgr.ignore_override;

// If gitignore is disabled but we have override patterns, apply them
if !gitignore_enabled && !override_patterns.is_empty() {
// Load ignore filter from override patterns only
let ignore_filter = if let Some(path) = cx.cwd().as_path() {
IgnoreFilter::from_patterns(path, override_patterns)
} else {
None
};

let hovered = cx.hovered().map(|f| f.urn().to_owned());
let apply = |f: &mut Folder, filter: Option<IgnoreFilter>| {
// Always set the filter, even when loading
let changed = f.files.set_ignore_filter(filter);
if f.stage == FolderStage::Loading {
render!();
false
} else {
render_and!(changed && f.files.catchup_revision())
}
};

// Apply to CWD
if apply(cx.current_mut(), ignore_filter.clone()) {
act!(mgr:hover, cx)?;
act!(mgr:update_paged, cx)?;
}

// Apply to hovered
if let Some(h) = cx.hovered_folder_mut() {
let hovered_filter = if let Some(path) = h.url.as_path() {
IgnoreFilter::from_patterns(path, override_patterns)
} else {
None
};

if apply(h, hovered_filter) {
render!(h.repos(None));
act!(mgr:peek, cx, true)?;
} else if hovered.as_deref() != cx.hovered().map(|f| f.urn()) {
act!(mgr:peek, cx)?;
act!(mgr:watch, cx)?;
}
}

succ!();
}

// If gitignore is disabled and no override patterns, remove any ignore filter
if !gitignore_enabled {
let hovered = cx.hovered().map(|f| f.urn().to_owned());
let apply = |f: &mut Folder| {
// Always clear the filter, even when loading
let changed = f.files.set_ignore_filter(None);
if f.stage == FolderStage::Loading {
render!();
false
} else {
render_and!(changed && f.files.catchup_revision())
}
};

// Apply to CWD and parent
if let (a, Some(b)) = (apply(cx.current_mut()), cx.parent_mut().map(apply))
&& (a | b)
{
act!(mgr:hover, cx)?;
act!(mgr:update_paged, cx)?;
}

// Apply to hovered
if let Some(h) = cx.hovered_folder_mut()
&& apply(h)
{
render!(h.repos(None));
act!(mgr:peek, cx, true)?;
} else if hovered.as_deref() != cx.hovered().map(|f| f.urn()) {
act!(mgr:peek, cx)?;
act!(mgr:watch, cx)?;
}

succ!();
}

// Load ignore filter from the current directory
let ignore_filter = if let Some(path) = cx.cwd().as_path() {
IgnoreFilter::from_dir(path, override_patterns)
} else {
None
};

let hovered = cx.hovered().map(|f| f.urn().to_owned());
let apply = |f: &mut Folder, filter: Option<IgnoreFilter>| {
// Always set the filter, even when loading, so files are filtered as they
// arrive
let changed = f.files.set_ignore_filter(filter);
if f.stage == FolderStage::Loading {
render!();
false
} else {
render_and!(changed && f.files.catchup_revision())
}
};

// Apply to CWD
if apply(cx.current_mut(), ignore_filter.clone()) {
act!(mgr:hover, cx)?;
act!(mgr:update_paged, cx)?;
}

// Apply to parent (they should use their own ignore file, so we don't apply the
// same filter) Parent folders will be updated when they become the current
// directory

// Apply to hovered
if let Some(h) = cx.hovered_folder_mut() {
// Load ignore filter for hovered directory if it's a directory
let hovered_filter = if let Some(path) = h.url.as_path() {
IgnoreFilter::from_dir(path, override_patterns)
} else {
None
};

if apply(h, hovered_filter) {
render!(h.repos(None));
act!(mgr:peek, cx, true)?;
} else if hovered.as_deref() != cx.hovered().map(|f| f.urn()) {
act!(mgr:peek, cx)?;
act!(mgr:watch, cx)?;
}
}

succ!();
}
}
1 change: 1 addition & 0 deletions yazi-actor/src/mgr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ yazi_macro::mod_flat!(
hardlink
hidden
hover
ignore
leave
linemode
link
Expand Down
3 changes: 3 additions & 0 deletions yazi-actor/src/mgr/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ impl Actor for Refresh {
execute!(TTY.writer(), SetTitle(s)).ok();
}

// Apply ignore filter before triggering file loads
act!(mgr:ignore, cx)?;

if let Some(p) = cx.parent() {
Self::trigger_dirs(&[cx.current(), p]);
} else {
Expand Down
8 changes: 8 additions & 0 deletions yazi-config/preset/yazi-default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ scrolloff = 5
mouse_events = [ "click", "scroll" ]
title_format = "Yazi: {cwd}"

# Git ignore integration
# gitignore_enable = false
# ignore_override = [
# "*.log", # Hide all .log files
# "tmp/", # Hide tmp directory
# "!target/", # Show target/ even if gitignored (negation)
# ]

[preview]
wrap = "no"
tab_size = 2
Expand Down
6 changes: 6 additions & 0 deletions yazi-config/src/mgr/mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ pub struct Mgr {
pub scrolloff: SyncCell<u8>,
pub mouse_events: SyncCell<MouseEvents>,
pub title_format: String,

// Filtering
#[serde(default)]
pub gitignore_enable: bool,
#[serde(default)]
pub ignore_override: Vec<String>,
}

impl Mgr {
Expand Down
3 changes: 3 additions & 0 deletions yazi-dds/src/spark/spark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub enum Spark<'a> {
Forward(yazi_parser::VoidOpt),
Hardlink(yazi_parser::mgr::HardlinkOpt),
Hidden(yazi_parser::mgr::HiddenOpt),
Ignore(yazi_parser::VoidOpt),
Hover(yazi_parser::mgr::HoverOpt),
Leave(yazi_parser::VoidOpt),
Linemode(yazi_parser::mgr::LinemodeOpt),
Expand Down Expand Up @@ -155,6 +156,7 @@ impl<'a> IntoLua for Spark<'a> {
Self::Forward(b) => b.into_lua(lua),
Self::Hardlink(b) => b.into_lua(lua),
Self::Hidden(b) => b.into_lua(lua),
Self::Ignore(b) => b.into_lua(lua),
Self::Hover(b) => b.into_lua(lua),
Self::Leave(b) => b.into_lua(lua),
Self::Linemode(b) => b.into_lua(lua),
Expand Down Expand Up @@ -253,6 +255,7 @@ try_from_spark!(
mgr:escape_visual,
mgr:follow,
mgr:forward,
mgr:ignore,
mgr:leave,
mgr:refresh,
mgr:search_stop,
Expand Down
1 change: 1 addition & 0 deletions yazi-fm/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl<'a> Executor<'a> {
on!(copy);
on!(shell);
on!(hidden);
on!(ignore);
on!(linemode);
on!(search);
on!(search_do);
Expand Down
Loading
Loading