From 4cf0eedd56793cd3005b306bb780bc60b6d512fe Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Sun, 1 May 2022 12:20:37 +0200 Subject: [PATCH] vim,tmux:plugs: Add `vim-tmux-navigator` [vim-tmux-navigator][1]: > Seamless navigation between tmux panes and vim splits Add the hybrid vim/tmux plugin `vim-tmux-navigator` to switch between tmux panes and vim splits with `C-[hjkl]`. Add vim-tmux-navigator as a submodule in tmux/plugins and create a symlink from vim/pack/plugins/start. Get rid of similar switching keymappings in the vim and tmux configs. [1]: https://github.com/christoomey/vim-tmux-navigator --- .config/tmux/plugins/vim-tmux-navigator | 1 + .config/tmux/tmux.conf | 16 ++++------------ .../vim/pack/plugins/start/vim-tmux-navigator | 1 + .config/vim/vimrc.d/40-keys.vim | 5 ----- .gitmodules | 3 +++ 5 files changed, 9 insertions(+), 17 deletions(-) create mode 160000 .config/tmux/plugins/vim-tmux-navigator create mode 120000 .config/vim/pack/plugins/start/vim-tmux-navigator diff --git a/.config/tmux/plugins/vim-tmux-navigator b/.config/tmux/plugins/vim-tmux-navigator new file mode 160000 index 0000000..9ca5bfe --- /dev/null +++ b/.config/tmux/plugins/vim-tmux-navigator @@ -0,0 +1 @@ +Subproject commit 9ca5bfe5bd274051b5dd796cc150348afc993b80 diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index 025900c..bfe9cca 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -25,12 +25,6 @@ bind-key > split-window -h -c "#{pane_current_path}" # Create new window in current path bind-key -T prefix c new-window -c "#{pane_current_path}" -# Change panes with Alt- -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 - # Resource config bind-key -T prefix R source-file "$XDG_CONFIG_HOME/tmux/tmux.conf" \; display-message "Sourced $XDG_CONFIG_HOME/tmux/tmux.conf" @@ -50,17 +44,14 @@ bind-key -T copy-mode-vi v send-keys -X begin-selection # Yank into system clipboard bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -selection clipboard" -# Navigate panes with hjkl +# Navigate panes with -[hjkl] +# NOTE: C-[hjkl] (w/o prefix) moves through vim splits and tmux panes +# See vim-tmux-navigator unbind -T prefix l bind -T prefix h select-pane -L bind -T prefix j select-pane -D bind -T prefix k select-pane -U bind -T prefix l select-pane -R -# Allow holding Ctrl after pressing the prefix -bind -T prefix C-h select-pane -L -bind -T prefix C-j select-pane -D -bind -T prefix C-k select-pane -U -bind -T prefix C-l select-pane -R # Resize panes with Alt-Shift-[hjkl] bind -n M-H resize-pane -L bind -n M-J resize-pane -D @@ -82,6 +73,7 @@ set -g @plugin 'tmux-plugins/tmux-prefix-highlight' set -g @plugin 'tmux-plugins/tmux-resurrect' set -g @plugin 'tmux-plugins/tmux-sensible' set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'vim-tmux-navigator' # Capture pane content set -g @resurrect-capture-pane-contents 'on' diff --git a/.config/vim/pack/plugins/start/vim-tmux-navigator b/.config/vim/pack/plugins/start/vim-tmux-navigator new file mode 120000 index 0000000..914ebe1 --- /dev/null +++ b/.config/vim/pack/plugins/start/vim-tmux-navigator @@ -0,0 +1 @@ +../../../../tmux/plugins/vim-tmux-navigator/ \ No newline at end of file diff --git a/.config/vim/vimrc.d/40-keys.vim b/.config/vim/vimrc.d/40-keys.vim index 89cffe2..a0c349f 100644 --- a/.config/vim/vimrc.d/40-keys.vim +++ b/.config/vim/vimrc.d/40-keys.vim @@ -11,11 +11,6 @@ nnoremap :nohlsearch " Create new panes nnoremap N :vsplit nnoremap n :split -" Move between panes -nnoremap -nnoremap -nnoremap -nnoremap " Substitute command if (exists('+inccommand') && &inccommand != '') diff --git a/.gitmodules b/.gitmodules index 9949408..e8573aa 100644 --- a/.gitmodules +++ b/.gitmodules @@ -35,6 +35,9 @@ [submodule "tpm"] path = .config/tmux/plugins/tpm url = https://github.com/tmux-plugins/tpm +[submodule "vim-tmux-navigator"] + path = .config/tmux/plugins/vim-tmux-navigator + url = https://github.com/christoomey/vim-tmux-navigator # vim [submodule "arm-syntax-vim"]