diff options
| -rw-r--r-- | nvim/init.lua | 1 | ||||
| -rw-r--r-- | nvim/lua/config/man.lua | 24 | ||||
| -rw-r--r-- | zsh/index.zsh | 2 |
3 files changed, 27 insertions, 0 deletions
diff --git a/nvim/init.lua b/nvim/init.lua index aabd42b..07c7054 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -2,6 +2,7 @@ require("config.lazy") require("config.lsp") require("config.trailing-spaces") require("config.keymaps") +require("config.man") vim.o.background = "dark" vim.o.tabstop = 4 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, +}) + diff --git a/zsh/index.zsh b/zsh/index.zsh index 0463c7e..adad395 100644 --- a/zsh/index.zsh +++ b/zsh/index.zsh @@ -29,3 +29,5 @@ source <(fzf --zsh) export EDITOR=nvim export MANPAGER='nvim +Man!' +export MANWIDTH=80 +export MAN_KEEP_FORMATTING='yes-please' |
