From f4d802a03d4db7b796ce87d6bf299a9476f6e385 Mon Sep 17 00:00:00 2001 From: David Chen Date: Mon, 16 Dec 2024 15:04:51 -0800 Subject: [PATCH] updated yazi plugins --- yazi/package.toml | 2 +- .../DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY | 0 yazi/plugins/smart-enter.yazi/LICENSE | 21 ++++++++++ yazi/plugins/smart-enter.yazi/README.md | 40 +++++++++++++++++++ yazi/plugins/yamb.yazi/.gitattributes | 1 - .../DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY | 0 yazi/plugins/yamb.yazi/README.md | 5 +++ yazi/plugins/yamb.yazi/init.lua | 27 +++++++------ 8 files changed, 82 insertions(+), 14 deletions(-) create mode 100644 yazi/plugins/smart-enter.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY create mode 100644 yazi/plugins/smart-enter.yazi/LICENSE create mode 100644 yazi/plugins/smart-enter.yazi/README.md delete mode 100644 yazi/plugins/yamb.yazi/.gitattributes create mode 100644 yazi/plugins/yamb.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY diff --git a/yazi/package.toml b/yazi/package.toml index 03e96e2..412e361 100644 --- a/yazi/package.toml +++ b/yazi/package.toml @@ -1,5 +1,5 @@ [plugin] -deps = [{ use = "llanosrocas/yaziline", rev = "5886330" }, { use = "Rolv-Apneseth/starship", rev = "247f49d" }, { use = "yazi-rs/plugins:git", rev = "ec97f88" }] +deps = [{ use = "llanosrocas/yaziline", rev = "5886330" }, { use = "Rolv-Apneseth/starship", rev = "247f49d" }, { use = "yazi-rs/plugins:git", rev = "ec97f88" }, { use = "yazi-rs/plugins:smart-enter", rev = "7afba3a" }, { use = "h-hg/yamb", rev = "108347b" }] [flavor] deps = [] diff --git a/yazi/plugins/smart-enter.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY b/yazi/plugins/smart-enter.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY new file mode 100644 index 0000000..e69de29 diff --git a/yazi/plugins/smart-enter.yazi/LICENSE b/yazi/plugins/smart-enter.yazi/LICENSE new file mode 100644 index 0000000..fb5b1d6 --- /dev/null +++ b/yazi/plugins/smart-enter.yazi/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 yazi-rs + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/yazi/plugins/smart-enter.yazi/README.md b/yazi/plugins/smart-enter.yazi/README.md new file mode 100644 index 0000000..d4c6bbd --- /dev/null +++ b/yazi/plugins/smart-enter.yazi/README.md @@ -0,0 +1,40 @@ +# smart-enter.yazi + +[`Open`][open] files or [`enter`][enter] directories all in one key! + +## Installation + +```sh +ya pack -a yazi-rs/plugins:smart-enter +``` + +## Usage + +Bind your l key to the plugin, in your `~/.config/yazi/keymap.toml`: + +```toml +[[manager.prepend_keymap]] +on = "l" +run = "plugin smart-enter" +desc = "Enter the child directory, or open the file" +``` + +## Advanced + +By default, `--hovered` is passed to the [`open`][open] command, make the behavior consistent with [`enter`][enter] avoiding accidental triggers, +which means both will only target the currently hovered file. + +If you still want `open` to target multiple selected files, add this to your `~/.config/yazi/init.lua`: + +```lua +require("smart-enter"):setup { + open_multi = true, +} +``` + +## License + +This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file. + +[open]: https://yazi-rs.github.io/docs/configuration/keymap/#manager.open +[enter]: https://yazi-rs.github.io/docs/configuration/keymap/#manager.enter diff --git a/yazi/plugins/yamb.yazi/.gitattributes b/yazi/plugins/yamb.yazi/.gitattributes deleted file mode 100644 index 94f480d..0000000 --- a/yazi/plugins/yamb.yazi/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -* text=auto eol=lf \ No newline at end of file diff --git a/yazi/plugins/yamb.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY b/yazi/plugins/yamb.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY new file mode 100644 index 0000000..e69de29 diff --git a/yazi/plugins/yamb.yazi/README.md b/yazi/plugins/yamb.yazi/README.md index 40759d4..3f08f48 100644 --- a/yazi/plugins/yamb.yazi/README.md +++ b/yazi/plugins/yamb.yazi/README.md @@ -18,6 +18,9 @@ git clone https://github.com/h-hg/yamb.yazi.git ~/.config/yazi/plugins/yamb.yazi # Windows git clone https://github.com/h-hg/yamb.yazi.git $env:APPDATA\yazi\config\plugins\yamb.yazi + +# if you are using Yazi version >= 3.0 +ya pack -a h-hg/yamb ``` ## Usage @@ -52,6 +55,8 @@ table.insert(bookmarks, { require("yamb"):setup { -- Optional, the path ending with path seperator represents folder. bookmarks = bookmarks, + -- Optional, recieve notification everytime you jump. + jump_notify = true, -- Optional, the cli of fzf. cli = "fzf", -- Optional, a string used for randomly generating keys, where the preceding characters have higher priority. diff --git a/yazi/plugins/yamb.yazi/init.lua b/yazi/plugins/yamb.yazi/init.lua index c6505b7..f3f46dc 100644 --- a/yazi/plugins/yamb.yazi/init.lua +++ b/yazi/plugins/yamb.yazi/init.lua @@ -102,7 +102,7 @@ local which_find = function(bookmarks) return cands[idx].path end -local action_jump = function(bookmarks, path) +local action_jump = function(bookmarks, path, jump_notify) if path == nil then return end @@ -112,12 +112,14 @@ local action_jump = function(bookmarks, path) else ya.manager_emit("reveal", { path }) end - ya.notify { - title = "Bookmarks", - content = 'Jump to "' .. tag .. '"', - timeout = 2, - level = "info", - } + if jump_notify then + ya.notify { + title = "Bookmarks", + content = 'Jump to "' .. tag .. '"', + timeout = 2, + level = "info", + } + end end local generate_key = function(bookmarks) @@ -294,6 +296,7 @@ return { (ya.target_family() == "windows" and os.getenv("APPDATA") .. "\\yazi\\config\\bookmark") or (os.getenv("HOME") .. "/.config/yazi/bookmark") state.cli = options.cli or "fzf" + state.jump_notify = options.jump_notify and true -- init the keys local keys = options.keys or "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" state.keys = {} @@ -325,12 +328,12 @@ return { save_to_file(state.path, bookmarks) state.bookmarks = bookmarks end, - entry = function(self, args) - local action = args[1] + entry = function(self, jobs) + local action = jobs.args[1] if not action then return end - local mb_path, cli, bookmarks = get_state_attr("path"), get_state_attr("cli"), get_state_attr("bookmarks") + local mb_path, cli, bookmarks, jump_notify = get_state_attr("path"), get_state_attr("cli"), get_state_attr("bookmarks"), get_state_attr("jump_notify") if action == "save" then action_save(mb_path, bookmarks, get_hovered_path()) elseif action == "delete_by_key" then @@ -340,9 +343,9 @@ return { elseif action == "delete_all" then action_delete_all(mb_path) elseif action == "jump_by_key" then - action_jump(bookmarks, which_find(bookmarks)) + action_jump(bookmarks, which_find(bookmarks), jump_notify) elseif action == "jump_by_fzf" then - action_jump(bookmarks, fzf_find(cli, mb_path)) + action_jump(bookmarks, fzf_find(cli, mb_path), jump_notify) elseif action == "rename_by_key" then action_save(mb_path, bookmarks, which_find(bookmarks)) elseif action == "rename_by_fzf" then