vim:ftplug:man: Enable resizing with hard-wrapping

From :h :Man:

> when running `man` from the shell and with that `MANPAGER` [='nvim
> +Man!'] in your environment, `man` will pre-format the manpage using
> `groff`. Thus, Nvim will inevitably display the manual page as it was
> passed to it from stdin. One of the caveats of this is that the width
> will _always_ be hard-wrapped

Since I actually don't like `g:man_hardwrap=0`/`MANPAGER=999` (e.g.
scrolling can be a mess with very long wrapped lines), add an
autocommand that is meant to reload the manpage through `:edit` after
every resize, so that its hard-wrapping adjusts to the new size.

This is slightly hacky, but does its job quite well.

Move the man.vim into after/ftplugin so that it overwrites the `set
wrap` of the global ftplugin, which I want turned off, since it messes
with the buffer shortly when resizing.
This commit is contained in:
2025-01-25 02:49:54 +01:00
parent 467df52c66
commit 78917a686e
Notes: Julian Prein 2025-07-04 14:15:09 +02:00
`MANPAGER=999` should have been `MANWIDTH=999`
2 changed files with 52 additions and 7 deletions

View File

@@ -1,7 +0,0 @@
setlocal nospell
" man(1) will assume it can use the full width of the terminal when
" hard-wrapping the lines. When signcolumn is enabled the width is one cell
" smaller and thus, lines that have a character in the last column will be
" wrapped by vim (i.e. almost all of them).
setlocal signcolumn=no