diff --git a/lua/nvim-autopairs.lua b/lua/nvim-autopairs.lua index dd76cf40..74700616 100644 --- a/lua/nvim-autopairs.lua +++ b/lua/nvim-autopairs.lua @@ -190,6 +190,10 @@ local function is_disable() return true end + if vim.v.count > 0 then + return true + end + if utils.check_filetype(M.config.disable_filetype, vim.bo.filetype) then del_keymaps() M.set_buf_rule({}, 0) diff --git a/lua/nvim-autopairs/rules/basic.lua b/lua/nvim-autopairs/rules/basic.lua index 51fc48e4..91b4c43a 100644 --- a/lua/nvim-autopairs/rules/basic.lua +++ b/lua/nvim-autopairs/rules/basic.lua @@ -41,10 +41,11 @@ local function setup(opt) local bracket = bracket_creator(opt) local rules = { Rule("", { "html", "markdown" }):with_cr(cond.none()), - Rule("```", "```", { "markdown", "vimwiki", "rmarkdown", "rmd", "pandoc" }), + Rule("```", "```", { "markdown", "vimwiki", "rmarkdown", "rmd", "pandoc" }) + :with_pair(cond.not_before_char('`', 3)), Rule("```.*$", "```", { "markdown", "vimwiki", "rmarkdown", "rmd", "pandoc" }):only_cr():use_regex(true), - Rule('"""', '"""', { "python", "elixir", "julia", "kotlin", "scala", "sbt" }):with_pair(cond.not_before_char('"', 3)), - Rule("'''", "'''", { "python" }):with_pair(cond.not_before_char('"', 3)), + Rule('"""', '"""', { "python", "elixir", "julia", "kotlin", "scala","sbt" }):with_pair(cond.not_before_char('"', 3)), + Rule("'''", "'''", { "python" }):with_pair(cond.not_before_char("'", 3)), quote("'", "'", { "-rust", "-nix" }) :with_pair(function(opts) -- python literals string diff --git a/tests/nvim-autopairs_spec.lua b/tests/nvim-autopairs_spec.lua index ff25a1d3..52254e5b 100644 --- a/tests/nvim-autopairs_spec.lua +++ b/tests/nvim-autopairs_spec.lua @@ -820,11 +820,25 @@ local data = { before = [[ some text before| ]], after = [[ some text before123456|789 ]], }, + { + name = "88 disable on count mode", + filetype = "txt", + key = function() + local keys = vim.api.nvim_replace_termcodes('2otest({', true, true, true) + vim.api.nvim_feedkeys(keys, 'x', true) + end, + before = [[ | ]], + after = { + ' ', + 'test({', + 'test({|', + } + }, } local run_data = _G.Test_filter(data) -describe('autopairs ', function() +describe("autopairs ", function() _G.Test_withfile(run_data, { cursor_add = 0, before_each = function(value)