focus.nvim
focus.nvim copied to clipboard
Support horizontal splits for focus_max_or_equal
At present it only checks for window width, which works for vertical splits. However, horizontal splits will not properly maximise since they will always have the max width, so attempts to focus_max_or_equal will always lead to focus_equalise.
Minimal repro setup:
-- minimal_init.lua
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
{ 'nvim-focus/focus.nvim', version = false, lazy = false, opts = true }
},
})
Repro:
nvim -u minimal_init.lua- Open a horizontal split (e.g. :split and :help lua)
- Try running :FocusMaxOrEqual, it doesn't toggle the window sizing
https://github.com/user-attachments/assets/259980ed-d9a1-401a-888d-f915811e41f5
https://github.com/user-attachments/assets/fa6eda7c-ebbc-45dd-9a31-b0927bafccf4
Thank you very much for your contribution.
Could you please add tests for it? Take a look at https://github.com/nvim-focus/focus.nvim/blob/master/tests/test_splits.lua
make test will run the tests.
@cryptomilk I'd like to write a test for even vs odd row/col count window sizes, but I'm not super familiar with MiniTest and if there's a way to do that. What do you think about opening a floating window or something with fixed dimensions to do some split testing?
That's all possible. See the new_set() function in the tests, it calls child.set_size(50, 180) which sets the size of nvim in rows and columns.
Ping
Superseded by #178 which includes a test.