mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-10-26 08:41:46 +03:00
add option enable_check_bracket_line
This commit is contained in:
parent
b5816204bd
commit
d7f2976b55
@ -17,6 +17,7 @@ local default = {
|
||||
check_ts = false,
|
||||
enable_moveright = true,
|
||||
enable_afterquote = true,
|
||||
enable_check_bracket_line = true,
|
||||
ts_config = {
|
||||
lua = {'string', 'source'},
|
||||
javascript = {'string', 'template_string'}
|
||||
|
@ -55,6 +55,7 @@ end
|
||||
cond.not_after_regex_check = function(regex, length)
|
||||
length = length or 1
|
||||
return function(opts)
|
||||
if not regex then return end
|
||||
log.debug('not_after_regex_check')
|
||||
local str = utils.text_sub_char(opts.line, opts.col + 1, length)
|
||||
if str:match(regex) then
|
||||
|
@ -10,6 +10,17 @@ local function setup(opt)
|
||||
:with_pair(cond.not_after_regex_check(opt.ignored_next_char))
|
||||
:with_pair(cond.not_add_quote_inside_quote())
|
||||
end
|
||||
|
||||
local bracket = function(...)
|
||||
print(opt.enable_check_bracket_line)
|
||||
print(vim.inspect(opt))
|
||||
if opt.enable_check_bracket_line == true then
|
||||
return basic(...)
|
||||
:with_pair(cond.check_is_bracket_line())
|
||||
end
|
||||
return basic(...)
|
||||
end
|
||||
|
||||
local rules = {
|
||||
Rule("<!--", "-->", 'html'):with_cr(cond.none()),
|
||||
Rule("```", "```", { 'markdown', 'vimwiki' }),
|
||||
@ -22,12 +33,9 @@ local function setup(opt)
|
||||
:with_pair(cond.not_before_regex_check("%w")) ,
|
||||
basic("`", "`"),
|
||||
basic('"', '"'),
|
||||
basic("(", ")")
|
||||
:with_pair(cond.check_is_bracket_line()),
|
||||
basic("[", "]")
|
||||
:with_pair(cond.check_is_bracket_line()),
|
||||
basic("{", "}")
|
||||
:with_pair(cond.check_is_bracket_line()),
|
||||
bracket("(", ")"),
|
||||
bracket("[", "]"),
|
||||
bracket("{", "}"),
|
||||
Rule(">", "<",
|
||||
{ 'html', 'typescript', 'typescriptreact', 'svelte', 'vue', 'xml'})
|
||||
:only_cr()
|
||||
|
@ -373,5 +373,18 @@ describe('autopairs ', function()
|
||||
},
|
||||
}
|
||||
Test(run_data)
|
||||
npairs.setup({
|
||||
enable_check_bracket_line=false
|
||||
})
|
||||
|
||||
run_data = {
|
||||
{
|
||||
name = "test disable check bracket line" ,
|
||||
filetype = "latex",
|
||||
key = [[(]],
|
||||
before = [[(|))) ]],
|
||||
after = [[((|)))) ]],
|
||||
},
|
||||
}
|
||||
Test(run_data)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user