https://github.com/sontungexpt/smart-resizing
The built-in function help you improve the resizing behavior of neovim
https://github.com/sontungexpt/smart-resizing
lua neovim nvim plugin resizing window
Last synced: 3 months ago
JSON representation
The built-in function help you improve the resizing behavior of neovim
- Host: GitHub
- URL: https://github.com/sontungexpt/smart-resizing
- Owner: sontungexpt
- License: mit
- Created: 2024-08-06T01:51:34.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-08-07T03:40:50.000Z (10 months ago)
- Last Synced: 2025-02-01T23:35:16.964Z (4 months ago)
- Topics: lua, neovim, nvim, plugin, resizing, window
- Language: Lua
- Homepage:
- Size: 15.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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.
## Installation
```lua
--lazy
{
lazy = true,
"sontungexpt/smart-resizing.nvim",
}```
## Features
### 🖼️ **Smart Window Resizing:**
- **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.
### 🚀 **Speed Up When Holding:**
- **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. 🚀
## What's Bad?
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.
## Preiview
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
## Usage
Because this plugin is just contain a builtin function, you need to map it to a keybinding.
like this:```lua
-- 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/lvim.keymap.set("n", "", function() require("smart-resizing").adjust_current_win_width(1, 1) end)
vim.keymap.set("n", "", function() require("smart-resizing").adjust_current_win_width(1, 2) end)
vim.keymap.set("n", "", function() require("smart-resizing").adjust_current_win_height(1, 1) end)
vim.keymap.set("n", "", function() require("smart-resizing").adjust_current_win_height(1, 2) end)
```## Built-in function
### Action:
- 1: decrease
- 2: increaseYou can access this enum by `require("smart-resizing").Action`
### Dimension:
- 1: height
- 2: widthYou can access this enum by `require("smart-resizing").Dimension`
### Functions:
- `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 1
- `adjust_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 1
- `adjust_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 window
- `increase_current_win_size(1, 1)`: increase the height of the current window by 1
- `increase_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 window
- `decrease_current_win_size(1, 1)`: decrease the height of the current window by 1
- `decrease_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
## License
[MIT](./LICENSE)