From c5a806d93d16b9ea8414c949bf6e3234bdf53311 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 10 Dec 2024 14:37:52 -0600 Subject: [PATCH] terminal/tools/yazi: use yazi-plugins instead of local copies Dont want to manage them if they are upstreamed and maintained --- .../yazi/configs/plugins/chmod.yazi/LICENSE | 21 ------- .../yazi/configs/plugins/chmod.yazi/README.md | 24 -------- .../yazi/configs/plugins/chmod.yazi/init.lua | 42 -------------- .../yazi/configs/plugins/diff.yazi/LICENSE | 21 ------- .../yazi/configs/plugins/diff.yazi/README.md | 24 -------- .../yazi/configs/plugins/diff.yazi/init.lua | 39 ------------- .../configs/plugins/full-border.yazi/LICENSE | 21 ------- .../configs/plugins/full-border.yazi/init.lua | 55 ------------------- .../configs/plugins/hide-preview.yazi/LICENSE | 21 ------- .../plugins/hide-preview.yazi/README.md | 24 -------- .../plugins/hide-preview.yazi/init.lua | 27 --------- .../configs/plugins/jump-to-char.yazi/LICENSE | 21 ------- .../plugins/jump-to-char.yazi/README.md | 24 -------- .../plugins/jump-to-char.yazi/init.lua | 32 ----------- .../configs/plugins/max-preview.yazi/LICENSE | 21 ------- .../plugins/max-preview.yazi/README.md | 24 -------- .../configs/plugins/max-preview.yazi/init.lua | 26 --------- .../configs/plugins/smart-enter.yazi/init.lua | 12 ---- .../configs/plugins/smart-filter.yazi/LICENSE | 21 ------- .../plugins/smart-filter.yazi/README.md | 24 -------- .../plugins/smart-filter.yazi/init.lua | 47 ---------------- .../programs/terminal/tools/yazi/default.nix | 27 ++++----- 22 files changed, 14 insertions(+), 584 deletions(-) delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/LICENSE delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/README.md delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/init.lua delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/LICENSE delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/README.md delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/init.lua delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/full-border.yazi/LICENSE delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/full-border.yazi/init.lua delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/LICENSE delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/README.md delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/init.lua delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/LICENSE delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/README.md delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/init.lua delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/LICENSE delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/README.md delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/init.lua delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/smart-enter.yazi/init.lua delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/LICENSE delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/README.md delete mode 100644 modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/init.lua diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/LICENSE b/modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/LICENSE deleted file mode 100644 index fb5b1d627..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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/modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/README.md b/modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/README.md deleted file mode 100644 index 95fab1718..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# chmod.yazi - -Execute `chmod` on the selected files to change their mode. This plugin is only available on Unix platforms since it relies on [`chmod(2)`](https://man7.org/linux/man-pages/man2/chmod.2.html). - -https://github.com/yazi-rs/plugins/assets/17523360/7aa3abc2-d057-498c-8473-a6282c59c464 - -## Installation - -```sh -ya pack -a yazi-rs/plugins#chmod -``` - -## Usage - -Add this to your `~/.config/yazi/keymap.toml`: - -```toml -[[manager.prepend_keymap]] -on = [ "c", "m" ] -run = "plugin chmod" -desc = "Chmod on selected files" -``` - -Make sure the c => m key is not used elsewhere. diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/init.lua b/modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/init.lua deleted file mode 100644 index 6d6c1c474..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/chmod.yazi/init.lua +++ /dev/null @@ -1,42 +0,0 @@ -local selected_or_hovered = ya.sync(function() - local tab, paths = cx.active, {} - for _, u in pairs(tab.selected) do - paths[#paths + 1] = tostring(u) - end - if #paths == 0 and tab.current.hovered then - paths[1] = tostring(tab.current.hovered.url) - end - return paths -end) - -return { - entry = function() - ya.manager_emit("escape", { visual = true }) - - local urls = selected_or_hovered() - if #urls == 0 then - return ya.notify({ title = "Chmod", content = "No file selected", level = "warn", timeout = 5 }) - end - - local value, event = ya.input({ - title = "Chmod:", - position = { "top-center", y = 3, w = 40 }, - }) - if event ~= 1 then - return - end - - local status, err = Command("chmod"):arg(value):args(urls):spawn():wait() - if not status or not status.success then - ya.notify({ - title = "Chmod", - content = string.format( - "Chmod with selected files failed, exit code %s", - status and status.code or err - ), - level = "error", - timeout = 5, - }) - end - end, -} diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/LICENSE b/modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/LICENSE deleted file mode 100644 index fb5b1d627..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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/modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/README.md b/modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/README.md deleted file mode 100644 index cc21344bf..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# diff.yazi - -Diff the selected file with the hovered file, create a living patch, and copy it to the clipboard. - -https://github.com/yazi-rs/plugins/assets/17523360/eff5e949-386a-44ea-82f9-4cb4a2c37aad - -## Installation - -```sh -ya pack -a yazi-rs/plugins#diff -``` - -## Usage - -Add this to your `~/.config/yazi/keymap.toml`: - -```toml -[[manager.prepend_keymap]] -on = "" -run = "plugin diff" -desc = "Diff the selected with the hovered file" -``` - -Make sure the C + d key is not used elsewhere. diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/init.lua b/modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/init.lua deleted file mode 100644 index 275e4edb3..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/diff.yazi/init.lua +++ /dev/null @@ -1,39 +0,0 @@ -local function info(content) - return ya.notify({ - title = "Diff", - content = content, - timeout = 5, - }) -end - -local selected_url = ya.sync(function() - for _, u in pairs(cx.active.selected) do - return u - end -end) - -local hovered_url = ya.sync(function() - local h = cx.active.current.hovered - return h and h.url -end) - -return { - entry = function() - local a, b = selected_url(), hovered_url() - if not a then - return info("No file selected") - elseif not b then - return info("No file hovered") - end - - local output, err = Command("diff"):arg("-Naur"):arg(tostring(a)):arg(tostring(b)):output() - if not output then - return info("Failed to run diff, error: " .. err) - elseif output.stdout == "" then - return info("No differences found") - end - - ya.clipboard(output.stdout) - info("Diff copied to clipboard") - end, -} diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/full-border.yazi/LICENSE b/modules/home/programs/terminal/tools/yazi/configs/plugins/full-border.yazi/LICENSE deleted file mode 100644 index fb5b1d627..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/full-border.yazi/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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/modules/home/programs/terminal/tools/yazi/configs/plugins/full-border.yazi/init.lua b/modules/home/programs/terminal/tools/yazi/configs/plugins/full-border.yazi/init.lua deleted file mode 100644 index 76a3fd65d..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/full-border.yazi/init.lua +++ /dev/null @@ -1,55 +0,0 @@ --- TODO: remove this once v0.4 is released -local v4 = function(typ, area, ...) - if typ == "bar" then - return ui.Table and ui.Bar(...):area(area) or ui.Bar(area, ...) - else - return ui.Table and ui.Border(...):area(area) or ui.Border(area, ...) - end -end - -local function setup(_, opts) - local type = opts and opts.type or ui.Border.ROUNDED - local old_build = Tab.build - - Tab.build = function(self, ...) - local bar = function(c, x, y) - if x <= 0 or x == self._area.w - 1 then - return v4("bar", ui.Rect.default, ui.Bar.TOP) - end - - return v4( - "bar", - ui.Rect({ - x = x, - y = math.max(0, y), - w = ya.clamp(0, self._area.w - x, 1), - h = math.min(1, self._area.h), - }), - ui.Bar.TOP - ):symbol(c) - end - - local c = self._chunks - self._chunks = { - c[1]:padding(ui.Padding.y(1)), - c[2]:padding(ui.Padding(c[1].w > 0 and 0 or 1, c[3].w > 0 and 0 or 1, 1, 1)), - c[3]:padding(ui.Padding.y(1)), - } - - local style = THEME.manager.border_style - self._base = ya.list_merge(self._base or {}, { - v4("border", self._area, ui.Border.ALL):type(type):style(style), - v4("bar", self._chunks[1], ui.Bar.RIGHT):style(style), - v4("bar", self._chunks[3], ui.Bar.LEFT):style(style), - - bar("┬", c[1].right - 1, c[1].y), - bar("┴", c[1].right - 1, c[1].bottom - 1), - bar("┬", c[2].right, c[2].y), - bar("┴", c[2].right, c[2].bottom - 1), - }) - - old_build(self, ...) - end -end - -return { setup = setup } diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/LICENSE b/modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/LICENSE deleted file mode 100644 index fb5b1d627..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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/modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/README.md b/modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/README.md deleted file mode 100644 index 999db1123..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# hide-preview.yazi - -Switch the preview pane between hidden and shown. - -https://github.com/yazi-rs/plugins/assets/17523360/c4f0b5c4-ff9f-4be8-ba73-4d8e7902e383 - -## Installation - -```sh -ya pack -a yazi-rs/plugins#hide-preview -``` - -## Usage - -Add this to your `~/.config/yazi/keymap.toml`: - -```toml -[[manager.prepend_keymap]] -on = "T" -run = "plugin --sync hide-preview" -desc = "Hide or show preview" -``` - -Make sure the T key is not used elsewhere. diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/init.lua b/modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/init.lua deleted file mode 100644 index f74f4d742..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/hide-preview.yazi/init.lua +++ /dev/null @@ -1,27 +0,0 @@ ---- @sync entry - -local function entry(st) - if st.old then - Tab.layout, st.old = st.old, nil - else - st.old = Tab.layout - Tab.layout = function(self) - local all = MANAGER.ratio.parent + MANAGER.ratio.current - self._chunks = ui.Layout() - :direction(ui.Layout.HORIZONTAL) - :constraints({ - ui.Constraint.Ratio(MANAGER.ratio.parent, all), - ui.Constraint.Ratio(MANAGER.ratio.current, all), - ui.Constraint.Length(1), - }) - :split(self._area) - end - end - ya.app_emit("resize", {}) -end - -local function enabled(st) - return st.old ~= nil -end - -return { entry = entry, enabled = enabled } diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/LICENSE b/modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/LICENSE deleted file mode 100644 index fb5b1d627..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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/modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/README.md b/modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/README.md deleted file mode 100644 index 9f50f7a86..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# jump-to-char.yazi - -Vim-like `f`, jump to the next file whose name starts with ``. - -https://github.com/yazi-rs/plugins/assets/17523360/aac9341c-b416-4e0c-aaba-889d48389869 - -## Installation - -```sh -ya pack -a yazi-rs/plugins#jump-to-char -``` - -## Usage - -Add this to your `~/.config/yazi/keymap.toml`: - -```toml -[[manager.prepend_keymap]] -on = "f" -run = "plugin jump-to-char" -desc = "Jump to char" -``` - -Make sure the f key is not used elsewhere. diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/init.lua b/modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/init.lua deleted file mode 100644 index 8074df1a9..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/jump-to-char.yazi/init.lua +++ /dev/null @@ -1,32 +0,0 @@ -local AVAILABLE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789." - -local changed = ya.sync(function(st, new) - local b = st.last ~= new - st.last = new - return b or not cx.active.finder -end) - -local escape = function(s) - return s == "." and "\\." or s -end - -return { - entry = function() - local cands = {} - for i = 1, #AVAILABLE_CHARS do - cands[#cands + 1] = { on = AVAILABLE_CHARS:sub(i, i) } - end - - local idx = ya.which({ cands = cands, silent = true }) - if not idx then - return - end - - local kw = escape(cands[idx].on) - if changed(kw) then - ya.manager_emit("find_do", { "^" .. kw }) - else - ya.manager_emit("find_arrow", {}) - end - end, -} diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/LICENSE b/modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/LICENSE deleted file mode 100644 index fb5b1d627..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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/modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/README.md b/modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/README.md deleted file mode 100644 index ba11df188..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# max-preview.yazi - -Maximize or restore the preview pane. - -https://github.com/yazi-rs/plugins/assets/17523360/8976308e-ebfe-4e9e-babe-153eb1f87d61 - -## Installation - -```sh -ya pack -a yazi-rs/plugins#max-preview -``` - -## Usage - -Add this to your `~/.config/yazi/keymap.toml`: - -```toml -[[manager.prepend_keymap]] -on = "T" -run = "plugin --sync max-preview" -desc = "Maximize or restore preview" -``` - -Make sure the T key is not used elsewhere. diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/init.lua b/modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/init.lua deleted file mode 100644 index 81f637174..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/max-preview.yazi/init.lua +++ /dev/null @@ -1,26 +0,0 @@ ---- @sync entry - -local function entry(st) - if st.old then - Tab.layout, st.old = st.old, nil - else - st.old = Tab.layout - Tab.layout = function(self) - self._chunks = ui.Layout() - :direction(ui.Layout.HORIZONTAL) - :constraints({ - ui.Constraint.Percentage(0), - ui.Constraint.Percentage(0), - ui.Constraint.Percentage(100), - }) - :split(self._area) - end - end - ya.app_emit("resize", {}) -end - -local function enabled(st) - return st.old ~= nil -end - -return { entry = entry, enabled = enabled } diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-enter.yazi/init.lua b/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-enter.yazi/init.lua deleted file mode 100644 index e2f201603..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-enter.yazi/init.lua +++ /dev/null @@ -1,12 +0,0 @@ ---- @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/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/LICENSE b/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/LICENSE deleted file mode 100644 index fb5b1d627..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/README.md b/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/README.md deleted file mode 100644 index 382852d0f..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# smart-filter.yazi - -A Yazi plugin that makes filters smarter: continuous filtering, automatically enter unique directory, open file on submitting. - -https://github.com/yazi-rs/plugins/assets/17523360/72aaf117-1378-4f7e-93ba-d425a79deac5 - -## Installation - -```sh -ya pack -a yazi-rs/plugins#smart-filter -``` - -## Usage - -Add this to your `~/.config/yazi/keymap.toml`: - -```toml -[[manager.prepend_keymap]] -on = "F" -run = "plugin smart-filter" -desc = "Smart filter" -``` - -Make sure the F key is not used elsewhere. diff --git a/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/init.lua b/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/init.lua deleted file mode 100644 index c62a7a38a..000000000 --- a/modules/home/programs/terminal/tools/yazi/configs/plugins/smart-filter.yazi/init.lua +++ /dev/null @@ -1,47 +0,0 @@ -local hovered = ya.sync(function() - local h = cx.active.current.hovered - if not h then - return {} - end - - return { - url = h.url, - is_dir = h.cha.is_dir, - unique = #cx.active.current.files == 1, - } -end) - -local function prompt() - return ya.input({ - title = "Smart filter:", - position = { "center", w = 50 }, - realtime = true, - debounce = 0.1, - }) -end - -local function entry() - local input = prompt() - - while true do - local value, event = input:recv() - if event ~= 1 and event ~= 3 then - ya.manager_emit("escape", { filter = true }) - break - end - - ya.manager_emit("filter_do", { value, smart = true }) - - local h = hovered() - if h.unique and h.is_dir then - ya.manager_emit("escape", { filter = true }) - ya.manager_emit("enter", {}) - input = prompt() - elseif event == 1 then - ya.manager_emit("escape", { filter = true }) - ya.manager_emit(h.is_dir and "enter" or "open", { h.url }) - end - end -end - -return { entry = entry } diff --git a/modules/home/programs/terminal/tools/yazi/default.nix b/modules/home/programs/terminal/tools/yazi/default.nix index c32e17455..b821db261 100644 --- a/modules/home/programs/terminal/tools/yazi/default.nix +++ b/modules/home/programs/terminal/tools/yazi/default.nix @@ -3,6 +3,7 @@ lib, pkgs, namespace, + inputs, ... }: let @@ -15,6 +16,7 @@ let manager = import ./keymap/manager.nix { inherit config namespace; }; select = import ./keymap/select.nix { }; tasks = import ./keymap/tasks.nix { }; + inherit (inputs) yazi-plugins; cfg = config.${namespace}.programs.terminal.tools.yazi; in @@ -63,19 +65,18 @@ in }; xdg.configFile = { - "yazi" = { - source = lib.cleanSourceWith { - filter = - name: _type: - let - baseName = baseNameOf (toString name); - in - !lib.hasSuffix ".nix" baseName; - src = lib.cleanSource ./configs/.; - }; - - recursive = true; - }; + "yazi/init.lua".source = ./configs/init.lua; + "yazi/plugins/chmod.yazi".source = "${yazi-plugins}/chmod.yazi"; + "yazi/plugins/diff.yazi".source = "${yazi-plugins}/diff.yazi"; + "yazi/plugins/full-border.yazi".source = "${yazi-plugins}/full-border.yazi"; + "yazi/plugins/glow.yazi".source = ./configs/plugins/glow.yazi; + "yazi/plugins/jump-to-char.yazi".source = "${yazi-plugins}/jump-to-char.yazi"; + "yazi/plugins/max-preview.yazi".source = "${yazi-plugins}/max-preview.yazi"; + "yazi/plugins/miller.yazi".source = ./configs/plugins/miller.yazi; + "yazi/plugins/ouch.yazi".source = ./configs/plugins/ouch.yazi; + "yazi/plugins/smart-enter.yazi".source = "${yazi-plugins}/smart-enter.yazi"; + "yazi/plugins/smart-filter.yazi".source = "${yazi-plugins}/smart-filter.yazi"; + "yazi/plugins/sudo.yazi".source = ./configs/plugins/sudo.yazi; }; }; }