fix(nvim): better autopair

This commit is contained in:
Léana 江 2023-10-26 10:09:10 +02:00 committed by Léana 江
parent bec1b47e0e
commit 4ddc2c13ca
2 changed files with 22 additions and 15 deletions

View file

@ -1,6 +1,27 @@
require "nvim-autopairs".setup()
local Rule = require "nvim-autopairs.rule"
local cond = require "nvim-autopairs.conds"
local npairs = require "nvim-autopairs"
npairs.setup()
-- Intergration with `cmp`
local cmp = require "cmp"
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
-------------------
-- Tex and Typst --
-------------------
npairs.add_rules {
Rule("$", "$", { "tex", "typst" })
:with_move(cond.done()),
Rule("_", "_", { "typst" })
:with_move(cond.done()),
Rule("*", "*", { "typst" })
:with_move(cond.done()),
Rule("```", "```", { "typst" })
:with_pair(cond.not_before_text "```")
:with_cr(cond.done),
}