--[[ 50-autopairs.lua — autopairs rules for markdown. Pairs `*` and `~` so that `**bold**` and `~~strike~~` auto-close, via nvim-autopairs. ]] local Rule = require("nvim-autopairs.rule") local npairs = require("nvim-autopairs") local cond = require("nvim-autopairs.conds") npairs.setup() --[[ Auto-close `*` and `~` in markdown, but only when not already before the same char (so `**`/`~~` nest cleanly), and never expand them on ``. ]] npairs.add_rules({ Rule("*", "*", "markdown"):with_move(cond.not_before_regex("%*")):with_cr(cond.none()), Rule("~", "~", "markdown"):with_move(cond.not_before_regex("~")):with_cr(cond.none()), })