shortcuts / no-neck-pain.nvim

☕ Dead simple yet super extensible plugin to center the currently focused buffer to the middle of the screen.
MIT License
558 stars 13 forks source link

Feature request: Option to fix window width of pads #216

Open AlphabetsAlphabets opened 1 year ago

AlphabetsAlphabets commented 1 year ago

Describe the problem

When the two pads show up (or one) to center the content on the screen, I would be nice if the user could optionally configure it to have fixed widths.

The reason I think this is nice is because when I open up a horizontal split and would either maximize the top or bottom split. I sometimes want to look at both of them at the same time again, I would use <C-w>=. But that also resizes width of the pads.

Describe the solution

In the setup function there could be fixwidth = true in buffers.

    buffers = {
      right = {
        enabled = false,
      },
    },

Or it could be for left and right as well. Having this set would just set the winfixedwidth option for the left and right buffers.

shortcuts commented 1 year ago

hey, thanks for the suggestion! I wonder if this is applicable as (IIRC) there's no events to listen to for a window resize, but definitely worth investigating!

AlphabetsAlphabets commented 1 year ago

hey, thanks for the suggestion! I wonder if this is applicable as (IIRC) there's no events to listen to for a window resize, but definitely worth investigating!

I'm not sure what the code is like under the hood but is there a need to listen for a window resize event? If I move to the buffers created by the plugin and manually type :set wfw I can use <C-w>= as much as I want, and the buffer with wfw set won't change in size.

shortcuts commented 1 year ago

If I move to the buffers created by the plugin and manually type :set wfw I can use = as much as I want, and the buffer with wfw set won't change in size.

That is interesting, I assume providing the wo option to the side buffers would be enough, as we forward any bo or wo options, something like:

require("no-neck-pain").setup({
    width = 70,
    buffers = {
        wo = {
            winfixwidth = true,
        },
    },
})

but IIRC it gets overridden if you open a vsplit.


Could you share the full set of command you'd apply and the expect behavior? So that I can both see if it's doable, and provide a test suite :)

AlphabetsAlphabets commented 1 year ago

but IIRC it gets overridden if you open a vsplit.

Looks like you're right, I didn't think about this. I'd have to use :set wfw each time the pads disappear.

I assume providing the wo option to the side buffers would be enough, as we forward any bo or wo options, something like:

If that's the case that should be good right?

Could you share the full set of command you'd apply and the expect behavior? So that I can both see if it's doable, and provide a test suite :)

In my case I only have the left pad open so

  1. I move to it <C-w>h
  2. Then fix its width with :set wfw.
  3. Go back to the file I was on <C-w>l
  4. Make a few horizontal splits, maximize one of them. Then use <C-w>= to make all the windows equal. What should happen is that every window will resize except for the pads.
AlphabetsAlphabets commented 7 months ago

Hey @shortcuts I completely forgot about this, I was wondering if you have the time to look at this again?