Skip to content

Commit

Permalink
fix: triple single quote and count
Browse files Browse the repository at this point in the history
fix #479
  • Loading branch information
windwp committed Jan 8, 2025
1 parent ff39eca commit e979a8e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lua/nvim-autopairs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions lua/nvim-autopairs/rules/basic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion tests/nvim-autopairs_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({<esc>', 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)
Expand Down

0 comments on commit e979a8e

Please sign in to comment.