{ config, lib, ... }:

with lib;

let
  cfg = config.settings.applications.yazi;
in {
  options = {
    settings.applications.yazi.enable = lib.mkOption {
      type = lib.types.bool;
      description = ''
        Enable yazi terminal file manager
      '';
    };
  };

  config = mkIf cfg.enable {
    programs.yazi = {
      enable = true;
      enableZshIntegration = true;
      settings = {
        opener = {
          open = [
            { run = "xdg-open $@"; desc = "xdg"; orphan = true; }
          ];
        };
        open = {
          prepend_rules = [
            { name = "*.rnote"; use = "open"; }
          ];
        };
      };
    };
  };
}
