diff --git a/lua/astrocommunity/editing-support/ultimate-autopair-nvim/README.md b/lua/astrocommunity/editing-support/ultimate-autopair-nvim/README.md new file mode 100644 index 000000000..30ef6f572 --- /dev/null +++ b/lua/astrocommunity/editing-support/ultimate-autopair-nvim/README.md @@ -0,0 +1,7 @@ +# ultimate-autopair.nvim + +**Repository** + +- Replace nvim-autopairs with ultimate-autopair.nvim. +- Setup rule to automatically disable pairing while editing comments. +- Add `ua` keymap to toggle the plugin off and on. diff --git a/lua/astrocommunity/editing-support/ultimate-autopair-nvim/init.lua b/lua/astrocommunity/editing-support/ultimate-autopair-nvim/init.lua new file mode 100644 index 000000000..ae6f24276 --- /dev/null +++ b/lua/astrocommunity/editing-support/ultimate-autopair-nvim/init.lua @@ -0,0 +1,44 @@ +return { + { + "windwp/nvim-autopairs", + enabled = false, + }, + { + "altermo/ultimate-autopair.nvim", + event = "InsertEnter", + opts = { + cmap = false, + extensions = { + rules = { + rules = { + { + "call", + function(o) + -- disable in comments including markdown style + local status, node = pcall(vim.treesitter.get_node, { pos = { o.linenr - 1, o.col - 2 } }) + return o.incmd + or o.col == 1 + or not status + or not node + or node:type() ~= "comment" and node:type() ~= "html_block" + end, + }, + }, + }, + -- get fly mode working on strings: https://github.com/altermo/ultimate-autopair.nvim/issues/17 + fly = { + nofilter = true, + }, + }, + { '"', '"', fly = true, p = 11 }, + { "'", "'", fly = true, p = 11 }, + }, + keys = { + { + "ua", + function() require("ultimate-autopair").toggle() end, + desc = "Toggle ultimate-autopair", + }, + }, + }, +}