diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 2d2f795..0ca068d 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -14,5 +14,6 @@ "nvim-treesitter": { "branch": "master", "commit": "dfd4fb330f75595813e2a2f83000580a36dd10ff" }, "nvim-web-devicons": { "branch": "master", "commit": "a1e6268779411048a87f767a27380089362a0ce2" }, "plenary.nvim": { "branch": "master", "commit": "9ce85b0f7dcfe5358c0be937ad23e456907d410b" }, - "telescope.nvim": { "branch": "master", "commit": "54930e1abfc94409e1bb9266e752ef8379008592" } + "telescope.nvim": { "branch": "master", "commit": "54930e1abfc94409e1bb9266e752ef8379008592" }, + "vim-tmux-navigator": { "branch": "master", "commit": "7db70e08ea03b3e4d91f63713d76134512e28d7e" } } \ No newline at end of file diff --git a/.config/nvim/lua/kamu/plugins/tmux.lua b/.config/nvim/lua/kamu/plugins/tmux.lua index 59097de..bbb3789 100644 --- a/.config/nvim/lua/kamu/plugins/tmux.lua +++ b/.config/nvim/lua/kamu/plugins/tmux.lua @@ -1,4 +1,12 @@ -return {} +return { + 'christoomey/vim-tmux-navigator', + config = function() + vim.keymap.set('n', '', ':TmuxNavigateLeft', { noremap = true, silent = true }) + vim.keymap.set('n', '', ':TmuxNavigateDown', { noremap = true, silent = true }) + vim.keymap.set('n', '', ':TmuxNavigateUp', { noremap = true, silent = true }) + vim.keymap.set('n', '', ':TmuxNavigateRight', { noremap = true, silent = true }) + end +} --return { -- "aserowy/tmux.nvim", -- config = function() diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index bf2581e..e0cd15b 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -22,11 +22,12 @@ set -g history-limit 50000 # reload config bind C-r source-file ${XDG_CONFIG_HOME}/tmux/tmux.conf \; display "Config reloaded!" -# switch panes using Alt-arrow without prefix -bind -n M-Left select-pane -L -bind -n M-Right select-pane -R -bind -n M-Up select-pane -U -bind -n M-Down select-pane -D +# switch panes using Alt-arrow without prefix - detect when we are in vim and switch panes there instead +is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)?$'" +bind -n M-Left if-shell "$is_vim" 'send-keys M-Left' 'select-pane -L' +bind -n M-Right if-shell "$is_vim" 'send-keys M-Right' 'select-pane -R' +bind -n M-Up if-shell "$is_vim" 'send-keys M-Up' 'select-pane -U' +bind -n M-Down if-shell "$is_vim" 'send-keys M-Down' 'select-pane -D' # vim style switch pane bind h select-pane -L