mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-09-11 07:15:44 +03:00
make default map_cr
This commit is contained in:
parent
f0c10f5265
commit
fd272b64c7
18
README.md
18
README.md
@ -111,22 +111,8 @@ remap('i', '<bs>', 'v:lua.MUtils.BS()', { expr = true, noremap = true })
|
||||
<summary><b>without completion plugin</b></summary>
|
||||
|
||||
```lua
|
||||
local remap = vim.api.nvim_set_keymap
|
||||
local npairs = require('nvim-autopairs')
|
||||
|
||||
-- skip it, if you use another global object
|
||||
_G.MUtils= {}
|
||||
|
||||
MUtils.completion_confirm=function()
|
||||
if vim.fn.pumvisible() ~= 0 then
|
||||
return npairs.esc("<cr>")
|
||||
else
|
||||
return npairs.autopairs_cr()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
remap('i' , '<CR>','v:lua.MUtils.completion_confirm()', {expr = true , noremap = true})
|
||||
-- add option map_cr
|
||||
npairs.setup({ map_cr = true })
|
||||
```
|
||||
</details>
|
||||
|
||||
|
@ -14,6 +14,7 @@ M.state = {
|
||||
local default = {
|
||||
map_bs = true,
|
||||
map_c_w = false,
|
||||
map_cr = false,
|
||||
disable_filetype = { 'TelescopePrompt', 'spectre_panel' },
|
||||
disable_in_macro = false,
|
||||
ignored_next_char = string.gsub([[ [%w%%%'%[%"%.] ]], '%s+', ''),
|
||||
@ -42,6 +43,10 @@ M.setup = function(opt)
|
||||
end
|
||||
end
|
||||
|
||||
if M.config.map_cr then
|
||||
M.map_cr()
|
||||
end
|
||||
|
||||
M.force_attach()
|
||||
|
||||
api.nvim_exec(
|
||||
@ -617,6 +622,22 @@ M.check_break_line_char = function()
|
||||
return M.autopairs_cr()
|
||||
end
|
||||
|
||||
M.map_cr = function()
|
||||
M.completion_confirm = function()
|
||||
if vim.fn.pumvisible() ~= 0 then
|
||||
return M.esc("<cr>")
|
||||
else
|
||||
return M.autopairs_cr()
|
||||
end
|
||||
end
|
||||
vim.api.nvim_set_keymap(
|
||||
'i',
|
||||
'<CR>',
|
||||
'v:lua.MPairs.completion_confirm()',
|
||||
{ expr = true, noremap = true }
|
||||
)
|
||||
end
|
||||
|
||||
M.esc = utils.esc
|
||||
_G.MPairs = M
|
||||
return M
|
||||
|
Loading…
Reference in New Issue
Block a user