{ lib, config, ... }:

let
  cfg = config.snowhawk.lazygit;
in
{
  options.snowhawk.lazygit = {
    enable = lib.mkEnableOption "lazygit";
  };

  config = lib.mkIf cfg.enable {
    programs.lazygit = {
      enable = true;
      settings = {
        customCommands = [{
          # We call this the double yoinky sploinky
          # https://github.com/jesseduffield/lazygit/wiki/Custom-Commands-Compendium#pushing-a-specific-commit
          key = "P";
          context = "commits";
          loadingText = "Pushing commit";
          description = "Push a specific commit (and any preceding)";
          stream = "yes";
          command = "git push {{.SelectedRemote.Name}} {{.SelectedLocalCommit.Sha}}:{{.SelectedLocalBranch.Name}}";
        }];
        services = {
          "git.zynh.me" = "gitea:git.zynh.me";
          "git.nullcube.net" = "gitea:git.nullcube.net";
        };
      };
    };
  };
}