mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-08-15 10:10:35 +03:00
Feat: Add the option mapping <C-h> to deleting a pair
This commit is contained in:
parent
04cd1779f8
commit
4406e94ba6
@ -21,6 +21,7 @@ local enable_afterquote = true -- add bracket pairs after quote
|
||||
local enable_check_bracket_line = true --- check bracket in same line
|
||||
local check_ts = false
|
||||
local map_bs = true -- map the <BS> key
|
||||
local map_c_h = false -- Map the <C-h> key to delete a pair
|
||||
local map_c_w = false -- map <c-w> to delete a pair if possible
|
||||
|
||||
```
|
||||
|
@ -13,6 +13,7 @@ M.state = {
|
||||
|
||||
local default = {
|
||||
map_bs = true,
|
||||
map_c_h = false,
|
||||
map_c_w = false,
|
||||
map_cr = true,
|
||||
disable_filetype = { 'TelescopePrompt', 'spectre_panel' },
|
||||
@ -317,6 +318,17 @@ M.on_attach = function(bufnr)
|
||||
{ expr = true, noremap = true }
|
||||
)
|
||||
end
|
||||
|
||||
if M.config.map_c_h then
|
||||
api.nvim_buf_set_keymap(
|
||||
bufnr,
|
||||
"i",
|
||||
utils.key.c_h,
|
||||
string.format("v:lua.MPairs.autopairs_c_h(%d)", bufnr),
|
||||
{expr = true, noremap = true}
|
||||
)
|
||||
end
|
||||
|
||||
if M.config.map_c_w then
|
||||
api.nvim_buf_set_keymap(
|
||||
bufnr,
|
||||
@ -374,6 +386,10 @@ M.autopairs_c_w = function(bufnr)
|
||||
return autopairs_delete(bufnr, '<c-g>U<c-w>')
|
||||
end
|
||||
|
||||
M.autopairs_c_h = function(bufnr)
|
||||
return autopairs_delete(bufnr, utils.key.c_h)
|
||||
end
|
||||
|
||||
M.autopairs_bs = function(bufnr)
|
||||
return autopairs_delete(bufnr, utils.key.bs)
|
||||
end
|
||||
|
@ -5,6 +5,7 @@ local log = require('nvim-autopairs._log')
|
||||
M.key = {
|
||||
del = "<del>",
|
||||
bs = "<bs>",
|
||||
c_h = "<C-h>",
|
||||
left = "<left>",
|
||||
right = "<right>",
|
||||
join_left = "<c-g>U<left>",
|
||||
|
@ -514,6 +514,15 @@ local data = {
|
||||
after = [[{{("It doesn't name %s", ''), 'ErrorMsg''|' }}, ]],
|
||||
end_cursor = 41
|
||||
},
|
||||
{
|
||||
setup_func = function()
|
||||
npairs.setup({map_c_h = true})
|
||||
end,
|
||||
name = "map <c-h>",
|
||||
key = "<c-h>",
|
||||
before = [[aa'|' ]],
|
||||
after = [[aa| ]],
|
||||
},
|
||||
{
|
||||
setup_func = function()
|
||||
npairs.setup({
|
||||
|
Loading…
Reference in New Issue
Block a user