Files
LinuxInstalls/nvim/config/nvim/lua/plugins/autopairs.lua
T
2026-09-30 16:29:04 -03:00

29 lines
1.3 KiB
Lua

return {
-- Auto-pair brackets/quotes: (), {}, [], "", '' -- nvim-autopairs'
-- own defaults. <> was tried here too but removed: it collided too
-- much with < and > as comparison operators to be worth keeping.
{
"windwp/nvim-autopairs",
dependencies = { "hrsh7th/nvim-cmp" },
config = function()
local autopairs = require("nvim-autopairs")
-- map_cr defaults to true, which makes nvim-autopairs install
-- its OWN insert-mode <CR> mapping (for expanding bracket pairs
-- onto their own indented line). That's set during plugin
-- loading, which runs after init.lua's own top-level code --
-- where the comment-continuation <CR> mapping lives -- so it
-- was silently overwriting that mapping entirely regardless of
-- what it did internally. Disabled here to free up <CR> for
-- that mapping; the trade-off is losing autopairs' own
-- brace-expands-on-Enter behavior, which was never explicitly
-- asked for.
autopairs.setup({ map_cr = false })
-- Integrates with nvim-cmp so accepting a completion (e.g. a
-- function call) doesn't end up with doubled-up parens.
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done())
end,
},
}