Lines in man pages break prematurely
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:
- Install NvChad/starter
export MANPAGER='nvim +Man!'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:
- Disable the padding on the left when filetype
manis detected. I don't know how, because I don't know how and where the padding is set. - Enable soft_wrapping for man pages with
vim.g.man_hardwrap=0. See:h manfor 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:
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:
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"
}
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):
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:
does this happen with other neovim configs?
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:
They also have a padding on the right side and therefore break lines prematurely.
Temporary fix: add this to your bashrc
# shrink Man page by size of padding
export MANWIDTH=$(( $(tput cols) - 2 ))
# resize the environent-variable when window is resized
trap 'export MANWIDTH=$(( $(tput cols) - 2 ))' WINCH
or set vim.opt.signcolumn = "no"
vim.api.nvim_create_autocmd("FileType", {
pattern = "man",
command = "setlocal signcolumn=no",
})