diff --git a/nvim/dot-config/nvim/lua/plugins/smart-splits.lua b/nvim/dot-config/nvim/lua/plugins/smart-splits.lua new file mode 100644 index 0000000..3c9c673 --- /dev/null +++ b/nvim/dot-config/nvim/lua/plugins/smart-splits.lua @@ -0,0 +1,34 @@ +-- https://github.com/mrjones2014/smart-splits.nvim +return { + "mrjones2014/smart-splits.nvim", + dependencies = { + "kwkarlwang/bufresize.nvim", + }, + config = function() + vim.keymap.set("n", "", require("smart-splits").move_cursor_left) + vim.keymap.set("n", "", require("smart-splits").move_cursor_down) + vim.keymap.set("n", "", require("smart-splits").move_cursor_up) + vim.keymap.set("n", "", require("smart-splits").move_cursor_right) + + vim.keymap.set("n", "r", require("smart-splits").start_resize_mode, { desc = "Enter resize mode" }) + + vim.keymap.set("n", "h", require("smart-splits").swap_buf_left, { desc = "Swap buffer to the left" }) + vim.keymap.set("n", "j", require("smart-splits").swap_buf_down, { desc = "Swap buffer to the bottom" }) + vim.keymap.set("n", "k", require("smart-splits").swap_buf_up, { desc = "Swap buffer to the top" }) + vim.keymap.set("n", "l", require("smart-splits").swap_buf_right, { desc = "Swap buffer to the right" }) + + require("smart-splits").setup({ + at_edge = "stop", + cursor_follows_swapped_bufs = true, + resize_mode = { + silent = true, + hooks = { + on_enter = function() + vim.notify("Entering resize mode...") + end, + on_leave = require("bufresize").register, + }, + }, + }) + end, +} diff --git a/nvim/dot-config/nvim/lua/plugins/tmux-navigation.lua b/nvim/dot-config/nvim/lua/plugins/tmux-navigation.lua deleted file mode 100644 index d8ec342..0000000 --- a/nvim/dot-config/nvim/lua/plugins/tmux-navigation.lua +++ /dev/null @@ -1,18 +0,0 @@ --- https://github.com/alexghergh/nvim-tmux-navigation -return { - 'alexghergh/nvim-tmux-navigation', - event = "VeryLazy", - config = function() - local nvim_tmux_nav = require('nvim-tmux-navigation') - - nvim_tmux_nav.setup { - disable_when_zoomed = true, - keybindings = { - left = '', - down = '', - up = '', - right = '', - }, - } - end -} diff --git a/tmux/dot-tmux.conf b/tmux/dot-tmux.conf index 3261df2..2eda40a 100644 --- a/tmux/dot-tmux.conf +++ b/tmux/dot-tmux.conf @@ -19,11 +19,16 @@ unbind C-b set -g prefix C-a # Improve navigation between tmux and nvim -is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"' -bind -n M-h if-shell "$is_vim" "send-keys M-h" "select-pane -L" -bind -n M-j if-shell "$is_vim" "send-keys M-j" "select-pane -D" -bind -n M-k if-shell "$is_vim" "send-keys M-k" "select-pane -U" -bind -n M-l if-shell "$is_vim" "send-keys M-l" "select-pane -R" +# TODO: Disable pane selection wrap +bind-key -n M-h if -F "#{@pane-is-vim}" 'send-keys M-h' 'select-pane -L' +bind-key -n M-j if -F "#{@pane-is-vim}" 'send-keys M-j' 'select-pane -D' +bind-key -n M-k if -F "#{@pane-is-vim}" 'send-keys M-k' 'select-pane -U' +bind-key -n M-l if -F "#{@pane-is-vim}" 'send-keys M-l' 'select-pane -R' + +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 # Custom keybinds bind '"' split-window -c "#{pane_current_path}"