mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-09-11 07:15:44 +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,
|
check_ts = false,
|
||||||
enable_moveright = true,
|
enable_moveright = true,
|
||||||
enable_afterquote = true,
|
enable_afterquote = true,
|
||||||
|
enable_check_bracket_line = true,
|
||||||
ts_config = {
|
ts_config = {
|
||||||
lua = {'string', 'source'},
|
lua = {'string', 'source'},
|
||||||
javascript = {'string', 'template_string'}
|
javascript = {'string', 'template_string'}
|
||||||
|
@ -55,6 +55,7 @@ end
|
|||||||
cond.not_after_regex_check = function(regex, length)
|
cond.not_after_regex_check = function(regex, length)
|
||||||
length = length or 1
|
length = length or 1
|
||||||
return function(opts)
|
return function(opts)
|
||||||
|
if not regex then return end
|
||||||
log.debug('not_after_regex_check')
|
log.debug('not_after_regex_check')
|
||||||
local str = utils.text_sub_char(opts.line, opts.col + 1, length)
|
local str = utils.text_sub_char(opts.line, opts.col + 1, length)
|
||||||
if str:match(regex) then
|
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_after_regex_check(opt.ignored_next_char))
|
||||||
:with_pair(cond.not_add_quote_inside_quote())
|
:with_pair(cond.not_add_quote_inside_quote())
|
||||||
end
|
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 = {
|
local rules = {
|
||||||
Rule("<!--", "-->", 'html'):with_cr(cond.none()),
|
Rule("<!--", "-->", 'html'):with_cr(cond.none()),
|
||||||
Rule("```", "```", { 'markdown', 'vimwiki' }),
|
Rule("```", "```", { 'markdown', 'vimwiki' }),
|
||||||
@ -22,12 +33,9 @@ local function setup(opt)
|
|||||||
:with_pair(cond.not_before_regex_check("%w")) ,
|
:with_pair(cond.not_before_regex_check("%w")) ,
|
||||||
basic("`", "`"),
|
basic("`", "`"),
|
||||||
basic('"', '"'),
|
basic('"', '"'),
|
||||||
basic("(", ")")
|
bracket("(", ")"),
|
||||||
:with_pair(cond.check_is_bracket_line()),
|
bracket("[", "]"),
|
||||||
basic("[", "]")
|
bracket("{", "}"),
|
||||||
:with_pair(cond.check_is_bracket_line()),
|
|
||||||
basic("{", "}")
|
|
||||||
:with_pair(cond.check_is_bracket_line()),
|
|
||||||
Rule(">", "<",
|
Rule(">", "<",
|
||||||
{ 'html', 'typescript', 'typescriptreact', 'svelte', 'vue', 'xml'})
|
{ 'html', 'typescript', 'typescriptreact', 'svelte', 'vue', 'xml'})
|
||||||
:only_cr()
|
:only_cr()
|
||||||
|
@ -373,5 +373,18 @@ describe('autopairs ', function()
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
Test(run_data)
|
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)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user