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.
-
- Hold the Keybinding:
- When you hold the keybinding, the window will resize faster, allowing you to quickly adjust the window size.
✨ 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.
2024-08-06_09.55.36-recording_cut-2024-08-06_09.56.47.mp4
2024-08-06_09.59.11-recording_cut-2024-08-06_10.00.33.mp4
2024-08-06_10.02.25-recording_cut-2024-08-06_10.03.22.mp4
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)
- 1: decrease
- 2: increase
You can access this enum by require("smart-resizing").Action
- 1: height
- 2: width
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 1
-
adjust_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 1
-
increase_current_win_size(step, dimension)
: increase the size of the current windowincrease_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 1
-
decrease_current_win_size(step, dimension)
: decrease the size of the current windowdecrease_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 1
-
increase_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