How to ignore auto pair when previous character is \, support for escaped character?
sokinpui opened this issue · comments
SoKinPui commented
I used to use this another vim auto pairs plugins, I find this plugins is more helpful so I switch until now. The only feature I miss is
-
Ignore auto pair when previous character is \
input: "\' output: "\'"
When I want to escaped single pairs, it will always insert auto pairs
"\|"
insert (
"\(|)"
Expected to be
"\|"
insert (
"\(|"
I have find partial solution from this issue
Then, I have try to add some lines to escape for other pairs, but fail, only the first three pairs works
-- disable in escaped chararcter
local nap = require('nvim-autopairs')
for _, char in ipairs {
"'",
'"',
'`',
'(',
')',
'[',
']',
'{',
'}',
'$',
'=',
} do
for _, r in ipairs(nap.get_rule(char)) do
r:with_move(cond.not_before_text('\\'))
:with_del(function(opts)
local prev_col = vim.api.nvim_win_get_cursor(0)[2] - 1
return opts.line:sub(prev_col, prev_col) ~= '\\'
end)
end
end
Is there a solution or existing setting can do so?
Sam commented
nap.add_rules({
Rule('\\'.. '\"', ''),
Rule('\\'.. '[', ''),
...
})
this works
stale commented
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.