Files
nixos-config/modules/user/config/tmux.conf
T
kiskaadee 437773fe0f refactor(editor): modularize neovim config, add dap support, and unify tmux setup
- Neovim: Modularize configuration into `init.lua`, `lsp.lua`, and `dap.lua`.
- Neovim: Introduce DAP (Debug Adapter Protocol) setup with `nvim-dap` and `nvim-dap-ui` for Python, Rust, and JS/TS.
- Neovim: Add seamless Neovim/Tmux pane navigation (`Ctrl-h/j/k/l`) and window split helpers (`|`, `-`).
- Tmux: Migrate settings to a declarative `tmux.conf` file with `Ctrl+Space` prefix, vi copy mode, and OSC 52 clipboard support.
- Graphical: Expand tree-sitter parsers and declaratively mount Neovim config modules.
2026-08-21 08:18:10 -05:00

115 lines
4.1 KiB
Bash

# ==============================================================================
# Tmux Configuration
# Neovim / Wayland / Alacritty integration
# ==============================================================================
# ------------------------------------------------------------------------------
# Terminal & Colors
# ------------------------------------------------------------------------------
set -g default-terminal "tmux-256color"
# Advertise true color / RGB support to terminal applications (Neovim, etc.)
set -as terminal-features ',*:RGB'
# 1-based indexing for windows and panes (matches keyboard row 1..9)
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
# ------------------------------------------------------------------------------
# General Behavior & Flow Control
# ------------------------------------------------------------------------------
set -g mouse on
set -g focus-events on
set -g history-limit 10000
# Zero delay for escape key responsiveness in Vim/Neovim
set -s escape-time 0
# Keep panes at their current size when the window is resized
setw -g aggressive-resize off
# Vim-style status and copy mode navigation
set -g status-keys vi
set -g mode-keys vi
# ------------------------------------------------------------------------------
# Prefix Key (Ctrl-Space)
# ------------------------------------------------------------------------------
unbind C-b
unbind C-s
set -g prefix C-Space
bind C-Space send-prefix
# ------------------------------------------------------------------------------
# Pane Creation (Shared Mental Model: | for vertical, - for horizontal)
# ------------------------------------------------------------------------------
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# ------------------------------------------------------------------------------
# Seamless Neovim <-> tmux Navigation (Ctrl-h/j/k/l)
# ------------------------------------------------------------------------------
# Smart pane switching with awareness of Vim/Neovim splits.
# When in Neovim, pass Ctrl-h/j/k/l through to Neovim.
# When in shell or at the edge of Neovim, tmux handles pane switching.
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
# Fallback explicit tmux-only navigation via prefix + h/j/k/l
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# ------------------------------------------------------------------------------
# Pane Resizing (prefix + H/J/K/L)
# ------------------------------------------------------------------------------
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# ------------------------------------------------------------------------------
# Copy Mode & Clipboard (Vi-Style + OSC 52 Terminal Clipboard)
# ------------------------------------------------------------------------------
bind Escape copy-mode
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
# Copy selection to tmux buffer and system clipboard through OSC 52
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# Allow tmux to set the system clipboard via terminal OSC 52 sequences (works locally & over SSH)
set -s set-clipboard on
# ------------------------------------------------------------------------------
# Configuration Reload
# ------------------------------------------------------------------------------
bind r source-file ~/.config/tmux/tmux.conf \; display-message "Tmux config reloaded"
# ------------------------------------------------------------------------------
# UI Adjustments
# ------------------------------------------------------------------------------
set -g status-position top
set -g clock-mode-style 12