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

Lines in man pages break prematurely #311

Open
lingling9000 opened this issue Jun 8, 2024 · 3 comments
Open

Lines in man pages break prematurely #311

lingling9000 opened this issue Jun 8, 2024 · 3 comments

Comments

@lingling9000
Copy link

lingling9000 commented Jun 8, 2024

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):

  • kitty 0.35.1, but I could replicate the same behavior in other terminals, e. g. Alacritty.
  • NVIM v0.10.0

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"
}
@siduck siduck transferred this issue from NvChad/NvChad Jun 8, 2024
@lingling9000
Copy link
Author

lingling9000 commented Jun 9, 2024

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 (neovim/neovim#10748, neovim/neovim#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: neovim/neovim#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
Copy link
Member

siduck commented Jun 27, 2024

does this happen with other neovim configs?

@lingling9000
Copy link
Author

lingling9000 commented Jun 28, 2024

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:

  • :let g:man_hardwrap=1
  • :Man namespaces
  • Result:

lazy_vim_hardwrap_2

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

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

No branches or pull requests

2 participants