{ config, lib, ... }:

{
  options.modules.fish = {
    enable = lib.mkEnableOption "Fish integration";
    enableDefaultAliases = lib.mkOption {
      type = lib.types.bool;
      default = true;
      description = "Enable default aliases and abbreviations";
    };

    enableStarship = lib.mkOption {
      type = lib.types.bool;
      default = false;
      description = "Enable Starship prompt";
    };

    functions = lib.mkOption {
      type = with lib.types; attrsOf str;
      description = "Fish function definitions";
    };
  };

  config = lib.mkIf config.modules.fish.enable {
    programs.nix-index = {
      enable = true;
      enableFishIntegration = true;
    };

    programs.starship = lib.mkIf config.modules.fish.enableStarship {
      enable = true;
      enableFishIntegration = true;
    };

    programs.fish = {
      enable = true;
      interactiveShellInit = ''
        				set fish_greeting
        				cat ~/.cache/wal/sequences
        			'';

      shellAliases = lib.mkIf config.modules.fish.enableDefaultAliases {
        ".." = "cd ..";
        "..." = "cd ../..";
        "...." = "cd ../../../";
        "....." = "cd ../../../../";

        "cp" = "cp -v";
        "ddf" = "df -h";
        "etc" = "erd -H";
        "mkdir" = "mkdir -p";
        "mv" = "mv -v";
        "rm" = "rm -v";
        "rr" = "rm -rf";

        "neofetch" = "fastfetch";
      };

      shellAbbrs = lib.mkIf config.modules.fish.enableDefaultAliases {
        gaa = "git add -A";
        ga = "git add";
        gbd = "git branch --delete";
        gb = "git branch";
        gc = "git commit";
        gcm = "git commit -m";
        gcob = "git checkout -b";
        gco = "git checkout";
        gd = "git diff";
        gl = "git log";
        gp = "git push";
        gs = "git status";
      };

      functions = config.modules.fish.functions;
    };
  };
}