feat(mini.pairs): smart Markdown code-fence expansion on 3rd backtick #5

Merged
rootiest merged 1 commits from feat/markdown-smart-backtick-fence into main 2026-08-25 02:03:15 +00:00
Owner

Summary

  • Typing a 3rd backtick in Markdown, right after mini.pairs' auto-paired (which normally pairs into 4 backticks), now expands into a fenced code block instead: `` on the current line with the cursor left right after the opener (so you can type a language id immediately), and a matching closing `` `` fence on the next line.
  • Pressing <CR> right after (with or without a language id typed) opens exactly one blank body line between the fences — no extra blank line is inserted up front.
  • Backspacing through the last backtick of a still-empty opening fence also removes the untouched closing fence, cleanly undoing the expansion. Once you've moved past it (e.g. typed a body via <CR>), backspacing the opener leaves the closing fence alone.
  • Handles indentation and inline list markers (e.g. - prefixes) correctly, and falls back to mini.pairs' normal pairing/backspace behavior in every other case.
  • Also bundles an already-in-progress .gitignore expansion and a lua/plugins.lua tabs→spaces reformat that were sitting uncommitted in the working tree, plus a README sync (feature bullet + corrected Lua line count).

Test plan

  • Open a .md file, type ``` — confirm cursor sits right after the opener with a closing fence on the next line
  • Type a language id (e.g. python) then <CR> — confirm exactly one blank body line opens, no stray blank line
  • Immediately backspace a freshly typed ``` back to nothing — confirm the closing fence disappears too
  • Create a fence, press <CR>, type body text, then backspace on the opening fence line — confirm the closing fence is NOT removed
  • Try inside an indented list item (- prefix) — confirm indentation on the closing fence and full undo via backspace both work
  • Confirm normal single/double backtick pairing (e.g. `code`) still behaves as before, in Markdown and other filetypes
## Summary - Typing a 3rd backtick in Markdown, right after mini.pairs' auto-paired `` `` `` (which normally pairs into 4 backticks), now expands into a fenced code block instead: `` ``` `` on the current line with the cursor left right after the opener (so you can type a language id immediately), and a matching closing `` ``` `` fence on the next line. - Pressing `<CR>` right after (with or without a language id typed) opens exactly one blank body line between the fences — no extra blank line is inserted up front. - Backspacing through the last backtick of a still-empty opening fence also removes the untouched closing fence, cleanly undoing the expansion. Once you've moved past it (e.g. typed a body via `<CR>`), backspacing the opener leaves the closing fence alone. - Handles indentation and inline list markers (e.g. `- ` prefixes) correctly, and falls back to mini.pairs' normal pairing/backspace behavior in every other case. - Also bundles an already-in-progress `.gitignore` expansion and a `lua/plugins.lua` tabs→spaces reformat that were sitting uncommitted in the working tree, plus a README sync (feature bullet + corrected Lua line count). ## Test plan - [x] Open a `.md` file, type `` ``` `` — confirm cursor sits right after the opener with a closing fence on the next line - [x] Type a language id (e.g. `python`) then `<CR>` — confirm exactly one blank body line opens, no stray blank line - [x] Immediately backspace a freshly typed `` ``` `` back to nothing — confirm the closing fence disappears too - [x] Create a fence, press `<CR>`, type body text, then backspace on the opening fence line — confirm the closing fence is NOT removed - [x] Try inside an indented list item (`- ` prefix) — confirm indentation on the closing fence and full undo via backspace both work - [x] Confirm normal single/double backtick pairing (e.g. `` `code` ``) still behaves as before, in Markdown and other filetypes
rootiest added 1 commit 2026-08-25 02:01:58 +00:00
Typing a 3rd backtick after mini.pairs' `` pair now expands into a fenced
code block instead of pairing into 4 backticks: the cursor lands right
after the opener (ready for a language id), and backspacing the fence
back out removes the empty closing fence too.

Also includes an already-in-progress .gitignore expansion (AGENTS/ and
agent-generated docs/ subdirs) and a plugins.lua tabs-to-spaces reformat
that were sitting uncommitted in the working tree.
rootiest force-pushed feat/markdown-smart-backtick-fence from 22858faac9 to fc535b6688 2026-08-25 02:01:58 +00:00 Compare
rootiest merged commit abda95b98f into main 2026-08-25 02:03:15 +00:00
rootiest deleted branch feat/markdown-smart-backtick-fence 2026-08-25 02:03:15 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rootiest/neovim-config#5