summaryrefslogtreecommitdiff
path: root/nvim/lua/config/man.lua
diff options
context:
space:
mode:
Diffstat (limited to 'nvim/lua/config/man.lua')
-rw-r--r--nvim/lua/config/man.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/nvim/lua/config/man.lua b/nvim/lua/config/man.lua
new file mode 100644
index 0000000..0c0357c
--- /dev/null
+++ b/nvim/lua/config/man.lua
@@ -0,0 +1,24 @@
+vim.api.nvim_create_autocmd({ "FileType", "VimResized" }, {
+ pattern = "man",
+ callback = function()
+ -- Read MANWIDTH from environment or fallback to 80 if not set
+ local manwidth_env = os.getenv("MANWIDTH")
+ local target_width = tonumber(manwidth_env) or 80
+
+ -- Calculate padding to center the text
+ local win_width = vim.api.nvim_win_get_width(0)
+ local padding = math.max(0, math.floor((win_width - target_width) / 2))
+ local nu_offset = vim.wo.numberwidth or 0
+ local final_padding = math.max(0, padding - nu_offset)
+
+ vim.opt_local.statuscolumn = string.rep(" ", final_padding) .. "%=%{v:lnum} "
+
+ -- disable wrapping only for centered view
+ if final_padding > 0 then
+ vim.opt_local.wrap = false
+ else
+ vim.opt_local.wrap = true
+ end
+ end,
+})
+