nixos-config/modules/home/yazi.nix
2025-02-27 17:16:39 -05:00

120 lines
5.4 KiB
Nix

{ inputs, pkgs, ... }:
{
programs.yazi = {
enable = true;
enableFishIntegration = true;
package = inputs.yazi.packages.x86_64-linux.default;
initLua = ../../homes/emenel/dotfiles/dot_config/yazi/init.lua;
keymap = {
manager.prepend_keymap = [
{ on = "!"; run = "shell '$SHELL' --block"; desc = "Open shell here"; }
{ on = ["c" "d"]; run = "shell 'ripdrag \"$@\" -x 2>/dev/null &' --confirm"; desc = "Drag selection";}
{ on = ["c" "c"]; run = "yank"; desc = "Copy file"; }
{ on = ["c" "n"]; run = "copy filename"; desc = "Copy file name"; }
{ on = ["c" "N"]; run = "copy name_without_ext"; desc = "Copy file name without extension"; }
{ on = "y"; run = ["shell 'for path in \"$@\"; do echo \"file://$path\"; done | wl-copy -t text/uri-list'\n" "yank"]; }
{ on = ["g" "r"]; run = "shell 'ya emit cd \"$(git rev-parse --show-toplevel)\"'\n"; desc = "Go to top of git repo"; }
{ on = ["g" "p"]; run = "cd ~/Projects"; desc = "Go to ~/Projects"; }
{ on = ["t" "p"]; run = "plugin toggle-view parent"; desc = "Toggle parent"; }
{ on = ["t" "c"]; run = "plugin toggle-view current"; desc = "Toggle current"; }
{ on = ["t" "r"]; run = "plugin toggle-view preview"; desc = "Toggle preview"; }
{ on = "<C-t>"; run ="tab_create"; }
{ on = "<C-w>"; run ="tab_close"; }
{ on = "<C-A-right>"; run ="tab_switch 1 --relative"; }
{ on = "<C-A-left>"; run ="tab_switch -1 --relative"; }
{ on = "<Tab>"; run = "spot"; desc = "Spot hovered file"; }
{ on = "M"; run = "plugin mount"; }
{ on = "p"; run = "plugin smart-paste"; desc = "Paste into the hovered directory or CWD"; }
{ on = ["g" "l"]; run = "plugin lazygit"; desc = "lazygit"; }
{ on = "k"; run = "plugin arrow -1"; desc = "up"; }
{ on = "j"; run = "plugin arrow 1"; desc = "down"; }
{ on = "<Up>"; run = "plugin arrow -1"; desc = "up"; }
{ on = "<Down>"; run = "plugin arrow 1"; desc = "down"; }
{ 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 = "<Enter>"; run = "plugin smart-enter"; desc = "Enter the child directory, or open the file"; }
{ on = "<Right>"; run = "plugin smart-enter"; desc = "Enter the child directory, or open the file"; }
{ on = "<Backspace>"; run = "remove"; }
{ on = [ "t" "s" ]; run = "plugin what-size"; desc = "Calc size of selection or cwd"; }
{ on = ["d" "u"]; run = "plugin restore"; desc = "Restore last deleted files/folders"; }
{ on = ["d" "d"]; run = "remove"; desc = "Delete files/folders"; }
{ on = ["F" "g"]; run = "plugin fg"; desc = "Find file by content (fuzzy)"; }
{ on = ["F" "G"]; run = "plugin fg rg"; desc = "Find file by content (ripgrep)"; }
{ on = ["F" "f"]; run = "plugin fg fzf"; desc = "Find file by name (fuzzy)"; }
];
};
settings = {
manager = {
sort_dir_first = false;
linemode = "mtime";
show_symlink = true;
};
opener = {
open = [
{ run = "plugin open-with-cmd --args=block"; desc = "Open with command in the terminal"; }
{ run = "plugin open-with-cmd"; desc = "Open with command"; }
];
edit = [
{ run = "emacsclient -r -n \"$@\""; desc = "open in current emacsclient"; orphan = true; }
];
extract = [
{ run = "ouch d -y \"$@\""; desc = "Extract here with ouch"; }
];
};
plugin = {
prepend_preloaders = [
{ name = "/mnt/**"; run = "noop"; }
{ name = "/home/emenel/Mounts/**"; run = "noop"; }
];
append_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/x-xz"; run = "ouch"; }
{ mime = "application/octet-stream"; run = "ouch"; }
{ name = "*.el"; run = "code"; }
{ name = "*.lisp"; run = "code"; }
{ name = "*.org"; run = "glow"; }
{ name = "*"; run = "file-extra-metadata"; }
{ name = "*.md"; run = "glow"; }
{ mime = "{image,audio,video}/*"; run = "mediainfo";}
{ mime = "application/x-subrip"; run = "mediainfo";}
];
append_spotters = [
{ name = "*"; run = "file-extra-metadata"; }
];
prepend_fetchers = [
{
id = "mime";
name = "*";
run = "mime-ext";
prio = "high";
}
{
id = "git";
name = "*";
run = "git";
}
{
id = "git";
name = "*/";
run = "git";
}
];
};
};
};
xdg.configFile."yazi/theme.toml".source = ../../homes/emenel/dotfiles/dot_config/yazi/theme.toml;
xdg.configFile."yazi/flavors".source = ../../homes/emenel/dotfiles/dot_config/yazi/flavors;
xdg.configFile."yazi/plugins".source = ../../homes/emenel/dotfiles/dot_config/yazi/plugins;
}