diff --git a/home/default.nix b/home/default.nix index b80dedd..c5146f1 100644 --- a/home/default.nix +++ b/home/default.nix @@ -7,6 +7,7 @@ ./git ./lazygit ./direnv + ./yazi ]; home.packages = with pkgs; [ @@ -25,7 +26,6 @@ dig tailspin nitch - joshuto ]; services.gpg-agent = { diff --git a/home/yazi/default.nix b/home/yazi/default.nix new file mode 100644 index 0000000..82d4d33 --- /dev/null +++ b/home/yazi/default.nix @@ -0,0 +1,47 @@ +{ + config, + pkgs, + ... +}: { + xdg.configFile."yazi/init.lua".source = ./init.lua; + # imports = [./keymap.nix]; + home.packages = [pkgs.exiftool]; + + programs.yazi = { + enable = true; + package = pkgs.yazi; + enableNushellIntegration = true; + settings = { + manager = { + ratio = [1 3 2]; + sort_by = "natural"; + sort_reverse = false; + sort_dir_first = true; + show_hidden = true; + show_symlink = true; + linemode = "size"; + }; + preview = { + cache_dir = "${config.xdg.cacheHome}"; + max_height = 900; + max_width = 600; + }; + open.rules = [ + { + mime = "image/*"; + use = ["image"]; + } + ]; + opener = { + image = [ + { + exec = ''imv "$@" ''; + block = true; + for = "linux"; + } + ]; + }; + log.enable = false; + }; + }; +} diff --git a/home/yazi/init.lua b/home/yazi/init.lua new file mode 100644 index 0000000..a60cc3b --- /dev/null +++ b/home/yazi/init.lua @@ -0,0 +1,38 @@ +function Manager:render(area) + self.area = area + + local chunks = ui.Layout() + :direction(ui.Layout.HORIZONTAL) + :constraints({ + ui.Constraint.Ratio(MANAGER.ratio.parent, MANAGER.ratio.all), + ui.Constraint.Ratio(MANAGER.ratio.current, MANAGER.ratio.all), + ui.Constraint.Ratio(MANAGER.ratio.preview, MANAGER.ratio.all), + }) + :split(area) + + local bar = function(c, x, y) + return ui.Bar( + ui.Rect { x = math.max(0, x), y = math.max(0, y), w = math.min(1, area.w), h = math.min(1, area.h) }, + ui.Bar.TOP + ):symbol(c) + end + + return ya.flat { + -- Borders + ui.Border(area, ui.Border.ALL):type(ui.Border.ROUNDED), + ui.Bar(chunks[1], ui.Bar.RIGHT), + ui.Bar(chunks[3], ui.Bar.LEFT), + + bar("┬", chunks[1].right - 1, chunks[1].y), + bar("┴", chunks[1].right - 1, chunks[1].bottom - 1), + bar("┬", chunks[2].right, chunks[2].y), + bar("┴", chunks[2].right, chunks[1].bottom - 1), + + -- Parent + Parent:render(chunks[1]:padding(ui.Padding.xy(1))), + -- Current + Current:render(chunks[2]:padding(ui.Padding.y(1))), + -- Preview + Preview:render(chunks[3]:padding(ui.Padding.xy(1))), + } +end