]> git.madduck.net Git - etc/lazyvim.git/blob - .config/lazyvim/after/ftplugin/markdown.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

profile cleanup
[etc/lazyvim.git] / .config / lazyvim / after / ftplugin / markdown.lua
1 local i, _ = string.find(vim.bo.filetype, "mail")
2 if not i then
3   vim.opt_local.textwidth = 80
4 end
5
6 vim.g.table_mode_corner = "|"
7
8 -- {{{ support { and } motions across quoted text/blockquotes
9 -- written by @seandewar on 2025-05-20 in #neovim:matrix.org
10 local function make_jump_fn(backwards)
11   return function()
12     local skip_flags = "W" .. (backwards and "be" or "")
13     local jump_flags = "c" .. skip_flags
14     local at_end = false
15
16     for _ = 1, vim.v.count1 do
17       local lnum = vim.api.nvim_win_get_cursor(0)[1]
18       -- First, check whether the cursor is already between paragraphs (in an
19       -- empty line/block), and skip past it if we are
20       if vim.fn.search([[^$]], "ncW", lnum) ~= 0 then
21         at_end = vim.fn.search([[.]], skip_flags) == 0
22       elseif vim.fn.search([[^\%(>\s*\)\+\zs$]], "ncW", lnum) ~= 0 then
23         -- In-between paragraphs inside a (possibly nested) block.
24         local depth = select(2, vim.fn.getline(lnum):gsub(">", ""))
25         at_end = vim.fn.search(([[^\%%(\%%(>\s*\)\{%u}$\)\@!.*$]]):format(depth), skip_flags) == 0
26       end
27
28       -- Finally, jump past the next paragraph, or to the beginning/end of the
29       -- buffer if there's no more
30       if at_end or vim.fn.search([[^$\|^\%(>\s*\)\+\zs$]], jump_flags) == 0 then
31         vim.fn.cursor(backwards and 1 or "$", backwards and 1 or vim.v.maxcol)
32         return
33       end
34     end
35   end
36 end
37
38 vim.keymap.set({ "n", "v" }, "}", make_jump_fn(false), { buffer = true })
39 vim.keymap.set({ "n", "v" }, "{", make_jump_fn(true), { buffer = true })
40
41 -- }}}