From e185f30421cf2247fcb3c50681262e43679435f2 Mon Sep 17 00:00:00 2001 From: Matt Nish-Lapidus Date: Mon, 17 Feb 2025 12:12:38 -0500 Subject: [PATCH] yazi config changes --- flake.lock | 18 +++++++++--------- homes/emenel/dotfiles/dot_config/yazi/init.lua | 5 +++++ .../yazi/plugins/smart-enter.yazi/main.lua | 11 +++++++++++ .../yazi/plugins/smart-tab.yazi/main.lua | 7 +++++++ modules/home/yazi.nix | 6 +++++- 5 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 homes/emenel/dotfiles/dot_config/yazi/plugins/smart-enter.yazi/main.lua create mode 100644 homes/emenel/dotfiles/dot_config/yazi/plugins/smart-tab.yazi/main.lua diff --git a/flake.lock b/flake.lock index ab1a1a6..2783ba0 100644 --- a/flake.lock +++ b/flake.lock @@ -69,11 +69,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1739784040, - "narHash": "sha256-ClWxBsyfs3NrJzrEuHbTMDvOdwldSKPIM3BqN9/Kw9E=", + "lastModified": 1739811682, + "narHash": "sha256-uKHJ7eUG6fLnFYPd9i7xOXbk2oiFE4RGvrh0Y0mhHZA=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "783cff85c13e857ab95b441020621ea64e7a9843", + "rev": "f46d961b45787fd1bd9b46226d094ef7dbc5a2ac", "type": "github" }, "original": { @@ -612,11 +612,11 @@ "uv2nix": "uv2nix" }, "locked": { - "lastModified": 1739737907, - "narHash": "sha256-b5wH4NiFBqQSKRHnAkYrhJBugnr/czUHJdH73dAXWzg=", + "lastModified": 1739810027, + "narHash": "sha256-sp/xGtMWHOHUvlID7hasOf6fxVzURW5MfJAsd2e4cjY=", "owner": "isd-project", "repo": "isd", - "rev": "73df766d2014b9190fe3bc7456bd8b8269886049", + "rev": "ec2453952c246ac2d1fcfc0626118e3ff1c8d7dd", "type": "github" }, "original": { @@ -992,11 +992,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1739580444, - "narHash": "sha256-+/bSz4EAVbqz8/HsIGLroF8aNaO8bLRL7WfACN+24g4=", + "lastModified": 1739736696, + "narHash": "sha256-zON2GNBkzsIyALlOCFiEBcIjI4w38GYOb+P+R4S8Jsw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8bb37161a0488b89830168b81c48aed11569cb93", + "rev": "d74a2335ac9c133d6bbec9fc98d91a77f1604c1f", "type": "github" }, "original": { diff --git a/homes/emenel/dotfiles/dot_config/yazi/init.lua b/homes/emenel/dotfiles/dot_config/yazi/init.lua index 6b1cc51..e0c6bfc 100644 --- a/homes/emenel/dotfiles/dot_config/yazi/init.lua +++ b/homes/emenel/dotfiles/dot_config/yazi/init.lua @@ -1,6 +1,11 @@ require("git"):setup() require("yatline-symlink"):setup() require("dir-rules"):setup() + +require("smart-enter"):setup { + open_multi = true, +} + require("yatline"):setup({ --theme = my_theme, section_separator = { open = "", close = "" }, diff --git a/homes/emenel/dotfiles/dot_config/yazi/plugins/smart-enter.yazi/main.lua b/homes/emenel/dotfiles/dot_config/yazi/plugins/smart-enter.yazi/main.lua new file mode 100644 index 0000000..32d1630 --- /dev/null +++ b/homes/emenel/dotfiles/dot_config/yazi/plugins/smart-enter.yazi/main.lua @@ -0,0 +1,11 @@ +--- @since 25.2.7 +--- @sync entry + +local function setup(self, opts) self.open_multi = opts.open_multi end + +local function entry(self) + local h = cx.active.current.hovered + ya.manager_emit(h and h.cha.is_dir and "enter" or "open", { hovered = not self.open_multi }) +end + +return { entry = entry, setup = setup } diff --git a/homes/emenel/dotfiles/dot_config/yazi/plugins/smart-tab.yazi/main.lua b/homes/emenel/dotfiles/dot_config/yazi/plugins/smart-tab.yazi/main.lua new file mode 100644 index 0000000..ae3de58 --- /dev/null +++ b/homes/emenel/dotfiles/dot_config/yazi/plugins/smart-tab.yazi/main.lua @@ -0,0 +1,7 @@ +--- @sync entry +return { + entry = function() + local h = cx.active.current.hovered + ya.manager_emit("tab_create", h and h.cha.is_dir and { h.url } or { current = true }) + end, +} diff --git a/modules/home/yazi.nix b/modules/home/yazi.nix index 4f98560..d1e8ec8 100644 --- a/modules/home/yazi.nix +++ b/modules/home/yazi.nix @@ -26,7 +26,11 @@ { on = "j"; run = "plugin arrow 1"; desc = "down"; } { on = ""; run = "plugin arrow -1"; desc = "up"; } { on = ""; run = "plugin arrow 1"; desc = "down"; } - { on = "C"; run = "plugin ouch --args=zip"; } + { on = "C"; run = "plugin ouch zip"; } + { on = "T"; run = "plugin smart-tab"; desc = "Create a tab and enter the hovered directory"; } + { on = "l"; run = "plugin smart-enter"; desc = "Enter the child directory, or open the file"; } + { on = ""; run = "plugin smart-enter"; desc = "Enter the child directory, or open the file"; } + { on = ""; run = "plugin smart-enter"; desc = "Enter the child directory, or open the file"; } ]; }; settings = {