The built-in function help you improve the resizing behavior of neovim
MIT License
The built-in function help you improve the resizing behavior of neovim.
This is just a sudden thought, so there may be many functions that are not reasonable. Please give me your feedback.
--lazy
{
lazy = true,
"sontungexpt/smart-resizing.nvim",
}
Calculate the area with a lot of empty space compared to the total window and resize based on that.
Compared with the middle position of vim and choose the side with the most empty space to maximize and least empty space to minimize.
If the height cannot be resized further, the window will glide to the bottommost or rightmost position.
✨ Elevate your productivity with effortless window management! Experience a more organized and efficient workspace with just a few keystrokes. 🚀
When there are more than 3 windows in a direction, the resizing behavior can feel uncomfortable. (It's not very bad, but for me, it sometimes feels uncomfortable, and I still haven't found a better behavior to solve this).
But I think it's find than the default behavior of neovim since there never seems to be more than 3 windows in a direction.
https://github.com/user-attachments/assets/0c87fc05-2415-4470-823e-f88b15e68465
https://github.com/user-attachments/assets/3a958a6b-59c6-433b-9585-0afe02ed49b6
https://github.com/user-attachments/assets/a0d5861c-930f-4ee9-b558-feaa786bed81
Because this plugin is just contain a builtin function, you need to map it to a keybinding. like this:
-- recommended to use this function since it has a speed up behavior when you hold the keybinding
-- You should map the keybinding with the modifier key + h/j/k/l
vim.keymap.set("n", "<A-h>", function() require("smart-resizing").adjust_current_win_width(1, 1) end)
vim.keymap.set("n", "<A-l>", function() require("smart-resizing").adjust_current_win_width(1, 2) end)
vim.keymap.set("n", "<A-j>", function() require("smart-resizing").adjust_current_win_height(1, 1) end)
vim.keymap.set("n", "<A-k>", function() require("smart-resizing").adjust_current_win_height(1, 2) end)
You can access this enum by require("smart-resizing").Action
You can access this enum by require("smart-resizing").Dimension
adjust_current_win_width(step, action)
: adjust the width of the current window (speed up behavior when you hold the keybinding)
adjust_current_win_width(1, 1)
: decrease the width of the current window by 1adjust_current_win_width(1, 2)
: increase the width of the current window by 1adjust_current_win_height(step, action)
: adjust the height of the current window (speed up behavior when you hold the keybinding)
adjust_current_win_height(1, 1)
: decrease the height of the current window by 1adjust_current_win_height(1, 2)
: increase the height of the current window by 1increase_current_win_size(step, dimension)
: increase the size of the current window
increase_current_win_size(1, 1)
: increase the height of the current window by 1increase_current_win_size(1, 2)
: increase the width of the current window by 1decrease_current_win_size(step, dimension)
: decrease the size of the current window
decrease_current_win_size(1, 1)
: decrease the height of the current window by 1decrease_current_win_size(1, 2)
: decrease the width of the current window by 1increase_current_win_width(step)
: increase the width of the current window by 1
decrease_current_win_width(step)
: decrease the width of the current window by 1
increase_current_win_height(step)
: increase the height of the current window by 1
decrease_current_win_height(step)
: decrease the height of the current window by 1