+local i, _ = string.find(vim.bo.filetype, "mail")
+if not i then
+ vim.opt_local.textwidth = 80
+end
+
vim.g.table_mode_corner = "|"
+
+-- {{{ support { and } motions across quoted text/blockquotes
+-- written by @seandewar on 2025-05-20 in #neovim:matrix.org
+local function make_jump_fn(backwards)
+ return function()
+ local skip_flags = "W" .. (backwards and "be" or "")
+ local jump_flags = "c" .. skip_flags
+ local at_end = false
+
+ for _ = 1, vim.v.count1 do
+ local lnum = vim.api.nvim_win_get_cursor(0)[1]
+ -- First, check whether the cursor is already between paragraphs (in an
+ -- empty line/block), and skip past it if we are
+ if vim.fn.search([[^$]], "ncW", lnum) ~= 0 then
+ at_end = vim.fn.search([[.]], skip_flags) == 0
+ elseif vim.fn.search([[^\%(>\s*\)\+\zs$]], "ncW", lnum) ~= 0 then
+ -- In-between paragraphs inside a (possibly nested) block.
+ local depth = select(2, vim.fn.getline(lnum):gsub(">", ""))
+ at_end = vim.fn.search(([[^\%%(\%%(>\s*\)\{%u}$\)\@!.*$]]):format(depth), skip_flags) == 0
+ end
+
+ -- Finally, jump past the next paragraph, or to the beginning/end of the
+ -- buffer if there's no more
+ if at_end or vim.fn.search([[^$\|^\%(>\s*\)\+\zs$]], jump_flags) == 0 then
+ vim.fn.cursor(backwards and 1 or "$", backwards and 1 or vim.v.maxcol)
+ return
+ end
+ end
+ end
+end
+
+vim.keymap.set({ "n", "v" }, "}", make_jump_fn(false), { buffer = true })
+vim.keymap.set({ "n", "v" }, "{", make_jump_fn(true), { buffer = true })
+
+-- }}}