Skip to content

The built-in function help you improve the resizing behavior of neovim

License

Notifications You must be signed in to change notification settings

sontungexpt/smart-resizing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

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

    --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

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

Usage

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)

Built-in function

Action:

  • 1: decrease
  • 2: increase

You can access this enum by require("smart-resizing").Action

Dimension:

  • 1: height
  • 2: width

You 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

About

The built-in function help you improve the resizing behavior of neovim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages