90 lines
2.3 KiB
Nix
90 lines
2.3 KiB
Nix
{ lib, pkgs, ... }:
|
||
|
||
{
|
||
programs.yazi = {
|
||
enable = true;
|
||
|
||
initLua = ''
|
||
function Linemode:size_and_mtime()
|
||
local time = math.floor(self._file.cha.mtime or 0)
|
||
if time == 0 then
|
||
time = ""
|
||
elseif os.date("%Y", time) == os.date("%Y") then
|
||
time = os.date("%b %d %H:%M", time)
|
||
else
|
||
time = os.date("%b %d %Y", time)
|
||
end
|
||
|
||
local size = self._file:size()
|
||
return string.format("%s %s", size and ya.readable_size(size) or "-", time)
|
||
end
|
||
|
||
require("git"):setup()
|
||
'';
|
||
|
||
# Основные настройки
|
||
settings = {
|
||
manager = {
|
||
sort_by = "natural";
|
||
sort_dir_first = false;
|
||
linemode = "size_and_mtime";
|
||
show_symlink = true;
|
||
};
|
||
|
||
preview = {
|
||
wrap = "no";
|
||
tab_size = 4;
|
||
};
|
||
|
||
opener = {
|
||
play = [
|
||
{
|
||
run = "mpv %s";
|
||
orphan = true;
|
||
for = "unix";
|
||
}
|
||
];
|
||
edit = [
|
||
{
|
||
run = ''cd "''${YAZI_ORIGINAL_CWD:-''${PWD}}" && "''${EDITOR:-nano}" %s'';
|
||
block = true;
|
||
for = "unix";
|
||
}
|
||
];
|
||
open = [
|
||
{
|
||
run = "xdg-open %s1";
|
||
desc = "Open";
|
||
}
|
||
];
|
||
};
|
||
};
|
||
|
||
# Хоткеи
|
||
keymap.mgr = {
|
||
prepend_keymap = [
|
||
{ on = "h"; run = "leave"; desc = "Назад (вверх по иерархии)"; }
|
||
{ on = "n"; run = "arrow next"; desc = "Вниз"; }
|
||
{ on = "e"; run = "arrow prev"; desc = "Вверх"; }
|
||
{ on = "M"; run = "plugin mount"; }
|
||
{ on = "F"; run = "plugin jump-to-char"; desc = "Jump to char"; }
|
||
{ on = "i"; run = "plugin smart-enter"; desc = "Enter the child directory, or open the file"; }
|
||
{ on = [ "c" "m" ]; run = "plugin chmod"; desc = "Chmod on selected files"; }
|
||
{ on = [ "<C-n>" ]; run = "seek 1"; desc = "Scroll preview down 1 line"; }
|
||
{ on = [ "<C-p>" ]; run = "seek -1"; desc = "Scroll preview up 1 line"; }
|
||
];
|
||
|
||
append_keymap = [
|
||
{ on = [ "c" "e" ]; run = "shell -- flipbit x %h"; desc = "Toggle execution mode on file"; }
|
||
];
|
||
};
|
||
|
||
plugins = {
|
||
mount.package = pkgs.yaziPlugins.mount;
|
||
jump-to-char.package = pkgs.yaziPlugins.jump-to-char;
|
||
smart-enter.package = pkgs.yaziPlugins.smart-enter;
|
||
chmod.package = pkgs.yaziPlugins.chmod;
|
||
};
|
||
};
|
||
}
|