mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-09-11 07:15:44 +03:00
fix: pairs on after quote
This commit is contained in:
parent
150697f4a5
commit
d616b72b05
@ -14,11 +14,11 @@ require('nvim-autopairs').setup()
|
||||
## Default values
|
||||
|
||||
``` lua
|
||||
|
||||
local disable_filetype = { "TelescopePrompt" }
|
||||
local ignored_next_char = string.gsub([[ [%w%%%'%[%"%.] ]],"%s+", "")
|
||||
local enable_moveright = true
|
||||
local check_ts = false,
|
||||
local enable_afterquote = true -- add bracket pairs after quote
|
||||
local check_ts = false
|
||||
|
||||
```
|
||||
|
||||
|
@ -400,7 +400,7 @@ M.autopairs_cr = function(bufnr)
|
||||
return utils.esc('<cr>')
|
||||
end
|
||||
|
||||
--- map to auto add pairs on close quote (|"aaaaa" => (|"aaaaaa")
|
||||
--- add bracket pairs after quote (|"aaaaa" => (|"aaaaaa")
|
||||
M.autopairs_afterquote = function(line, key_char)
|
||||
if M.config.enable_afterquote then
|
||||
line = line or utils.text_get_current_line(0)
|
||||
@ -417,7 +417,7 @@ M.autopairs_afterquote = function(line, key_char)
|
||||
local new_text = line:sub(0, i) .. rule.end_pair .. line:sub(i + 1,#line)
|
||||
M.state.expr_quote = new_text
|
||||
local append = "a";
|
||||
if col > 2 then append = "la" end
|
||||
if col > 0 then append = "la" end
|
||||
return utils.esc('<esc><cmd>lua MPairs.autopairs_closequote_expr()<cr>' .. append)
|
||||
end
|
||||
end
|
||||
|
@ -2,6 +2,9 @@ local npairs = require('nvim-autopairs')
|
||||
|
||||
_G.npairs = npairs
|
||||
|
||||
npairs.setup({
|
||||
enable_afterquote = true,
|
||||
})
|
||||
local data = {
|
||||
{
|
||||
name = 'add bracket after quote ',
|
||||
@ -9,8 +12,8 @@ local data = {
|
||||
filetype = 'lua',
|
||||
linenr = 5,
|
||||
key = [[(]],
|
||||
before = [[const abc=|"visudsa" ]],
|
||||
after = [[const abc=(|"visudsa") ]],
|
||||
before = [[const abc=|"test" ]],
|
||||
after = [[const abc=(|"test") ]],
|
||||
},
|
||||
{
|
||||
name = 'add bracket after quote ',
|
||||
@ -18,10 +21,19 @@ local data = {
|
||||
filetype = 'lua',
|
||||
linenr = 5,
|
||||
key = [[(]],
|
||||
before = [[|"visudsa" ]],
|
||||
after = [[(|"visudsa") ]],
|
||||
before = [[|"test" ]],
|
||||
after = [[(|"test") ]],
|
||||
},
|
||||
|
||||
{
|
||||
name = 'add bracket after quote ',
|
||||
filepath = './tests/endwise/init.lua',
|
||||
filetype = 'lua',
|
||||
linenr = 5,
|
||||
key = [[{]],
|
||||
before = [[(|"test") ]],
|
||||
after = [[({|"test"}) ]],
|
||||
},
|
||||
{
|
||||
name = 'add bracket after quote ',
|
||||
filepath = './tests/endwise/init.lua',
|
||||
|
Loading…
Reference in New Issue
Block a user