From 57f4a31f2689b3576ca3864e895a62ac68cf3821 Mon Sep 17 00:00:00 2001 From: Francis Hamel <36383308+francishamel@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:27:11 -0400 Subject: [PATCH] 299 setup yazi (#302) * Enable yazi * Setup yazi-picker for helix Used https://yazi-rs.github.io/docs/tips/#helix-with-zellij to set this up. --- home-manager/flake-module.nix | 1 + home-manager/modules/helix.nix | 20 +++++++++++++++++++- home-manager/modules/yazi.nix | 8 ++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 home-manager/modules/yazi.nix diff --git a/home-manager/flake-module.nix b/home-manager/flake-module.nix index 7419a0d..6f1a25d 100644 --- a/home-manager/flake-module.nix +++ b/home-manager/flake-module.nix @@ -18,6 +18,7 @@ ./modules/terminal.nix ./modules/vscode.nix ./modules/wezterm.nix + ./modules/yazi.nix ./modules/zellij.nix ]; home.stateVersion = "22.11"; diff --git a/home-manager/modules/helix.nix b/home-manager/modules/helix.nix index ff5896e..932cc58 100644 --- a/home-manager/modules/helix.nix +++ b/home-manager/modules/helix.nix @@ -1,5 +1,20 @@ -{ pkgs, ... }: +{ config, lib, pkgs, ... }: +let + yaziPicker = pkgs.writeShellScriptBin "yazi-picker" '' + paths=$(${pkgs.yazi}/bin/yazi --chooser-file=/dev/stdout | while read -r; do printf "%q " "$REPLY"; done) + + if [[ -n "$paths" ]]; then + ${pkgs.zellij}/bin/zellij action toggle-floating-panes + ${pkgs.zellij}/bin/zellij action write 27 # send key + ${pkgs.zellij}/bin/zellij action write-chars ":open $paths" + ${pkgs.zellij}/bin/zellij action write 13 # send key + ${pkgs.zellij}/bin/zellij action toggle-floating-panes + fi + + ${pkgs.zellij}/bin/zellij action close-pane + ''; +in { programs.helix = { enable = true; @@ -14,6 +29,9 @@ }; settings = { editor.line-number = "relative"; + keys.normal = { + "C-y" = lib.mkIf config.programs.yazi.enable ":sh ${pkgs.zellij}/bin/zellij run -f -n yazi-picker -x 10% -y 10% --width 80% --height 80% -- ${yaziPicker}/bin/yazi-picker"; + }; }; }; } diff --git a/home-manager/modules/yazi.nix b/home-manager/modules/yazi.nix new file mode 100644 index 0000000..0dad0e7 --- /dev/null +++ b/home-manager/modules/yazi.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + programs.yazi = { + enable = true; + enableZshIntegration = true; + }; +}