# Keybinds
set-option -g prefix C-Space
bind-key -T root C-M-Left if-shell -F "#{pane_at_left}" "previous-window\; refresh-client -S" "select-pane -L\; refresh-client -S"
bind-key -T root C-M-Right if-shell -F "#{pane_at_right}" "next-window\; refresh-client -S" "select-pane -R\; refresh-client -S"
bind-key -T root C-M-Up select-pane -U\; refresh-client -S
bind-key -T root C-M-Down select-pane -D\; refresh-client -S


bind-key -T root F2 split-window -h\; refresh-client -S
bind-key -T root F1 split-window -v\; refresh-client -S

bind-key -T root C-M-+ neww\; refresh-client -S
bind-key -T root C-M-- kill-pane\; refresh-client -S

bind j command-prompt -p "Target window num:" { join-pane -t ":%%" }

bind-key -T prefix v copy-mode
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel

bind-key -T root 'M-S-Left' resize-pane -L 3
bind-key -T root 'M-S-Down' resize-pane -D 3
bind-key -T root 'M-S-Up' resize-pane -U 3
bind-key -T root 'M-S-Right' resize-pane -R 3

bind -T prefix Left swap-pane -s "{left-of}"
bind -T prefix Down swap-pane -s "{down-of}"
bind -T prefix Up swap-pane -s "{up-of}"
bind -T prefix Right swap-pane -s "{right-of}"

set -g extended-keys always
set -g mode-keys vi

# Style
set-window-option -g window-active-style 'bg=terminal'
set-window-option -g status-style 'bg=terminal'
set -s set-clipboard on

# Enable Colors
set -g default-terminal 'tmux-256color'
set -ga terminal-overrides ",*:Tc"
set -ga terminal-overrides '*:Ss=\E[%p1%d q:Se=\E[6 q'

# Pane Border & status
set -g pane-border-status off
set -g status-position bottom

# Color
set -g window-style 'bg=terminal,fg=terminal'
set -g window-active-style 'bg=terminal'
set -g window-status-separator ""

# Image preview
set -g allow-passthrough on

# Vim TPipeLine
set -g focus-events on
set -g status-style bg=default
set -g status-left-length 99
set -g status-right-length 99
set -g status-justify centre

# Scrolling
set -g mouse on
set-option -g focus-events on

# Copy but do not clear selection and do not exit copy mode
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection
set -g @mighty-scroll-interval 7
set -g history-limit 50000

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-fpp'
set -g @plugin 'erikw/tmux-powerline'
# set -g @plugin 'aserowy/tmux.nvim'

# Plugin Settings - tmux.nvim
# Navigation
# set -g @tmux-nvim-navigation true
# set -g @tmux-nvim-navigation-cycle true
# set -g @tmux-nvim-navigation-keybinding-left 'M-Left'
# set -g @tmux-nvim-navigation-keybinding-down 'M-Down'
# set -g @tmux-nvim-navigation-keybinding-up 'M-Up'
# set -g @tmux-nvim-navigation-keybinding-right 'M-Right'
#
# # Resize
# set -g @tmux-nvim-resize true
# set -g @tmux-nvim-resize-step-x 5
# set -g @tmux-nvim-resize-step-y 5
# set -g @tmux-nvim-resize-keybinding-left 'C-Left'
# set -g @tmux-nvim-resize-keybinding-down 'C-Down'
# set -g @tmux-nvim-resize-keybinding-up 'C-Up'
# set -g @tmux-nvim-resize-keybinding-right 'C-Right'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
