From 7f748a11620ff81c077bb0ebfc1e5d252e37e41d Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 28 Nov 2022 05:29:08 +0000 Subject: [PATCH] feat: adds tmux support --- .tmux.conf | 22 ++++++++++++++++++++++ init.lua | 1 + lua/config/plugins.lua | 1 + lua/config/tmux.lua | 3 +++ 4 files changed, 27 insertions(+) create mode 100644 .tmux.conf create mode 100644 lua/config/tmux.lua diff --git a/.tmux.conf b/.tmux.conf new file mode 100644 index 0000000..85183ea --- /dev/null +++ b/.tmux.conf @@ -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 diff --git a/init.lua b/init.lua index b26751e..b995013 100644 --- a/init.lua +++ b/init.lua @@ -31,3 +31,4 @@ require("config.surround") require("config.toggleterm") require("config.cursorline") require("config.color-highlight") +require("config.tmux") diff --git a/lua/config/plugins.lua b/lua/config/plugins.lua index 18f6c16..ad3fb64 100644 --- a/lua/config/plugins.lua +++ b/lua/config/plugins.lua @@ -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() diff --git a/lua/config/tmux.lua b/lua/config/tmux.lua new file mode 100644 index 0000000..dbe894a --- /dev/null +++ b/lua/config/tmux.lua @@ -0,0 +1,3 @@ +import("tmux", function (tmux) + tmux.setup() +end)