diff options
author | kylo252 <[email protected]> | 2021-10-30 14:43:29 +0200 |
---|---|---|
committer | kylo252 <[email protected]> | 2021-10-30 14:44:24 +0200 |
commit | 17648e5a07f8c4fe851b09f3037db58c73fe292f (patch) | |
tree | 6ef8f701b823e5d4f61945142eb7ceec2581ead4 /lua/lvim/core/autopairs.lua | |
parent | 1f2167df0ea3f837c9c78a0137a888ca05e5e83a (diff) | |
parent | c4a85b32752e1ca41c6d9a2613b9d2e75dbf463d (diff) |
Merge branch 'rolling'
Diffstat (limited to 'lua/lvim/core/autopairs.lua')
-rw-r--r-- | lua/lvim/core/autopairs.lua | 16 |
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 } } |