Skip to content

Commit

Permalink
feat(editing-support): add ultimate-autopair.nvim (#314)
Browse files Browse the repository at this point in the history
* feat(editing-support): add ultimate-autopair.nvim

* load on event

* move readme

---------

Co-authored-by: windowsrefund <mtf8>
  • Loading branch information
windowsrefund authored Jun 30, 2023
1 parent 840e049 commit 73a537c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ultimate-autopair.nvim

**Repository** <https://github.com/altermo/ultimate-autopair.nvim>

- Replace nvim-autopairs with ultimate-autopair.nvim.
- Setup rule to automatically disable pairing while editing comments.
- Add `<leader>ua` keymap to toggle the plugin off and on.
44 changes: 44 additions & 0 deletions lua/astrocommunity/editing-support/ultimate-autopair-nvim/init.lua
Original file line number Diff line number Diff line change
@@ -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 = {
{
"<leader>ua",
function() require("ultimate-autopair").toggle() end,
desc = "Toggle ultimate-autopair",
},
},
},
}

0 comments on commit 73a537c

Please sign in to comment.