{ config, lib, ... }:

let
  cfg = config.subs.ghostty;
in
{
  options.subs.ghostty.enable = lib.mkOption {
    default = false;
    type = lib.types.bool;
  };

  config = lib.mkIf cfg.enable {
    programs.ghostty = {
      enable = true;
      enableZshIntegration = true;
      settings = {
        font-family = "Iosevka Nerd Font";
        font-size = 14;
        theme = "ghostty-kanagawabones";
        clipboard-read = "allow";
        clipboard-write = "allow";
        window-padding-x = 0;
        window-padding-y = 0;
        window-theme = "system";
        window-decoration = true;
        window-padding-balance = true;
        window-new-tab-position = "end";
        gtk-single-instance = true;
        gtk-titlebar = true;
        gtk-titlebar-hide-when-maximized = true;
        gtk-adwaita = false;
        gtk-wide-tabs = false;
        confirm-close-surface = false;
        keybind = [
          "ctrl+shift+h=goto_split:left"
          "ctrl+shift+j=goto_split:down"
          "ctrl+shift+k=goto_split:up"
          "ctrl+shift+l=goto_split:right"
          "ctrl+alt+h=new_split:left"
          "ctrl+alt+j=new_split:down"
          "ctrl+alt+k=new_split:up"
          "ctrl+alt+l=new_split:right"
        ];
      };
    };

    home.file = {
      ".config/ghostty/themes/ghostty-kanagawabones".source = ../../config/theme-files/ghostty-kanagawabones;
    };
  };
}
