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

[Feature Request] inner-padding around nvim #140

Closed
kiuKisas opened this issue Feb 18, 2020 · 39 comments
Closed

[Feature Request] inner-padding around nvim #140

kiuKisas opened this issue Feb 18, 2020 · 39 comments
Labels
enhancement New feature or request

Comments

@kiuKisas
Copy link

It can be nice to be able to set padding aroud nvim instance.
Here is an exemple with vim on my terminal on the right.

@Kethku
Copy link
Member

Kethku commented Feb 18, 2020

Correct me if I'm wrong, but this feels like a feature that should be enabled in your window manager, not the app

@Kethku
Copy link
Member

Kethku commented Feb 18, 2020

I don't think it should be the prerogative of the gui to add padding around windows when all other situations that is undesirable.

@kiuKisas
Copy link
Author

Hum.. I'm talking about inner-padding, but my WM is pretty minimalist, maybe you'll see my point with more decoration:
2020-02-18-192452_1920x1080_scrot

@kiuKisas kiuKisas changed the title [Features Request] Padding around vim [Feature Request] inner-padding around nvim Feb 18, 2020
@Kethku
Copy link
Member

Kethku commented Feb 18, 2020

This is what I'm talking about. I don't see other apps really adding options for inner padding, and I'm concerned about the added complexity for such a niche feature.

@kiuKisas
Copy link
Author

Ho ok, sorry about that, I though you think about window borders. Well, most of the terminal I used have this options (vte-based, urxvt.. ) so I'm used to it. But you probably right, not a lot of people will need it. I'll see if I can trick my vm. Thank's for your time ! :)

@Kethku
Copy link
Member

Kethku commented Feb 18, 2020

Window border handling is currently all managed by the windowing system which is currently managed by winit, but moving to sdl2 since winit appears to be buggy in a few crucial ways. I'm actually going to reopen this as a future enhancement, but at the moment it is going to be very low priority :( If done in an unobtrusive way I would be happy to take a pull request, but I'd probably be pretty picky about much added complexity since its just a few of us managing the project :)

@Kethku Kethku added the enhancement New feature or request label Feb 18, 2020
@Kethku Kethku reopened this Feb 18, 2020
@jonvaldes
Copy link
Collaborator

jonvaldes commented Mar 1, 2020

I did a quick experiment, and submitted my WIP to this branch: https://github.com/Kethku/neovide/tree/window-margin-experiment
It is very broken right now, but it shows a few issues we'd have to solve to fully implement this.

This is how it looks right now on Linux (Sway window manager), with a huge black margin:
Screenshot_2020-03-01_16-03-1583077228

Issues I've found:

  • Right now nvim tells us to what color clear the background of each cell. But does it tell us what color to use for areas that have no cell attached? Right now we're not clearing that, and it just accumulates garbage over time
  • Changing the margin in runtime can result in horrible visual artifacts, as some parts realize there's been a margin change and others don't. Not sure exactly where that's coming from right now.
  • Sometimes the previous issue happens on startup too. My guess is the settings sometimes load after the window is created, and then it behaves like a runtime change.
  • The cursor misaligns when adding the margin. I tried just offsetting the cursor by the margin, but it seems to have also made each cursor cell bigger than the actual text cells. No idea why.

@Kethku
Copy link
Member

Kethku commented Sep 8, 2020

I'm going to close this as out of scope. I think this adds too much complexity for a niche use case

@Kethku Kethku closed this as completed Sep 8, 2020
@zezic
Copy link

zezic commented Oct 7, 2020

@jonvaldes I tried to do the same based on your fork with the little changes and got pretty nice results. No glitches, margin have proper background color, pointer positioning is absolutely OK, mouse position is handled correctly and it feels like complexity of the code is almost not increased. I'm new to Rust, I will refactor my code a bit later and try to prepare a good PR for review.

This is how it looks at the moment on Linux:
Neovid-margins

@shaunsingh
Copy link
Collaborator

Gui's on macOS (and I assume windows) can't take advantage of padding through the WM/compositor, since yabai etc. doesn't support it. I understand its outside the scope of neovim, but could you kindly reconsider opening the issue?

@Kethku
Copy link
Member

Kethku commented Jun 14, 2021

Done. However I think its pretty low priority unless somebody wants to take it on.

@Kethku Kethku reopened this Jun 14, 2021
@shaunsingh
Copy link
Collaborator

@zezic do you mind sharing your WIP code?

@zezic
Copy link

zezic commented Jun 17, 2021

@shaunsingh It seems like I deleted it from my disk. It was mostly based on this commit: c376629
If I remember correctly, there were much additions in the main repo after that, many of them included various changes related to multigrid feature. Probably, this is why I decided that it will be easier to rewrite the feature from scratch.

@shaunsingh
Copy link
Collaborator

No problem. Alacritty has a similar option so I'll take a look at both.

@seanstrom
Copy link
Contributor

@Kethku Could you help guide an implementation of this feature? At the moment I've written some code that changes the size of the rendered image on the canvas, instead of changing the grid width/height. Is that the right approach?

My intention is to allow for pixel values to represent window padding, but I'm not sure what else needs to be adjusted with those padding values. I have attempted to configure the CursorRender with the padding values, but I'm wondering if it would be better to adjust the GridRenderer instead?

Any thoughts?

@MultisampledNight
Copy link
Contributor

In the end, padding is "just" shrinking the character grid. So the cursor renderer has nothing to do with that.

Changing the actual rendered size though sounds... a bit interesting. Do you scale down from the original image or do you just provide whole other sizes from the start on?

@seanstrom
Copy link
Contributor

In one of my first attempts I tried decreasing the CharacterGrid and shifting it with the grid position, but it seemed to truncate the content. For example, my status bar at the bottom right would be clipped if I decreased the grid width. Though I'm curious if that is the best way to shrink the grid.

For my second attempt I tried rendering all the content with no changes to the size of the character grid, but I changed the surface image dimensions and the pixel region. This cleanly moves things into view with the padding (no truncating) but it confuses the CursorRenderer. I think the CursorRenderer uses the font-width and grid size to figure out where it should be, but changing the image size seems to implicitly change the font-width of the image, which means I have to explain to the CursorRenderer how to handle the padding sizes. But this doesn't seem to be a simple solution because many things rely on the font dimensions and grid size.

Ideally I would be able to simply decrease the character grid width without the weird truncating stuff. But I'm not sure how to do this, any ideas?

@Kethku
Copy link
Member

Kethku commented May 26, 2022

Will read this sometime today and respond with thoughts. Thanks for the ping!

@seanstrom
Copy link
Contributor

Okay I have an update:
I think I was able to adjust the CursorRenderer and the MouseManager to work properly, but now I'm noticing that something with the scrolling logic causes the new adjustments to miscalculate the CursorRenderer position. I'm not certain if it's the scrolling logic, but I'm thinking that it might be because I haven't adjusted anything with scrolling and I'm only noticing miscalculations for the y-axis of the CursorRenderer.

For more context here's a working version of the code pushed up to a branch:
main...seanstrom:feature-window-padding

Maybe somebody who understands the scrolling logic and the changes I made can help point me in the right direction. Let me know what ya'll think when you have a chance. Thank you!

@seanstrom
Copy link
Contributor

Okay I took a step back to solve this without squishing the image. I was noticing too many glitches that would result from too much padding. So I went through the code again and found a simpler solution by finding the best location to reduce the size of the character grid. This results in no truncating of content and no weird re-calculations of the CursorRenderer & stuff. Here's a new commit with the basics of what I have:
main...seanstrom:feature-window-padding-V2

@MultisampledNight I can see now what you meant about not needing to tweak the CursorRenderer, this approach fits much better with all the existing pieces. Thanks for your input! 🙏

@seanstrom
Copy link
Contributor

seanstrom commented May 29, 2022

Here's a GIF of what I have working in the latest version:

Neovide-Window-Padding

@i-am-the-slime
Copy link

@seanstrom So? It looks very nice, how do we get it?

@seanstrom
Copy link
Contributor

@i-am-the-slime at the moment it’s here: https://github.com/seanstrom/neovide/tree/feature-window-padding-V2

If you pull down my fork of neovide with that branch you can build it from source. Though it should likely be updated with the latest commits from the official main branch. Happy to put together a PR if the maintainers are interested too.

@MultisampledNight
Copy link
Contributor

Please do! This is great.

@seanstrom
Copy link
Contributor

Thanks @MultisampledNight 😸

Here’s a link to the pull request for anyone interested: #1632

@seanstrom
Copy link
Contributor

Good news, the branch implementing window padding support was recently merged into main 🙌
Thank you for all the help @MultisampledNight, very appreciated 🍻

@nmfirdausw
Copy link

nmfirdausw commented Dec 10, 2022

How to set window padding? through neovim config? any guide?

@MultisampledNight
Copy link
Contributor

...I seriously still haven't managed to do the docs on this. You need to be running on git main, and you can set the variables g:neovide_padding_{top,right,bottom,left} (with the {} to be interpreted as in shell syntax) to control the padding.

@seanstrom
Copy link
Contributor

I have mine configured with VimScript like this:

let g:neovide_padding_top=35
let g:neovide_padding_left=28
let g:neovide_padding_right=28
let g:neovide_padding_bottom=10

Which I think in Lua would be this:

vim.g.neovide_padding_top=35
vim.g.neovide_padding_left=28
vim.g.neovide_padding_right=28
vim.g.neovide_padding_bottom=10

@nmfirdausw
Copy link

I have mine configured with VimScript like this:

let g:neovide_padding_top=35
let g:neovide_padding_left=28
let g:neovide_padding_right=28
let g:neovide_padding_bottom=10

Which I think in Lua would be this:

vim.g.neovide_padding_top=35
vim.g.neovide_padding_left=28
vim.g.neovide_padding_right=28
vim.g.neovide_padding_bottom=10

Thanks.

@NEX-S
Copy link

NEX-S commented Dec 27, 2022

hi! it seems the padding color is related to HL normal, can we set it separately? especially when we are using tabline, it might need to relate the color to tabLine.

image

@seanstrom
Copy link
Contributor

Are you saying that the tabline is not padded? Or that the color of the padding is incorrect?

my assumption was that the padding was transparent, but maybe it uses the background color of the theme 🤔

@NEX-S
Copy link

NEX-S commented Dec 27, 2022

Are you saying that the tabline is not padded? Or that the color of the padding is incorrect?

no, padded works just perfect, but the color is same to Normal's bg

my assumption was that the padding was transparent, but maybe it uses the background color of the theme thinking
yes, it color is related to the colorscheme's normal I just wondering if we can set it to tabline's BG like this

image
image

@NEX-S
Copy link

NEX-S commented Dec 27, 2022

and setting the vim.g.neovide_padding_top = 5 will cause the neovide bottom position not correct on my arch-linux

set cmdline=0's case
image

we need to resize the neovide window to get bottom padding manually

image

@seanstrom
Copy link
Contributor

I’m trying to understand the screenshots related to the color. In your example are you saying the padding is colored black or gray?

For the second issue related to the bottom padding glitch, are you saying that happens when you set the cmdline=0 and the window needs to be resized manually before the padding is visible again?

And in general are you configuring the padding and cmdline settings dynamically by typing it in the command line or by setting the values in a config file?

@NEX-S
Copy link

NEX-S commented Dec 27, 2022

I’m trying to understand the screenshots related to the color. In your example are you saying the padding is colored black or gray?

I wish it was black(same as my tabline's bg), but it's gray(same as Normal's bg).

For the second issue related to the bottom padding glitch, are you saying that happens when you set the cmdline=0 and the window needs to be resized manually before the padding is visible again?

I only set the vim.g.neovide_padding_top = 5 but neovide bottom has extra space. we need to manually resize the window to reduce that extra space

And in general are you configuring the padding and cmdline settings dynamically by typing it in the command line or by setting the values in a config file?

it is in my config file

@seanstrom
Copy link
Contributor

Okay I’ll try understanding how the color is assigned for the padding and think about how to change that. Not sure how that works at the moment, so that might take a while before I come up with a solution. Hope that’s okay 🙏

About the extra spacing at the bottom, I’m not sure what that is, but it could be related to how Neovim is being resized into the window. It seems Neovide is allowing up to one block of padding to be appended at the bottom. The block of padding is sized from 0 to your font height. You can test this out by increasing the font in Neovide and noticing the extra padding correlates to the font size.

I think that extra padding issue is related to how Neovim is being sized and rendered inside the window. I’ll try taking a look but I’m not sure how to solve that either. I know it has something to do with character grids and stuff, and it seems we have extra space unused by the character grid.

@NEX-S
Copy link

NEX-S commented Dec 27, 2022

appreciate for that!

@NEX-S
Copy link

NEX-S commented Dec 27, 2022

btw, I don't know if this feature request is useful but might relate to neovide's ui setting. It would be very cool if the inner-padding could be combined with a transparent specific component, but now neovide only support transparent globally.

only padding and tabline get transparent
image

#1696

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants