From 35d1f8b03d12735d591d24c19bc54f9c0f19bccf Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 20 Jun 2025 22:57:56 +0200 Subject: [PATCH] nvim: Improve mini.pairs triple mappings Whenever there is a left-over quote (') or double quote ("), if we want to 'close' it, mini.pairs will by default add a new pair (e.g. """) instead. This simply changes it to close the pair. Makes some 'double-quote' pairings harder (e.g. we have a python dict: {"name"}) and want to add another {"name""value"} into it, but this happens relatively rarely in my use cases. The first on the other hand happens frequently enough to be an annoyance. Additionally, did the same for back-ticks so we can more easily create triple backticks ``` which are essential in many literate programming markup languages (markdown, quarto, rmd and so on). --- nvim/.config/nvim/lua/plugins/base.lua | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/plugins/base.lua b/nvim/.config/nvim/lua/plugins/base.lua index e0fcfb1..0f8590e 100644 --- a/nvim/.config/nvim/lua/plugins/base.lua +++ b/nvim/.config/nvim/lua/plugins/base.lua @@ -250,7 +250,33 @@ return { require("mini.map").setup() require("mini.move").setup() require("mini.operators").setup() - require("mini.pairs").setup() + require("mini.pairs").setup({ + mappings = { + -- these mappings ensure that when trying to _close_ any of the pairs + -- it will not double insert: + -- " <- you are here. Normal pairs will do """. This config will do "". + ['"'] = { + action = "closeopen", + pair = '""', + neigh_pattern = '[^\\"].', + register = { cr = false }, + }, + ["'"] = { + action = "closeopen", + pair = "''", + neigh_pattern = "[^%a\\'].", + register = { cr = false }, + }, + ["`"] = { + action = "closeopen", + pair = "``", + neigh_pattern = "[^\\`].", + register = { cr = false }, + }, + ["<"] = { action = "open", pair = "<>", neigh_pattern = "\r." }, + [">"] = { action = "close", pair = "<>" }, + }, + }) require("mini.trailspace").setup() end, })