nixos-config/modules/home/yazi.nix

226 lines
7.8 KiB
Nix

{ inputs, pkgs, lib, ... }:
{
programs.yazi = {
enable = true;
enableFishIntegration = true;
package = inputs.yazi.packages.x86_64-linux.default;
initLua = ./yazi/init.lua;
plugins = let
officialPluginsNames = [
"chmod"
"diff"
"git"
"mount"
"smart-paste"
"toggle-pane"
];
officialPluginsSrc = pkgs.fetchgit {
url = "https://github.com/yazi-rs/plugins.git";
sparseCheckout = map (p: "${p}.yazi") officialPluginsNames;
hash = "sha256-bre666Z5qEqkt3c2wLfX5tI2+JMoeRdP4721bJeanKs=";
};
officialPlugins =
lib.lists.fold (
a: b:
{
${a} = "${officialPluginsSrc}/${a}.yazi";
}
// b
)
{}
officialPluginsNames;
in
officialPlugins // {
restore = pkgs.fetchFromGitHub {
owner = "boydaihungst";
repo = "restore.yazi";
rev = "HEAD";
sha256 = "sha256-3Z8P25u9bffdjrPjxLRWUQn6MdBS+vyElUBkgV4EUwY=";
};
lazygit = pkgs.fetchFromGitHub {
owner = "Lil-Dank";
repo = "lazygit.yazi";
rev = "HEAD";
sha256 = "sha256-OJJPgpSaUHYz8a9opVLCds+VZsK1B6T+pSRJyVgYNy8=";
};
ouch = pkgs.fetchFromGitHub {
owner = "ndtoan96";
repo = "ouch.yazi";
rev = "HEAD";
sha256 = "sha256-7X8uAiJ8vBXYBXOgyKhVVikOnTBGrdCcXOJemjQNolI=";
};
rich-preview = pkgs.fetchFromGitHub {
owner = "AnirudhG07";
repo = "rich-preview.yazi";
rev = "HEAD";
sha256 = "sha256-dW2gAAv173MTcQdqMV32urzfrsEX6STR+oCJoRVGGpA=";
};
mediainfo= pkgs.fetchFromGitHub {
owner = "boydaihungst";
repo = "mediainfo.yazi";
rev = "HEAD";
sha256 = "sha256-U6rr3TrFTtnibrwJdJ4rN2Xco4Bt4QbwEVUTNXlWRps=";
};
starship = pkgs.fetchFromGitHub {
owner = "Rolv-Apneseth";
repo = "starship.yazi";
rev = "HEAD";
sha256 = "sha256-+CSdghcIl50z0MXmFwbJ0koIkWIksm3XxYvTAwoRlDY=";
};
office = pkgs.fetchFromGitHub {
owner = "macydnah";
repo = "office.yazi";
rev = "HEAD";
sha256 = "sha256-ORcexu1f7hb7G4IyzQIfGlCkH3OWlk4w5FtZrbXkR40=";
};
dir-rules = ./yazi/plugins/dir-rules.yazi;
smart-tab = ./yazi/plugins/smart-tab.yazi;
};
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" "y"]; run = "yank"; desc = "Copy file (yank)"; }
{ on = "y"; run = ["shell 'for path in \"$@\"; do echo \"file://$path\"; done | wl-copy -t text/uri-list'\n" "yank"]; desc = "Yank selected files (copy)"; }
{ 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 = "<C-t>"; run ="tab_create"; }
{ on = "<C-w>"; run ="close"; }
{ on = "<C-A-right>"; run ="tab_switch 1 --relative"; }
{ on = "<C-A-left>"; run ="tab_switch -1 --relative"; }
{ on = "<C-1>"; run ="tab_switch 0"; }
{ on = "<C-2>"; run ="tab_switch 1"; }
{ on = "<C-3>"; run ="tab_switch 2"; }
{ on = "<C-4>"; run ="tab_switch 3"; }
{ 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 = "C"; run = "plugin ouch zip"; }
{ on = "T"; run = "plugin smart-tab"; desc = "Create a tab and enter the hovered directory"; }
{ on = "<Backspace>"; run = "remove"; }
{ on = ["d" "d"]; run = "remove"; desc = "Delete files/folders"; }
{ on = ["d" "u"]; run = "plugin restore"; desc = "Restore last deleted files/folders"; }
{ on = ["d" "x"]; run = "shell 'trash-empty'"; desc = "Empty trash"; }
{ on = "F"; run = "filter --smart"; desc = "Find file"; }
{ on = "f"; run = "find --smart"; desc = "Find file"; }
{ on = "z"; run = "plugin zoxide"; }
{ on = "Z"; run = "plugin fzf"; }
];
};
settings = {
manager = {
sort_dir_first = false;
linemode = "mtime";
show_symlink = true;
};
opener = {
edit = [
{ run = "$EDITOR \"$@\""; desc = "emacsclient"; orphan = true; block = false; }
{ run = "nano \"$@\""; desc = "nano"; orphan = false; block = true; }
];
extract = [
{ run = "ouch d -y \"$@\""; desc = "Extract here with ouch"; }
];
};
open = {
prepend_rules = [
{ name = "*.zip"; use = "extract"; }
];
};
plugin = {
prepend_preloaders = [
{ name = "/home/emenel/Mounts/**"; run = "noop"; }
{ name = "/mnt/**"; run = "noop"; }
# { mime = "{image,audio,video}/*"; run = "mediainfo";}
# { mime = "application/x-subrip"; run = "mediainfo";}
# Office Documents
{ mime = "application/openxmlformats-officedocument.*"; run = "office"; }
{ mime = "application/oasis.opendocument.*"; run = "office"; }
{ mime = "application/ms-*"; run = "office"; }
{ mime = "application/msword"; run = "office"; }
{ name = "*.docx"; run = "office"; }
];
prepend_previewers = [
# { mime = "{image,audio,video}/*"; run = "mediainfo";}
# { mime = "application/x-subrip"; run = "mediainfo";}
{ name = "*.csv"; run = "rich-preview"; }
{ name = "*.md"; run = "rich-preview" ; }
{ name = "*.rst"; run = "rich-preview"; }
{ name = "*.ipynb"; run = "rich-preview"; }
{ name = "*.json"; run = "rich-preview"; }
{ name = "*.org"; run = "rich-preview"; }
# Office Documents
{ mime = "application/openxmlformats-officedocument.*"; run = "office"; }
{ mime = "application/oasis.opendocument.*"; run = "office"; }
{ mime = "application/ms-*"; run = "office"; }
{ mime = "application/msword"; run = "office"; }
{ name = "*.docx"; run = "office"; }
];
append_previewers = [
# Archive previewer
{ name = "*.zip"; run = "ouch"; }
{ 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"; }
];
_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";
}
];
};
tasks = {
image_alloc = 53687091;
image_bound = [ 0 0 ];
};
};
};
xdg.configFile."yazi/theme.toml".source = ./yazi/theme.toml;
xdg.configFile."yazi/flavors".source = ./yazi/flavors;
xdg.configFile."xdg-desktop-portal-termfilechooser/config".source = ./file-chooser/config;
home.file.".local/bin/yazi-wrapper.sh".source = ./file-chooser/yazi-wrapper.sh;
}