monkoose / matchparen.nvim

alternative to matchparen neovim plugin
MIT License
113 stars 2 forks source link

Matchparen.nvim

alternative to default neovim matchparen plugin

main branch requires neovim v0.8 or higher.

Last version that uses neovim v0.7 is dc511ea. Last version that uses neovim v0.6 is 8df2b17.

BE AWARE: highlighting should work as expected, but jumping to highlighted bracket with % or text objects as i(, a[ etc not implemented yet, so it could work improperly when there are some unmatched brackets in strings or comments inside highlighted brackets. With default plugin you will have the same behavior.

It fixes some bugs of the default plugin like:

It is also much faster (5-10 times in my synthetic tests).

Installation

For vim-plug

Plug 'monkoose/matchparen.nvim'

For packer.nvim

use 'monkoose/matchparen.nvim'

This plugin tries it best to disable built-in plugin before enabling itself, but if you use packer (and it's config option to setup matchparen.nvim) or use some kind of lazy loading, then you can check if built-in plugin was loaded with trying to write and autocomplete such command :DoMatchParen. If it is present then you may want to explicitly disable built-in matchparen plugin with setting global variable to 1 somewhere in you config outside of packer config option.

vim.g.loaded_matchparen = 1

It would improve startuptime a little bit and will not create unnecessary commands.

Usage

Initialize the plugin with this line somewhere in your config

require('matchparen').setup()

There are two commands to temporary disable or enable the plugin

:MatchParenDisable
:MatchParenEnable

Configuration

require('matchparen').setup({
    on_startup = true, -- Should it be enabled by default
    hl_group = 'MatchParen', -- highlight group of the matched brackets
    augroup_name = 'matchparen',  -- almost no reason to touch this unless there is already augroup with such name
    debounce_time = 100, -- debounce time in milliseconds for rehighlighting of brackets.
})

Read :h matchparen.nvim-configuration for more descriptive explanation of the options.