added tmux and nvim integration for pane switching

This commit is contained in:
Christopher Beckmann
2023-10-14 15:16:37 +02:00
parent 22e741c30c
commit 1497c7967c
3 changed files with 17 additions and 7 deletions

View File

@@ -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" }
}

View File

@@ -1,4 +1,12 @@
return {}
return {
'christoomey/vim-tmux-navigator',
config = function()
vim.keymap.set('n', '<M-Left>', ':<C-U>TmuxNavigateLeft<cr>', { noremap = true, silent = true })
vim.keymap.set('n', '<M-Down>', ':<C-U>TmuxNavigateDown<cr>', { noremap = true, silent = true })
vim.keymap.set('n', '<M-Up>', ':<C-U>TmuxNavigateUp<cr>', { noremap = true, silent = true })
vim.keymap.set('n', '<M-Right>', ':<C-U>TmuxNavigateRight<cr>', { noremap = true, silent = true })
end
}
--return {
-- "aserowy/tmux.nvim",
-- config = function()

View File

@@ -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