Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add 'map_custom_bs' option #431

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -56,6 +56,7 @@ local map_cr = true
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
local map_custom_bs = false, -- custom bs key

```

Expand Down
1 change: 1 addition & 0 deletions doc/nvim-autopairs.txt
Expand Up @@ -58,6 +58,7 @@ DEFAULT VALUES *nvim-autopairs-default-values*
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
local map_custom_bs = false, -- custom bs key
<


Expand Down
12 changes: 12 additions & 0 deletions lua/nvim-autopairs.lua
Expand Up @@ -15,6 +15,7 @@ local default = {
map_bs = true,
map_c_h = false,
map_c_w = false,
map_custom_bs = false,
map_cr = true,
disable_filetype = { 'TelescopePrompt', 'spectre_panel' },
disable_in_macro = true,
Expand Down Expand Up @@ -335,6 +336,17 @@ M.on_attach = function(bufnr)
{ callback = M.autopairs_c_w, expr = true, noremap = true }
)
end

if M.config.map_custom_bs then
api.nvim_buf_set_keymap(
bufnr,
'i',
M.config.map_custom_bs,
'',
{ callback = M.autopairs_bs, expr = true, noremap = true }
)
end

api.nvim_buf_set_var(bufnr, 'nvim-autopairs', 1)
end

Expand Down