diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index f7354ae..48d278d 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -54,6 +54,7 @@ "telescope-tabs": { "branch": "master", "commit": "0a678eefcb71ebe5cb0876aa71dd2e2583d27fd3" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "tmux.nvim": { "branch": "main", "commit": "2c1c3be0ef287073cef963f2aefa31a15c8b9cd8" }, "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "tree-sitter-nu": { "branch": "main", "commit": "c10340b5bb3789f69182acf8f34c3d4fc24d2fe1" }, "tree-sitter-templ": { "branch": "master", "commit": "7f7f06b3931ca00e8ddfbeab3fc08ad00d297fad" }, diff --git a/nvim/.config/nvim/lua/plugins/tmux.lua b/nvim/.config/nvim/lua/plugins/tmux.lua new file mode 100644 index 0000000..eb2918c --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/tmux.lua @@ -0,0 +1,25 @@ +return { + { + 'aserowy/tmux.nvim', + opts = { + navigation = { + enable_default_keybindings = false, + }, + resize = { + enable_default_keybindings = false, + }, + }, + keys = { + { '', [[lua require("tmux").move_left()]] }, + { '', [[lua require("tmux").move_bottom()]] }, + { '', [[lua require("tmux").move_top()]] }, + { '', [[lua require("tmux").move_right()]] }, + { '', [[lua require("tmux").next_window()]] }, + { '', [[lua require("tmux").previous_window()]] }, + { '', [[lua require("tmux").resize_left()]] }, + { '', [[lua require("tmux").resize_bottom()]] }, + { '', [[lua require("tmux").resize_top()]] }, + { '', [[lua require("tmux").resize_right()]] }, + }, + }, +} diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index 6092b0c..be2b861 100644 --- a/tmux/.tmux.conf +++ b/tmux/.tmux.conf @@ -3,15 +3,6 @@ set -g status-fg colour7 set -sg escape-time 0 -bind-key -n M-j select-pane -D -bind-key -n M-k select-pane -U -bind-key -n M-h select-pane -L -bind-key -n M-l select-pane -R -bind-key -n M-J switch-client -n -bind-key -n M-K switch-client -p -bind-key -n M-H previous-window -bind-key -n M-L next-window - bind-key -n M-1 select-window -t 1 bind-key -n M-2 select-window -t 2 bind-key -n M-3 select-window -t 3 @@ -56,3 +47,39 @@ set -g status-left " #[fg=green]#[bg=green]#[fg=black] #H #[bg=default]#[fg=g set -g status-left-length 50 set -g status-right "#[fg=green]#[bg=green]#[fg=black] %H:%M #[bg=default]#[fg=green] " set-window-option -g window-status-current-format '#[fg=green]#[bg=green]#[fg=black] #I:#W#F #[fg=green]#[bg=black]' + +is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?\.?(view|n?vim?x?)(-wrapped)?(diff)?$'" + +bind-key -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'select-pane -L' +bind-key -n 'M-j' if-shell "$is_vim" 'send-keys M-j' 'select-pane -D' +bind-key -n 'M-k' if-shell "$is_vim" 'send-keys M-k' 'select-pane -U' +bind-key -n 'M-l' if-shell "$is_vim" 'send-keys M-l' 'select-pane -R' +bind-key -n 'M-n' if-shell "$is_vim" 'send-keys M-n' 'select-window -n' +bind-key -n 'M-p' if-shell "$is_vim" 'send-keys M-p' 'select-window -p' + +bind-key -T copy-mode-vi 'M-h' select-pane -L +bind-key -T copy-mode-vi 'M-j' select-pane -D +bind-key -T copy-mode-vi 'M-k' select-pane -U +bind-key -T copy-mode-vi 'M-l' select-pane -R +bind-key -T copy-mode-vi 'M-n' select-window -n +bind-key -T copy-mode-vi 'M-p' select-window -p + +bind -n 'M-H' if-shell "$is_vim" 'send-keys M-H' 'resize-pane -L 1' +bind -n 'M-J' if-shell "$is_vim" 'send-keys M-J' 'resize-pane -D 1' +bind -n 'M-K' if-shell "$is_vim" 'send-keys M-K' 'resize-pane -U 1' +bind -n 'M-L' if-shell "$is_vim" 'send-keys M-L' 'resize-pane -R 1' + +bind-key -T copy-mode-vi M-H resize-pane -L 1 +bind-key -T copy-mode-vi M-J resize-pane -D 1 +bind-key -T copy-mode-vi M-K resize-pane -U 1 +bind-key -T copy-mode-vi M-L resize-pane -R 1 + +bind -n 'C-M-h' if-shell "$is_vim" 'send-keys C-M-h' 'swap-pane -s "{left-of}"' +bind -n 'C-M-j' if-shell "$is_vim" 'send-keys C-M-j' 'swap-pane -s "{down-of}"' +bind -n 'C-M-k' if-shell "$is_vim" 'send-keys C-M-k' 'swap-pane -s "{up-of}"' +bind -n 'C-M-l' if-shell "$is_vim" 'send-keys C-M-l' 'swap-pane -s "{right-of}"' + +bind-key -T copy-mode-vi C-M-h swap-pane -s "{left-of}" +bind-key -T copy-mode-vi C-M-j swap-pane -s "{down-of}" +bind-key -T copy-mode-vi C-M-k swap-pane -s "{up-of}" +bind-key -T copy-mode-vi C-M-l swap-pane -s "{right-of}"