55 lines
2.0 KiB
Lua
55 lines
2.0 KiB
Lua
local autopairs = require('nvim-autopairs')
|
|
local Rule = require('nvim-autopairs.rule')
|
|
local cond = require('nvim-autopairs.conds')
|
|
|
|
autopairs.setup({
|
|
{
|
|
enabled = function(bufnr) return true end, -- control if auto-pairs should be enabled when attaching to a buffer
|
|
disable_filetype = { "TelescopePrompt", "spectre_panel", "snacks_picker_input" },
|
|
disable_in_macro = true, -- disable when recording or executing a macro
|
|
disable_in_visualblock = false, -- disable when insert after visual block mode
|
|
disable_in_replace_mode = true,
|
|
ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=],
|
|
enable_moveright = true,
|
|
enable_afterquote = true, -- add bracket pairs after quote
|
|
enable_check_bracket_line = false, --- check bracket in same line
|
|
enable_bracket_in_quote = true, --
|
|
enable_abbr = false, -- trigger abbreviation
|
|
break_undo = true, -- switch for basic rule break undo sequence
|
|
check_ts = false,
|
|
map_cr = true,
|
|
map_bs = true, -- map the <BS> key
|
|
map_c_h = false, -- Map the <C-h> key to delete a pair
|
|
map_c_w = true, -- map <c-w> to delete a pair if possible
|
|
}
|
|
})
|
|
|
|
autopairs.add_rules({
|
|
Rule("$", "$",{"tex", "latex"})
|
|
-- don't add a pair if the next character is %
|
|
:with_pair(cond.not_after_regex("%%"))
|
|
-- don't add a pair if the previous character is xxx
|
|
:with_pair(cond.not_before_regex("xxx", 3))
|
|
-- don't move right when repeat character
|
|
:with_move(cond.none())
|
|
-- don't delete if the next character is xx
|
|
:with_del(cond.not_after_regex("xx"))
|
|
-- disable adding a newline when you press <cr>
|
|
:with_cr(cond.none())
|
|
},
|
|
-- disable for .vim files, but it work for another filetypes
|
|
Rule("a","a","-vim")
|
|
)
|
|
|
|
autopairs.add_rules({
|
|
Rule("$$","$$","tex")
|
|
:with_pair(function(opts)
|
|
print(vim.inspect(opts))
|
|
if opts.line=="aa $$" then
|
|
-- don't add pair on that line
|
|
return false
|
|
end
|
|
end)
|
|
}
|
|
)
|