Skip to content

Commit e979a8e

Browse files
committed
fix: triple single quote and count
fix #479
1 parent ff39eca commit e979a8e

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

lua/nvim-autopairs.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ local function is_disable()
190190
return true
191191
end
192192

193+
if vim.v.count > 0 then
194+
return true
195+
end
196+
193197
if utils.check_filetype(M.config.disable_filetype, vim.bo.filetype) then
194198
del_keymaps()
195199
M.set_buf_rule({}, 0)

lua/nvim-autopairs/rules/basic.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ local function setup(opt)
4141
local bracket = bracket_creator(opt)
4242
local rules = {
4343
Rule("<!--", "-->", { "html", "markdown" }):with_cr(cond.none()),
44-
Rule("```", "```", { "markdown", "vimwiki", "rmarkdown", "rmd", "pandoc" }),
44+
Rule("```", "```", { "markdown", "vimwiki", "rmarkdown", "rmd", "pandoc" })
45+
:with_pair(cond.not_before_char('`', 3)),
4546
Rule("```.*$", "```", { "markdown", "vimwiki", "rmarkdown", "rmd", "pandoc" }):only_cr():use_regex(true),
46-
Rule('"""', '"""', { "python", "elixir", "julia", "kotlin", "scala", "sbt" }):with_pair(cond.not_before_char('"', 3)),
47-
Rule("'''", "'''", { "python" }):with_pair(cond.not_before_char('"', 3)),
47+
Rule('"""', '"""', { "python", "elixir", "julia", "kotlin", "scala","sbt" }):with_pair(cond.not_before_char('"', 3)),
48+
Rule("'''", "'''", { "python" }):with_pair(cond.not_before_char("'", 3)),
4849
quote("'", "'", { "-rust", "-nix" })
4950
:with_pair(function(opts)
5051
-- python literals string

tests/nvim-autopairs_spec.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,11 +820,25 @@ local data = {
820820
before = [[ some text before| ]],
821821
after = [[ some text before123456|789 ]],
822822
},
823+
{
824+
name = "88 disable on count mode",
825+
filetype = "txt",
826+
key = function()
827+
local keys = vim.api.nvim_replace_termcodes('2otest({<esc>', true, true, true)
828+
vim.api.nvim_feedkeys(keys, 'x', true)
829+
end,
830+
before = [[ | ]],
831+
after = {
832+
' ',
833+
'test({',
834+
'test({|',
835+
}
836+
},
823837
}
824838

825839
local run_data = _G.Test_filter(data)
826840

827-
describe('autopairs ', function()
841+
describe("autopairs ", function()
828842
_G.Test_withfile(run_data, {
829843
cursor_add = 0,
830844
before_each = function(value)

0 commit comments

Comments
 (0)