From 9c82e73c693573d0997c298c0e0686482d44156c Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Fri, 14 Jul 2023 13:20:34 +0200 Subject: [PATCH] disable/enable nvim-autopairs with --- home/.config/nvim/autopairs.vim | 13 +++++++++---- home/.config/nvim/utils.lua | 11 +++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 home/.config/nvim/utils.lua diff --git a/home/.config/nvim/autopairs.vim b/home/.config/nvim/autopairs.vim index e10220e..a3cf6c5 100644 --- a/home/.config/nvim/autopairs.vim +++ b/home/.config/nvim/autopairs.vim @@ -1,10 +1,15 @@ +" off with +nmap :lua require('nvim-autopairs').disable() +" on with +nmap :lua require('nvim-autopairs').enable() + +" fix being not usable to select a completion item +inoremap coc#pum#visible() ? coc#pum#confirm() : + \ "\u\=v:lua.require'nvim-autopairs'.autopairs_cr()\" + lua << EOF require("nvim-autopairs").setup {} local Rule = require('nvim-autopairs.rule') local npairs = require('nvim-autopairs') npairs.add_rule(Rule("<>","<>","rs")) EOF - -" fix being not usable to select a completion item -inoremap coc#pum#visible() ? coc#pum#confirm() : - \ "\u\=v:lua.require'nvim-autopairs'.autopairs_cr()\" diff --git a/home/.config/nvim/utils.lua b/home/.config/nvim/utils.lua new file mode 100644 index 0000000..2ba735e --- /dev/null +++ b/home/.config/nvim/utils.lua @@ -0,0 +1,11 @@ +local utils = {} + +function M.map(mode, lhs, rhs, opts) + local options = { noremap = true } + if opts then + options = vim.tbl_extend("force", options, opts) + end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) +end + +return utils