Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behavior when resizing with autocmd #84

Open
thraizz opened this issue May 5, 2022 · 7 comments
Open

Strange behavior when resizing with autocmd #84

thraizz opened this issue May 5, 2022 · 7 comments
Labels
good first issue Good for newcomers

Comments

@thraizz
Copy link

thraizz commented May 5, 2022

Hi, I am currently trying to get nvim to resize accordingly when I resize the terminal.
I tried to set it up with an autocomand like
autocmd VimResized * <cmd>lua require"focus".resize()<cr>
but this produces a blank screen and then, after what looks like a timeout, redraws without a resize.
Is this related to no window currently being focused? Can I work around this somehow?
Thanks and best regards!

@beauwilliams beauwilliams added the good first issue Good for newcomers label Jul 24, 2022
@beauwilliams
Copy link
Collaborator

beauwilliams commented Jul 24, 2022

Hey @thraizz I see your issue on my end too.

Noticed that if I hit <esc> or any key for that matter after resizing my terminal window that the windows resize correctly again.

Perhaps adding an <esc> at the end of that aucmd there might solve the issue?

@clement-buchart
Copy link

clement-buchart commented Oct 19, 2022

Hello,

I have the same issue with the following autocmd :

vim.api.nvim_create_autocmd("VimResized", {
  desc = "Resize split.",
  group = vim.api.nvim_create_augroup("Focus.nvim", { clear = true }),
  pattern = "*",
  callback = function(args)
    require("focus").resize()
  end,
})

There is a message in the :messages with the following error :

Error detected while processing VimResized Autocommands for "*":
Error executing lua callback: ...ck/packer/start/focus.nvim/lua/focus/modules/resizer.lua:68: E592: 'winwidth' cannot be smaller than 'winminwidth'
stack traceback:
	[C]: in function '__newindex'
	...ck/packer/start/focus.nvim/lua/focus/modules/resizer.lua:68: in function 'split_resizer'
	...vim/site/pack/packer/start/focus.nvim/lua/focus/init.lua:54: in function 'resize'
	/home/clement/.config/nvim/lua/user/windows/init.lua:46: in function </home/clement/.config/nvim/lua/user/windows/init.lua:43>

Hope this helps :)

Edit :
Naively changing line 68 from

vim.o.winwidth = golden_ratio_width()

to

vim.o.winwidth = math.max(golden_ratio_width(),vim.o.winminwidth)

seems to fix the issue, but I'm not sure it's a proper fix.

@beauwilliams
Copy link
Collaborator

Ah yes, this is a common problem. In 0.8 is has been allowed to set winminwidth to 0

This should provide a stable path to fix this problem.

I will have a look

@cryptomilk
Copy link
Collaborator

The refactor branch has tests now. We should write tests for resizing vim.

@Leandros
Copy link

Leandros commented Oct 2, 2023

I'm getting the following error trying to open a plenary.nvim popup for lsp code actions:

Screenshot 2023-10-02 at 14 53 12

@willothy
Copy link
Contributor

willothy commented Oct 3, 2023

I'm getting the following error trying to open a plenary.nvim popup for lsp code actions:

I'll look into this today - would you mind opening a separate issue and providing a minimal init?

@Leandros
Copy link

Leandros commented Oct 4, 2023

Yes, will do.

@willothy: I have created #138 with all information required. Let me know if you need more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

6 participants