nvim/lua/plugins/autopairs.lua

34 lines
1.2 KiB
Lua

-- Phase 6.5: nvim-autopairs for auto-closing brackets, quotes, etc.
return {
'windwp/nvim-autopairs',
event = 'InsertEnter',
config = function()
local autopairs = require('nvim-autopairs')
autopairs.setup({
check_ts = true, -- Use treesitter to check for valid pair
ts_config = {
lua = { 'string' }, -- Don't add pairs in lua string treesitter nodes
javascript = { 'template_string' }, -- Don't add pairs in JS template strings
php = { 'string' }, -- Don't add pairs in PHP strings
},
disable_filetype = { 'TelescopePrompt', 'vim' },
fast_wrap = {
map = '<M-e>', -- Alt+e for fast wrap
chars = { '{', '[', '(', '"', "'" },
pattern = [=[[%'%"%>%]%)%}%,]]=],
end_key = '$',
keys = 'qwertyuiopzxcvbnmasdfghjkl',
check_comma = true,
highlight = 'Search',
highlight_grey = 'Comment',
},
})
-- Integration with nvim-cmp
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
end,
}