feat(mini.pairs): enable mini.pairs in the cmdline

This commit is contained in:
Folke Lemaitre
2024-06-16 10:33:20 +02:00
parent 71390adcbe
commit 2daca4b510
2 changed files with 4 additions and 0 deletions

View File

@ -142,6 +142,7 @@ return {
"echasnovski/mini.pairs",
event = "VeryLazy",
opts = {
modes = { insert = true, command = true, terminal = false },
-- skip autopair when next character is one of these
skip_next = [=[[%w%%%'%[%"%.%`%$]]=],
-- skip autopair when the cursor is inside these treesitter nodes

View File

@ -115,6 +115,9 @@ function M.pairs(opts)
pairs.setup(opts)
local open = pairs.open
pairs.open = function(pair, neigh_pattern)
if vim.fn.getcmdline() ~= "" then
return open(pair, neigh_pattern)
end
local o, c = pair:sub(1, 1), pair:sub(2, 2)
local line = vim.api.nvim_get_current_line()
local cursor = vim.api.nvim_win_get_cursor(0)