From 0d1d303679aaf2dea94120a19d5d85c1cf03f74d Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Tue, 1 Mar 2022 01:49:46 -0600 Subject: [PATCH] Add autopairs --- lua/configs/autopairs.lua | 40 +++++++++++++++++++++++++++++++++++++++ lua/configs/cmp.lua | 2 +- lua/plugins.lua | 3 +++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 lua/configs/autopairs.lua diff --git a/lua/configs/autopairs.lua b/lua/configs/autopairs.lua new file mode 100644 index 0000000..9ee75ed --- /dev/null +++ b/lua/configs/autopairs.lua @@ -0,0 +1,40 @@ +local M = {} + +function M.config() + local status_ok, npairs = pcall(require, "nvim-autopairs") + if not status_ok then + return + end + + npairs.setup { + check_ts = true, + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + fast_wrap = { + map = "", + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "PmenuSel", + highlight_grey = "LineNr", + }, + } + + --Rule = require "nvim-autopairs.rule" + -- local cmp_autopairs = require "nvim-autopairs.completion.cmp" + -- local cmp_status_ok, cmp = pcall(require, "cmp") + -- if not cmp_status_ok then + -- return + -- end + -- cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } }) +end + +return M + diff --git a/lua/configs/cmp.lua b/lua/configs/cmp.lua index e173007..f4860d8 100644 --- a/lua/configs/cmp.lua +++ b/lua/configs/cmp.lua @@ -80,7 +80,7 @@ function M.config() }, sources = { { name = "nvim_lsp" }, - { name = "luasnip" }, + --{ name = "luasnip" }, { name = "buffer" }, { name = "path" }, }, diff --git a/lua/plugins.lua b/lua/plugins.lua index b159259..37a9ea5 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -146,6 +146,9 @@ packer.startup { -- Quality of Life -- + -- Autopairs + use { 'windwp/nvim-autopairs', config = function() require'configs.autopairs'.config() end } + -- Commenting use { 'numToStr/Comment.nvim', config = function() require'configs.comment'.config() end }