feat(yazi): add some more plugins to yazi.
This commit is contained in:
parent
71095292e9
commit
6ef00fe663
3 changed files with 177 additions and 11 deletions
|
|
@ -154,24 +154,89 @@
|
|||
show_hidden = true;
|
||||
show_symlink = false;
|
||||
};
|
||||
plugin = {
|
||||
prepend_fetchers = [
|
||||
{
|
||||
id = "git";
|
||||
name = "*";
|
||||
run = "git";
|
||||
}
|
||||
{
|
||||
id = "git";
|
||||
name = "*/";
|
||||
run = "git";
|
||||
}
|
||||
];
|
||||
prepend_previewers = [
|
||||
# Archive previewer
|
||||
{
|
||||
mime = "application/*zip";
|
||||
run = "ouch";
|
||||
}
|
||||
{
|
||||
mime = "application/x-tar";
|
||||
run = "ouch";
|
||||
}
|
||||
{
|
||||
mime = "application/x-bzip2";
|
||||
run = "ouch";
|
||||
}
|
||||
{
|
||||
mime = "application/x-7z-compressed";
|
||||
run = "ouch";
|
||||
}
|
||||
{
|
||||
mime = "application/x-rar";
|
||||
run = "ouch";
|
||||
}
|
||||
{
|
||||
mime = "application/vnd.rar";
|
||||
run = "ouch";
|
||||
}
|
||||
{
|
||||
mime = "application/x-xz";
|
||||
run = "ouch";
|
||||
}
|
||||
{
|
||||
mime = "application/xz";
|
||||
run = "ouch";
|
||||
}
|
||||
{
|
||||
mime = "application/x-zstd";
|
||||
run = "ouch";
|
||||
}
|
||||
{
|
||||
mime = "application/zstd";
|
||||
run = "ouch";
|
||||
}
|
||||
{
|
||||
mime = "application/java-archive";
|
||||
run = "ouch";
|
||||
}
|
||||
];
|
||||
opener = {
|
||||
extract = [
|
||||
{
|
||||
run = "ouch -d -y \"$@\"";
|
||||
desc = "Extract here with ouch";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
plugins = {
|
||||
full-border = pkgs.yaziPlugins.full-border;
|
||||
smart-enter = pkgs.yaziPlugins.smart-enter;
|
||||
smart-tab = ./yazi/smart-tab;
|
||||
folder-rules = ./yazi/folder-rules;
|
||||
toggle-pane = pkgs.yaziPlugins.toggle-pane;
|
||||
parent-arrow = ./yazi/parent-arrow;
|
||||
chmod = pkgs.yaziPlugins.chmod;
|
||||
ouch = pkgs.yaziPlugins.ouch;
|
||||
git = pkgs.yaziPlugins.git;
|
||||
mount = pkgs.yaziPlugins.mount;
|
||||
};
|
||||
initLua = ''
|
||||
require("full-border"):setup({
|
||||
type = ui.Border.ROUNDED,
|
||||
})
|
||||
|
||||
require("smart-enter"):setup({
|
||||
open_multi = true,
|
||||
})
|
||||
|
||||
require("folder-rules"):setup()
|
||||
'';
|
||||
initLua = ./yazi/init.lua;
|
||||
keymap = {
|
||||
mgr.prepend_keymap = [
|
||||
{
|
||||
|
|
@ -184,6 +249,44 @@
|
|||
run = "plugin smart-tab";
|
||||
desc = "Create a tab and enter the howered directory";
|
||||
}
|
||||
{
|
||||
on = "<C-w>";
|
||||
for = "linux";
|
||||
run = "shell -- hyprctl hyprpaper reload , \"$0\"";
|
||||
desc = "Set howered file as wallpaper";
|
||||
}
|
||||
{
|
||||
on = [" " "p"];
|
||||
run = "plugin toggle-pane min-preview";
|
||||
desc = "Show or hide the preview pane";
|
||||
}
|
||||
{
|
||||
on = "K";
|
||||
run = "plugin parent-arrow -1";
|
||||
}
|
||||
{
|
||||
on = "J";
|
||||
run = "plugin parent-arrow 1";
|
||||
}
|
||||
{
|
||||
on = ["g" "r"];
|
||||
run = "shell -- ya emit cd \"$(git rev-parse --show-toplevel)\"";
|
||||
}
|
||||
{
|
||||
on = ["c" "m"];
|
||||
run = "plugin chmod";
|
||||
desc = "Chmod on selected files";
|
||||
}
|
||||
{
|
||||
on = "C";
|
||||
run = "plugin ouch tar.gz";
|
||||
desc = "Compress with ouch";
|
||||
}
|
||||
{
|
||||
on = "M";
|
||||
run = "plugin mount";
|
||||
desc = "Manage mounting disks";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
43
modules/cross-platform/home-manager/yazi/init.lua
Normal file
43
modules/cross-platform/home-manager/yazi/init.lua
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
-- Hide preview pane by default
|
||||
require("toggle-pane"):entry("min-preview")
|
||||
|
||||
-- Have nice rounded border
|
||||
require("full-border"):setup({
|
||||
type = ui.Border.ROUNDED,
|
||||
})
|
||||
|
||||
-- Smartly enter directory or open file
|
||||
require("smart-enter"):setup({
|
||||
open_multi = true,
|
||||
})
|
||||
|
||||
-- Setup some folder rules
|
||||
require("folder-rules"):setup()
|
||||
|
||||
-- Show git status of files
|
||||
require("git"):setup()
|
||||
|
||||
-- Show symlink in status bar
|
||||
Status:children_add(function(self)
|
||||
local h = self._current.hovered
|
||||
if h and h.link_to then
|
||||
return " -> " .. tostring(h.link_to)
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end, 3300, Status.LEFT)
|
||||
|
||||
-- Show user/group of file in status bar
|
||||
Status:children_add(function()
|
||||
local h = cx.active.current.hovered
|
||||
if not h or ya.target_family() ~= "unix" then
|
||||
return ""
|
||||
end
|
||||
|
||||
return ui.Line {
|
||||
ui.Span(ya.user_name(h.cha.uid) or tostring(h.cha.uid)):fg("magenta"),
|
||||
":",
|
||||
ui.Span(ya.group_name(h.cha.gid) or tostring(h.cha.gid)):fg("magenta"),
|
||||
" ",
|
||||
}
|
||||
end, 500, Status.RIGHT)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
--- @sync entry
|
||||
local function entry(_, job)
|
||||
local parent = cx.active.parent
|
||||
if not parent then return end
|
||||
|
||||
local offset = tonumber(job.args[1])
|
||||
if not offset then return ya.err(job.args[1], 'is not a number') end
|
||||
|
||||
local start = parent.cursor + 1 + offset
|
||||
local end_ = offset < 0 and 1 or #parent.files
|
||||
local step = offset < 0 and -1 or 1
|
||||
for i = start, end_, step do
|
||||
local target = parent.files[i]
|
||||
if target and target.cha.is_dir then
|
||||
return ya.emit("cd", { target.url })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return { entry = entry }
|
||||
Loading…
Add table
Add a link
Reference in a new issue