Skip to content

Is there’s any config that make mini.pairs smarter? #1691

Closed Answered by echasnovski
jasonxue1 asked this question in Q&A
Discussion options

You must be logged in to vote

I am afraid this is not possible because 'mini.pairs' only "knows" about cursor's neighborhood when it "makes the decision" about whether to insert the whole pair or not. This is done for performance reasons: having to compute information about whether there is an unbalanced brackets on every key press of bracket's pair has high performance impact.

The best possible behavior here is to insert only a single { if there is a } to the right of cursor. Here is one example of how to do it:

require('mini.pairs').setup({
  mappings = {
    ['{'] = { neigh_pattern = '[^\\][^}]' },
  },
})

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jasonxue1
Comment options

@echasnovski
Comment options

Answer selected by echasnovski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested mini.pairs
2 participants