snacks.nvim icon indicating copy to clipboard operation
snacks.nvim copied to clipboard

bug(lazygit): Lazygit height changes as well when we set height for a terminal

Open FY0u11 opened this issue 1 month ago • 6 comments

Did you check docs and existing issues?

  • [x] I have read all the snacks.nvim docs
  • [x] I have updated the plugin to the latest version before submitting this issue
  • [x] I have searched the existing issues of snacks.nvim
  • [x] I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.11.5

Operating system/version

ubuntu 24

Describe the bug

When I set the height for a terminal:

terminal = { win = { height = 0.3, }, },

The lazygit height is also changing:

Image

Without height option the lazygit looks like:

Image

Steps To Reproduce

  1. Set terminal height in snacks options:

terminal = { win = { height = 0.3, }, },

  1. Open lazygit

Expected Behavior

Lazygit's height should no depend on the terminal's height

Repro

opts = {
terminal = {
  win = {
    height = 0.3,
  },
},
lazygit = {enabled = true}
}

FY0u11 avatar Nov 28 '25 14:11 FY0u11

The workaround for now is setting the lazygit's height explicitly:

lazygit = { win = { height = 0.9 }, },

FY0u11 avatar Nov 28 '25 14:11 FY0u11

That's normal since lazygit is also opened in a terminal window. Instead you want to change the height inside opts.styles. Check the docs.

dpetka2001 avatar Nov 28 '25 23:11 dpetka2001

@dpetka2001 it is behaving the same incorrect way, if we will use styles instead:

styles = {
  terminal = {
    height = 0.3,
  },
},

The lazygit's window will be also 30% of a screen like it was shown on the first screenshot.

FY0u11 avatar Nov 29 '25 16:11 FY0u11

Yes, you're right. It's because both styles don't have a default height and they inherit the height from style["float"]. Yep it seems you have to explicitly set height for lazygit in opts.styles as well. But it makes sense that if you change it in opts.terminal.win, it will also change it for lazygit as well because essentially snacks.lazygit just spawns the lazygit process inside a snacks.terminal window.

PS correction: they don't inherit from style["float"]. The terminal window will open either in a float position or split position depending on if cmd is available or not. Then the correct style will get resolved according to the position of the window.

dpetka2001 avatar Nov 29 '25 16:11 dpetka2001

@dpetka2001 imho that is not good (we need to have default height in both styles so terminal and lazygit's heights won't relate one on the other). If someone (as it was with me) has set the terminal's height explicitly, they may find out after some time (days, or weeks), that lazygit starts to be opened at like 20-30% of the window size (which makes it completely unusable) and then they will start to think what could have gone wrong with lazygit, or which configurations of the many plugins could have broken lazygit's UI

FY0u11 avatar Nov 29 '25 17:11 FY0u11

You could add here https://github.com/folke/snacks.nvim/blob/fe7cfe9800a182274d0f868a74b7263b8c0c020b/lua/snacks/lazygit.lua#L63-L63 height = 0.9, width = 0.9 explicitly and that will behave as you expect. Feel free to create a PR.

Also, I'm just a simple user like you, so you'll have to wait until maintainer reviews your PR.

dpetka2001 avatar Nov 29 '25 17:11 dpetka2001