smart-splits.nvim allows for easier resizing of neovim splits, also handled tmux integration
This commit is contained in:
parent
1125c6543a
commit
ad8a5caa99
34
nvim/dot-config/nvim/lua/plugins/smart-splits.lua
Normal file
34
nvim/dot-config/nvim/lua/plugins/smart-splits.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
-- https://github.com/mrjones2014/smart-splits.nvim
|
||||
return {
|
||||
"mrjones2014/smart-splits.nvim",
|
||||
dependencies = {
|
||||
"kwkarlwang/bufresize.nvim",
|
||||
},
|
||||
config = function()
|
||||
vim.keymap.set("n", "<M-h>", require("smart-splits").move_cursor_left)
|
||||
vim.keymap.set("n", "<M-j>", require("smart-splits").move_cursor_down)
|
||||
vim.keymap.set("n", "<M-k>", require("smart-splits").move_cursor_up)
|
||||
vim.keymap.set("n", "<M-l>", require("smart-splits").move_cursor_right)
|
||||
|
||||
vim.keymap.set("n", "<C-w>r", require("smart-splits").start_resize_mode, { desc = "Enter resize mode" })
|
||||
|
||||
vim.keymap.set("n", "<C-w>h", require("smart-splits").swap_buf_left, { desc = "Swap buffer to the left" })
|
||||
vim.keymap.set("n", "<C-w>j", require("smart-splits").swap_buf_down, { desc = "Swap buffer to the bottom" })
|
||||
vim.keymap.set("n", "<C-w>k", require("smart-splits").swap_buf_up, { desc = "Swap buffer to the top" })
|
||||
vim.keymap.set("n", "<C-w>l", require("smart-splits").swap_buf_right, { desc = "Swap buffer to the right" })
|
||||
|
||||
require("smart-splits").setup({
|
||||
at_edge = "stop",
|
||||
cursor_follows_swapped_bufs = true,
|
||||
resize_mode = {
|
||||
silent = true,
|
||||
hooks = {
|
||||
on_enter = function()
|
||||
vim.notify("Entering resize mode...")
|
||||
end,
|
||||
on_leave = require("bufresize").register,
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
-- https://github.com/alexghergh/nvim-tmux-navigation
|
||||
return {
|
||||
'alexghergh/nvim-tmux-navigation',
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
local nvim_tmux_nav = require('nvim-tmux-navigation')
|
||||
|
||||
nvim_tmux_nav.setup {
|
||||
disable_when_zoomed = true,
|
||||
keybindings = {
|
||||
left = '<M-h>',
|
||||
down = '<M-j>',
|
||||
up = '<M-k>',
|
||||
right = '<M-l>',
|
||||
},
|
||||
}
|
||||
end
|
||||
}
|
|
@ -19,11 +19,16 @@ unbind C-b
|
|||
set -g prefix C-a
|
||||
|
||||
# Improve navigation between tmux and nvim
|
||||
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
|
||||
bind -n M-h if-shell "$is_vim" "send-keys M-h" "select-pane -L"
|
||||
bind -n M-j if-shell "$is_vim" "send-keys M-j" "select-pane -D"
|
||||
bind -n M-k if-shell "$is_vim" "send-keys M-k" "select-pane -U"
|
||||
bind -n M-l if-shell "$is_vim" "send-keys M-l" "select-pane -R"
|
||||
# TODO: Disable pane selection wrap
|
||||
bind-key -n M-h if -F "#{@pane-is-vim}" 'send-keys M-h' 'select-pane -L'
|
||||
bind-key -n M-j if -F "#{@pane-is-vim}" 'send-keys M-j' 'select-pane -D'
|
||||
bind-key -n M-k if -F "#{@pane-is-vim}" 'send-keys M-k' 'select-pane -U'
|
||||
bind-key -n M-l if -F "#{@pane-is-vim}" 'send-keys M-l' 'select-pane -R'
|
||||
|
||||
bind-key -T copy-mode-vi 'M-h' select-pane -L
|
||||
bind-key -T copy-mode-vi 'M-j' select-pane -D
|
||||
bind-key -T copy-mode-vi 'M-k' select-pane -U
|
||||
bind-key -T copy-mode-vi 'M-l' select-pane -R
|
||||
|
||||
# Custom keybinds
|
||||
bind '"' split-window -c "#{pane_current_path}"
|
||||
|
|
Loading…
Reference in New Issue
Block a user