on master help sign in
fix: python multiple quote
commitbd1bcb4dde625f3ece5c3325bc294e9961ce5ec5 authorzztrieuzz <trieu19@gmail.com> dateMon 15 Aug 2022, 08:59 (4 years ago) parent6ba1868
2 files changed+17−5
lua/nvim-autopairs/rules/basic.lua+10−5 tests/nvim-autopairs_spec.lua+7
lua/nvim-autopairs/rules/basic.lua+10−5
@@ -36,25 +36,30 @@ local function setup(opt)
3636 Rule("```.*$", "```", { 'markdown', 'vimwiki', 'rmarkdown', 'rmd', 'pandoc' })
3737 :only_cr()
3838 :use_regex(true),
39− Rule('"""', '"""', { 'python', 'elixir', 'julia', 'kotlin' }),
40− Rule("'''", "'''", { 'python' }),
39+ Rule('"""', '"""', { 'python', 'elixir', 'julia', 'kotlin' })
40+ :with_pair(cond.not_before_char('"', 3)),
41+ Rule("'''", "'''", { 'python' })
42+ :with_pair(cond.not_before_char('"', 3)),
4143 basic("'", "'", '-rust')
4244 :with_pair(cond.not_before_regex("%w")),
4345 basic("'", "'", 'rust')
4446 :with_pair(cond.not_before_regex("[%w<&]"))
4547 :with_pair(cond.not_after_text(">")),
4648 basic("`", "`"),
47− basic('"', '"','-vim'),
48− basic('"', '"','vim')
49+ basic('"', '"', '-vim'),
50+ basic('"', '"', 'vim')
4951 :with_pair(cond.not_before_regex("^%s*$", -1)),
5052 bracket("(", ")"),
5153 bracket("[", "]"),
5254 bracket("{", "}"),
5355 Rule(">[%w%s]*$", "^%s*</",
54− { 'html', 'typescript', 'typescriptreact', 'javascript' , 'javascriptreact', 'svelte', 'vue', 'xml', 'rescript'})
56+ { 'html', 'typescript', 'typescriptreact', 'javascript', 'javascriptreact', 'svelte', 'vue', 'xml',
57+ 'rescript' })
5558 :only_cr()
5659 :use_regex(true)
5760 }
5861 return rules
5962end
63+
6064return { setup = setup }
65+
tests/nvim-autopairs_spec.lua+7
@@ -50,6 +50,13 @@ local data = {
5050 before = [[""| ]],
5151 after = [["""|""" ]]
5252 },
53+ {
54+ name = "don't repeat python quote" ,
55+ filetype = "python",
56+ key = [["]],
57+ before = [[a"""|""" ]],
58+ after = [[a""""|"" ]]
59+ },
5360
5461 {
5562 name = "add markdown quote" ,