NvChad / base46

NvChad's base46 theme plugin with caching ( Total re-write )
Other
170 stars 185 forks source link

Lines in man pages break prematurely #311

Open lingling9000 opened 3 weeks ago

lingling9000 commented 3 weeks ago

Describe the bug Lines in man pages break prematurely. This reason seem to be the additional padding on the left.

This does not happen in Neovim without a config. So it need to come somewhere from NvChad, but I couldn't figure out, which option sets that additional padding.

To Reproduce Steps to reproduce the behavior:

  1. Install NvChad/starter
  2. export MANPAGER='nvim +Man!'
  3. man namespaces

This does also happen when open the man pages from inside Neovim with :Man namespaces or the respective Telescope picker.

Expected behavior Lines should not prematurely break in man pages. I can imagine two solutions:

  1. Disable the padding on the left when filetype man is detected. I don't know how, because I don't know how and where the padding is set.
  2. Enable soft_wrapping for man pages with vim.g.man_hardwrap=0. See :h man for details. This also enables the reformatting of the content when the window is resized. I recommend to set this option as default.

Screenshots man page with no config: nvim_manpage_noconfig

man page with unmodified NvChad starter config. I marked the first 4 bad linebreaks red, but when you look into the chapter The namespaces API you can see that nearly every line has a prematurely linebreak: nvim_manpage_nvchad

Desktop (please complete the following information):

Additional context It is important to note that there are differences in opening the man page by the man command or from inside Neovim. When using the man command on the shell the man page is pre-formatted with groff and the soft_wrapping setting is useless. :h man tells the workaround to export MANWIDTH=999, but this will result in a broken title bar and therefore I won't recommend that. A better solution is to redefine the man command in the shell (as recommended in :h man):

man() {
    nvim "+hide Man $1"
}
lingling9000 commented 3 weeks ago

I used soft wrap (vim.g.man_hardwrap = 0) and noticed a problem with the formatting of wide tables in e. g. systemd.unit(5):

softwrap_splitcreen

But is is not an unknown issue and they previously set hard wrap to be more fool prove (https://github.com/neovim/neovim/issues/10748, https://github.com/neovim/neovim/issues/11436). Nevertheless I opened an issue, because I would expect that Neovim would be able to create multi line cells in man pages, even when using soft wrap: https://github.com/neovim/neovim/issues/29249.

In view of the facts I need to withdraw my recommendation to set soft wrap as default, for now. Therefore I think the best solution for NvChad would be to disable the left padding when filetype man is detected.

Another solution, would be to use hard wrap and subtract the padding from the terminal columns and set this as MANWIDTH environment variable. When I understand it right, they've done something similar in the past:

siduck commented 1 week ago

does this happen with other neovim configs?

lingling9000 commented 1 week ago

I tested it with LazyVim.

Soft Wrap

They seem to default to soft wrap. When testing with systemd.unit(5) I can also see that broken tables. But as I pointed out in the previous comment, this is an upstream Neovim bug and not a problem with NvChad/base46.

Hard Wrap

I've done following steps to test hard wrap in LazyVim:

lazy_vim_hardwrap_2

They also have a padding on the right side and therefore break lines prematurely.