From 00d144e1e30a21f4b7746c507e15651173079a24 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 20 Nov 2023 22:15:47 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20nvim-autopairs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/lazy-plugins.lua | 17 ++++++++++------- lua/plugins/cmp.lua | 9 +++++++++ lua/plugins/nvim-autopairs.lua | 9 --------- 3 files changed, 19 insertions(+), 16 deletions(-) delete mode 100644 lua/plugins/nvim-autopairs.lua diff --git a/lua/lazy-plugins.lua b/lua/lazy-plugins.lua index bffaf7e..1057bb5 100644 --- a/lua/lazy-plugins.lua +++ b/lua/lazy-plugins.lua @@ -49,7 +49,7 @@ local plugins = { }, { "nvim-treesitter/nvim-treesitter-context", - event = {"BufReadPre", "BufNewFile"}, + event = { "BufReadPre", "BufNewFile" }, dependencies = { "nvim-treesitter/nvim-treesitter", }, @@ -75,18 +75,21 @@ local plugins = { "L3MON4D3/LuaSnip" } }, - { - "windwp/nvim-autopairs", - config = function() - require("plugins.nvim-autopairs") - end - }, }, event = { "InsertEnter", "CmdlineEnter" }, config = function() require("plugins/cmp") end }, + { + "windwp/nvim-autopairs", + event = "InsertEnter", + opts = { + map_c_w = true, + enable_check_bracket_line = true, + check_ts = true, + }, + }, { "Dynge/gitmoji.nvim", ft = "gitcommit", diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 4e591e2..8e9ba6d 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -102,3 +102,12 @@ cmp.setup.cmdline(':', { } }) }) + +-- nvim-cmp +-- If you want insert `(` after select function or method item +local cmp_autopairs = require('nvim-autopairs.completion.cmp') +local cmp = require('cmp') +cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done() +) diff --git a/lua/plugins/nvim-autopairs.lua b/lua/plugins/nvim-autopairs.lua deleted file mode 100644 index ed548af..0000000 --- a/lua/plugins/nvim-autopairs.lua +++ /dev/null @@ -1,9 +0,0 @@ -local npairs = require("nvim-autopairs") - -npairs.setup({ - map_bs = true, - map_cr = true, - map_c_w = true, - enable_check_bracket_line = true, - check_ts = true, -})