dotfiles

Personal dotfiles
git clone https://git.bracken.jp/dotfiles.git
Log | Files | Refs | LICENSE

commit 57da5c24f1377f569d0ff4859afb85ba84086624
parent 9f76bdb411a561abf59057cac3139e1e454ba44a
Author: Chris Bracken <chris@bracken.jp>
Date:   Fri,  5 Jun 2026 22:30:36 +0900

nvim: Revert back to hard-wrapping markdown at 80 cols

Turns out soft-wrap is still garbage, and complicated garbage at that.

Diffstat:
M.config/nvim/after/ftplugin/markdown.lua | 29+++++------------------------
M.config/nvim/lua/custom/utils.lua | 33---------------------------------
2 files changed, 5 insertions(+), 57 deletions(-)

diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua @@ -1,36 +1,17 @@ -local utils = require("custom.utils") - --- Hide colorcolumn. -vim.opt_local.colorcolumn = "" - -- Set tabs and indents. vim.opt_local.tabstop = 2 vim.opt_local.shiftwidth = 2 vim.opt_local.softtabstop = 2 vim.opt_local.expandtab = true --- Enable soft wrapping. Disable hard wrapping. -vim.opt_local.wrap = true -vim.opt_local.textwidth = 0 -vim.opt_local.wrapmargin = 0 - --- Wrap lines at word boundaries. -vim.opt_local.linebreak = true +-- Hard wrap at 100 columns. +vim.opt_local.textwidth = 80 +vim.opt_local.colorcolumn = "80" --- Indent wrapped lines to match the start of the line; indent list item bodies. -vim.opt_local.breakindent = true -vim.opt_local.breakindentopt = "list:2" - --- Prevent Neovim from auto-wrapping text as you type. -vim.opt_local.formatoptions:remove("t") - --- Since we're not hard-wrapping; remap common nav keys to move across physical --- lines instead of logical lines. +-- Since some people fail to hard-wrap, remap common nav keys to move across +-- physical lines instead of logical lines. vim.keymap.set({ 'n', 'v' }, 'j', 'gj', { buffer = true, silent = true }) vim.keymap.set({ 'n', 'v' }, 'k', 'gk', { buffer = true, silent = true }) vim.keymap.set({ 'n', 'v' }, '0', 'g0', { buffer = true, silent = true }) vim.keymap.set({ 'n', 'v' }, '^', 'g^', { buffer = true, silent = true }) vim.keymap.set({ 'n', 'v' }, '$', 'g$', { buffer = true, silent = true }) - --- Set the buffer width to 80 chars. -utils.set_buffer_wrapwidth(80) diff --git a/.config/nvim/lua/custom/utils.lua b/.config/nvim/lua/custom/utils.lua @@ -55,37 +55,4 @@ function M.jump_daily(offset) vim.cmd("edit " .. vim.fn.fnameescape(path)) end -function M.set_buffer_wrapwidth(target_width) - local current_win = vim.api.nvim_get_current_win() - local width = vim.api.nvim_win_get_width(current_win) - - -- Only split if your window is wider than target_width + 5 - local threshold = target_width + 5 - if width > threshold then - -- Create a vertical split on the right - vim.cmd("rightbelow vsplit") - local pad_win = vim.api.nvim_get_current_win() - - -- Create a clean scratch buffer for the padding window - local pad_buf = vim.api.nvim_create_buf(false, true) - vim.api.nvim_win_set_buf(pad_win, pad_buf) - - -- Hide line numbers, signs, and statuslines in the padding window - vim.wo[pad_win].number = false - vim.wo[pad_win].relativenumber = false - vim.wo[pad_win].signcolumn = "no" - vim.wo[pad_win].foldcolumn = "0" - vim.wo[pad_win].statuscolumn = "" - vim.bo[pad_buf].buftype = "nofile" - vim.bo[pad_buf].bufhidden = "wipe" - - -- Move cursor back to the markdown window - vim.api.nvim_set_current_win(current_win) - - -- Set markdown window width to target_width and lock it - vim.api.nvim_win_set_width(current_win, target_width) - vim.wo[current_win].winfixwidth = true - end -end - return M