on master help sign in
6 files changed+38−20
since splitsnapshots
unifiedsplit
README.md+6−1 lua/nvim-autopairs.lua+2−2 lua/nvim-autopairs/completion/cmp.lua+2−1 lua/nvim-autopairs/conds.lua+6−3 lua/nvim-autopairs/fastwrap.lua+4−12 tests/nvim-autopairs_spec.lua+18−1
README.md+6−1
@@ -34,7 +34,7 @@ local disable_filetype = { "TelescopePrompt" }
3434local disable_in_macro = false -- disable when recording or executing a macro
3535local disable_in_visualblock = false -- disable when insert after visual block mode
3636local disable_in_replace_mode = true
37−local ignored_next_char = [=[[%w%%%'%[%"%.]]=]
37+local ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=]
3838local enable_moveright = true
3939local enable_afterquote = true -- add bracket pairs after quote
4040local enable_check_bracket_line = true --- check bracket in same line
@@ -391,3 +391,8 @@ npairs.setup({
391391
392392### Custom rules
393393[rules](https://github.com/windwp/nvim-autopairs/wiki/Custom-rules)
394+
395+## Sponsors
396+
397+Thanks to everyone who sponsors my projects and makes continued development maintenance possible!
398+<!-- patreon --><a href="https://github.com/t4t5"><img src="https://github.com/t4t5.png" width="60px" alt="" /></a><!-- patreon-->
lua/nvim-autopairs.lua+2−2
@@ -20,7 +20,7 @@ local default = {
2020 disable_in_macro = false,
2121 disable_in_visualblock = false,
2222 disable_in_replace_mode = true,
23− ignored_next_char = [=[[%w%%%'%[%"%.]]=],
23+ ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=],
2424 break_undo = true,
2525 check_ts = false,
2626 enable_moveright = true,
@@ -302,7 +302,7 @@ M.on_attach = function(bufnr)
302302 bufnr,
303303 'i',
304304 '<bs>',
305− string.format('v:lua.MPairs.autopairs_bs(%d)', bufnr),
305+ 'v:lua.MPairs.autopairs_bs()',
306306 { expr = true, noremap = true }
307307 )
308308 end
lua/nvim-autopairs/completion/cmp.lua+2−1
@@ -38,7 +38,8 @@ M.filetypes = {
3838 handler = handlers.lisp
3939 }
4040 },
41− tex = false
41+ tex = false,
42+ haskell = false
4243}
4344
4445M.on_confirm_done = function(opts)
lua/nvim-autopairs/conds.lua+6−3
@@ -199,13 +199,16 @@ cond.is_bracket_line = function()
199199 ---@param opts CondOpts
200200 return function(opts)
201201 log.debug('is_bracket_line')
202− if utils.is_bracket(opts.char) and opts.next_char == opts.rule.end_pair then
202+ if utils.is_bracket(opts.char) and
203+ (opts.next_char == opts.rule.end_pair
204+ or opts.next_char == opts.rule.start_pair)
205+ then
203206 -- (( many char |)) => add
204207 -- ( many char |)) => not add
205208 local count_prev_char, count_next_char = count_bracket_char(
206209 opts.line,
207− opts.char,
208− opts.next_char
210+ opts.rule.start_pair,
211+ opts.rule.end_pair
209212 )
210213 if count_prev_char ~= count_next_char then
211214 return false
lua/nvim-autopairs/fastwrap.lua+4−12
@@ -56,7 +56,6 @@ M.show = function(line)
5656 local index = 1
5757 local str_length = #line
5858 local offset = -1
59− local is_end_key = true
6059 for i = col + 2, #line, 1 do
6160 local char = line:sub(i, i)
6261 local char2 = line:sub(i - 1, i)
@@ -74,11 +73,6 @@ M.show = function(line)
7473 offset = 0
7574 end
7675
77− if i == str_length then
78− is_end_key = false
79− key = config.end_key
80− offset = 0
81− end
8276 table.insert(
8377 list_pos,
8478 { col = i + offset, key = key, char = char, pos = i }
@@ -86,12 +80,10 @@ M.show = function(line)
8680 end
8781 end
8882
89− if is_end_key then
90− table.insert(
91− list_pos,
92− { col = str_length + 1, key = config.end_key, pos = str_length + 1 }
93− )
94− end
83+ table.insert(
84+ list_pos,
85+ { col = str_length + 1, key = config.end_key, pos = str_length + 1 }
86+ )
9587
9688 M.highlight_wrap(list_pos, row, col, #line)
9789 vim.defer_fn(function()
tests/nvim-autopairs_spec.lua+18−1
@@ -1,4 +1,3 @@
1−local helpers = {}
21local npairs = require('nvim-autopairs')
32local Rule = require('nvim-autopairs.rule')
43local cond = require('nvim-autopairs.conds')
@@ -689,6 +688,24 @@ local data = {
689688 [[}]],
690689 },
691690 },
691+ {
692+ name='open bracker on back tick',
693+ key = [[(]],
694+ before = [[ |`abcd`]],
695+ after = [[ (`abcd`) ]]
696+ },
697+ {
698+ name='should not add bracket on line have bracket ',
699+ key = [[(]],
700+ before = [[ |(abcd))]],
701+ after = [[ ((abcd)) ]]
702+ },
703+ {
704+ name='not add bracket on line have bracket ',
705+ key = [[(]],
706+ before = [[ |(abcd) ( visual)]],
707+ after = [[ ()(abcd) ( visual)]]
708+ }
692709}
693710
694711local run_data = _G.Test_filter(data)