# ── General ───────────────────────────────────────────────────────────────────


set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"

set -g mouse on                  # click to focus panes, drag borders to resize
set -g base-index 1              # start window numbering at 1
set -g pane-base-index 1         # start pane numbering at 1
set -g renumber-windows on       # re-number windows when one is closed
set -g escape-time 0             # no delay for escape key (important for Neovim)
set -g history-limit 10000
set -g focus-events on           # pass focus events through (needed by Neovim)


# ── Keybinds ──────────────────────────────────────────────────────────────────

# Leader key
unbind C-b
set -g prefix C-Space
bind C-x send-prefix

# Reload config
unbind r
bind r source-file ~/.config/tmux/tmux.conf \; display "Config reloaded"

# Pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R


# ── Plugins ───────────────────────────────────────────────────────────────────

# Auto-bootstrap TPM if not installed
if "test ! -d ~/.config/tmux/plugins/tpm" \
  "run 'git clone https://github.com/tmux-plugins/tpm ~/.config/tmux/plugins/tpm && ~/.config/tmux/plugins/tpm/bin/install_plugins'"

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

# Catppuccin theme
set -g @plugin 'catppuccin/tmux'
set -g @catppuccin_flavor "mocha"
set -g @catppuccin_window_status_style "rounded"


# ── Initialize TPM (must be last line before status bar) ──────────────────────

run '~/.config/tmux/plugins/tpm/tpm'


# ── Status bar ────────────────────────────────────────────────────────────────
# (must come after TPM run so catppuccin variables are available)

set -g status-position top
set -g status-left-length 100
set -g status-right-length 100
set -g status-left "#{E:@catppuccin_status_session}"
set -g status-right "#{E:@catppuccin_status_date_time}"
