mirror of
https://github.com/neovim/neovim.git
synced 2025-10-22 17:11:49 +00:00
Don't set manwidth wider than the window (#34078)
fix: set manwidth to not exceed the window width If we set the MANWIDTH variable to a value wider than the window, the contents wrap and formatting breaks. A more sensible way to handle this is to interpret MANWIDTH as a maximum width, but to set the width to the window size if smaller. See also: #9023, #10748.
This commit is contained in:

committed by
GitHub

parent
dfad613813
commit
2045e9700c
@@ -823,8 +823,8 @@ Variables:
|
|||||||
For example in C one usually wants section 3 or 2: >
|
For example in C one usually wants section 3 or 2: >
|
||||||
:let b:man_default_sections = '3,2'
|
:let b:man_default_sections = '3,2'
|
||||||
*g:man_hardwrap* Hard-wrap to $MANWIDTH or window width if $MANWIDTH is
|
*g:man_hardwrap* Hard-wrap to $MANWIDTH or window width if $MANWIDTH is
|
||||||
empty. Enabled by default. Set |FALSE| to enable soft
|
empty or larger than the window width. Enabled by
|
||||||
wrapping.
|
default. Set |FALSE| to enable soft wrapping.
|
||||||
|
|
||||||
To use Nvim as a manpager: >bash
|
To use Nvim as a manpager: >bash
|
||||||
export MANPAGER='nvim +Man!'
|
export MANPAGER='nvim +Man!'
|
||||||
|
@@ -415,11 +415,12 @@ local function get_page(path, silent)
|
|||||||
-- Disable hard-wrap by using a big $MANWIDTH (max 1000 on some systems #9065).
|
-- Disable hard-wrap by using a big $MANWIDTH (max 1000 on some systems #9065).
|
||||||
-- Soft-wrap: ftplugin/man.lua sets wrap/breakindent/….
|
-- Soft-wrap: ftplugin/man.lua sets wrap/breakindent/….
|
||||||
-- Hard-wrap: driven by `man`.
|
-- Hard-wrap: driven by `man`.
|
||||||
local manwidth --- @type integer|string
|
local manwidth --- @type integer
|
||||||
if (vim.g.man_hardwrap or 1) ~= 1 then
|
if (vim.g.man_hardwrap or 1) ~= 1 then
|
||||||
manwidth = 999
|
manwidth = 999
|
||||||
elseif vim.env.MANWIDTH then
|
elseif vim.env.MANWIDTH then
|
||||||
manwidth = vim.env.MANWIDTH --- @type string|integer
|
vim.env.MANWIDTH = tonumber(vim.env.MANWIDTH) or 0
|
||||||
|
manwidth = math.min(vim.env.MANWIDTH, api.nvim_win_get_width(0) - vim.o.wrapmargin)
|
||||||
else
|
else
|
||||||
manwidth = api.nvim_win_get_width(0) - vim.o.wrapmargin
|
manwidth = api.nvim_win_get_width(0) - vim.o.wrapmargin
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user