summaryrefslogtreecommitdiff
path: root/lua/lvim/core/autopairs.lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-10-29 19:33:00 +0200
committerkylo252 <[email protected]>2021-10-30 14:39:00 +0200
commit377cab434c79aa537820ba21bbcc44261304ed09 (patch)
tree4361d6101ec999ba74ae1cc1c8d00aa9366d3752 /lua/lvim/core/autopairs.lua
parentffd1d5e16522f7c03603c183eec237d529dbe1e3 (diff)
feat: update now syncs the core plugins (#1865)
Diffstat (limited to 'lua/lvim/core/autopairs.lua')
-rw-r--r--lua/lvim/core/autopairs.lua16
1 files changed, 6 insertions, 10 deletions
diff --git a/lua/lvim/core/autopairs.lua b/lua/lvim/core/autopairs.lua
index eb080fb1..51649790 100644
--- a/lua/lvim/core/autopairs.lua
+++ b/lua/lvim/core/autopairs.lua
@@ -4,8 +4,6 @@ function M.config()
lvim.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,14 +50,12 @@ M.setup = function()
end),
}
- if package.loaded["cmp"] then
- require("nvim-autopairs.completion.cmp").setup {
- map_cr = false,
- map_complete = lvim.builtin.autopairs.map_complete,
- map_char = lvim.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 = lvim.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 } }