summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/core/autopairs.lua
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-11-08 23:13:05 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-11-08 23:13:05 +0100
commitc9e2adbbc8fd7a5398c8c66d21f0e02dc7b60203 (patch)
tree274263ba15e0197180af8bb681e22c4780d5de05 /.config/nvim/lua/core/autopairs.lua
parente4ea22e223bbd6b4091610c6fa093862cbd32f75 (diff)
Add new lunarvin updates
Diffstat (limited to '.config/nvim/lua/core/autopairs.lua')
-rw-r--r--.config/nvim/lua/core/autopairs.lua21
1 files changed, 6 insertions, 15 deletions
diff --git a/.config/nvim/lua/core/autopairs.lua b/.config/nvim/lua/core/autopairs.lua
index 630f3de..ec7f651 100644
--- a/.config/nvim/lua/core/autopairs.lua
+++ b/.config/nvim/lua/core/autopairs.lua
@@ -4,8 +4,6 @@ function M.config()
options.builtin.autopairs = {
active = true,
on_config_done = nil,
- ---@usage auto insert after select function or method item
- map_complete = true,
---@usage -- modifies the function or method delimiter by filetypes
map_char = {
all = "(",
@@ -52,19 +50,12 @@ M.setup = function()
end),
}
- if package.loaded["cmp"] then
- require("nvim-autopairs.completion.cmp").setup {
- map_cr = false,
- map_complete = options.builtin.autopairs.map_complete,
- map_char = options.builtin.autopairs.map_char,
- }
- -- we map CR explicitly in cmp.lua but we still need to setup the autopairs CR keymap
- vim.api.nvim_set_keymap(
- "i",
- "<CR>",
- "v:lua.MPairs.autopairs_cr()",
- { expr = true, noremap = true }
- )
+ local cmp_status_ok, cmp = pcall(require, "cmp")
+ if cmp_status_ok then
+ -- If you want insert `(` after select function or method item
+ local cmp_autopairs = require "nvim-autopairs.completion.cmp"
+ local map_char = options.builtin.autopairs.map_char
+ cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = map_char })
end
require("nvim-treesitter.configs").setup { autopairs = { enable = true } }