Skip to content

Commit

Permalink
feat: adds tmux support
Browse files Browse the repository at this point in the history
  • Loading branch information
ixahmedxi committed Nov 28, 2022
1 parent bed23d4 commit 7f748a1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .tmux.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This maps tmux navigation and resize keys to the neovim ones so that they are both the same
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' { if -F '#{pane_at_left}' '' 'select-pane -L' }
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' { if -F '#{pane_at_bottom}' '' 'select-pane -D' }
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' { if -F '#{pane_at_top}' '' 'select-pane -U' }
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' { if -F '#{pane_at_right}' '' 'select-pane -R' }

bind-key -T copy-mode-vi 'C-h' if -F '#{pane_at_left}' '' 'select-pane -L'
bind-key -T copy-mode-vi 'C-j' if -F '#{pane_at_bottom}' '' 'select-pane -D'
bind-key -T copy-mode-vi 'C-k' if -F '#{pane_at_top}' '' 'select-pane -U'
bind-key -T copy-mode-vi 'C-l' if -F '#{pane_at_right}' '' 'select-pane -R'

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
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ require("config.surround")
require("config.toggleterm")
require("config.cursorline")
require("config.color-highlight")
require("config.tmux")
1 change: 1 addition & 0 deletions lua/config/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ return packer.startup(function(use)
use("rcarriga/nvim-notify")
use("ThePrimeagen/vim-be-good")
use("davidgranstrom/nvim-markdown-preview")
use("aserowy/tmux.nvim")

if PACKER_BOOTSTRAP then
require("packer").sync()
Expand Down
3 changes: 3 additions & 0 deletions lua/config/tmux.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import("tmux", function (tmux)
tmux.setup()
end)

0 comments on commit 7f748a1

Please sign in to comment.