matchwith.nvim is an alternative plugin to matchparen and matchit. Provides simpler functionality using treesitter.
Caution
We have identified some bugs and are actively working on resolving them.
Displays off-screen match symbols.
Highlight the next capture match and parent node match.
The word_highlight feature is a treesitter implementation of LSP reference highlighting.
This feature can have a significant impact on performance and is therefore implemented
in the word_highlight branch.
Option values
word_highlight(boolean): Enable/Disable the feature. default:trueavoid_word_type(string[]): Specifies nodes to be excluded. default:{ 'comment', 'string', 'codeblock', 'heading', 'delimiter' }
- Neovim >= 0.11.0
- lazy.nvim
{
'tar80/matchwith.nvim',
opts = {
...
},
}
Defalut values.
Caution
The off_side option is no longer needed.
require('matchwith').setup({
captures = {
['*'] = { 'tag.delimiter', 'punctuation.bracket' },
lua = { 'keyword.function', 'keyword.repeat', 'keyword.conditional', 'keyword.do.matchwith', 'punctuation.bracket', 'constructor' },
vim = { 'keyword.function', 'keyword.repeat', 'keyword.conditional', 'punctuation.bracket', 'constructor', 'keyword.exception' },
},
debounce_time = 50,
depth_limit = 10,
ignore_buftypes = { 'nofile' },
ignore_filetypes = { 'vimdoc' }, -- Suggested items: 'TelescopePrompt', 'TelescopeResults', 'cmp_menu', 'cmp_docs' ,'fidget', 'snacks_picker_input'
ignore_parsers = { 'markdown' },
indicator = 0,
jump_key = nil, -- e.g. '%'
priority = 100,
show_next = false,
show_parent = false,
sign = false,
symbols = { [1] = '↑', [2] = '↓', [3] = '→', [4] = '↗', [5] = '↘', [6] = '←', [7] = '↖', [8] = '↙' },
-- in word_highlight branch
word_highlight = true,
avoid_word_type = { 'comment', 'string', 'codeblock', 'heading', 'delimiter' }
})Matchwith provides four operator keys corresponding to matchepair.
<Plug>(matchwith-operator-i)Inner range of the current/next matchpair<Plug>(matchwith-operator-a)A range of the current/next matchpair<Plug>(matchwith-operator-parent-i)Inner range of the parent matchpair<Plug>(matchwith-operator-parent-a)A range of the parent matchpair
Register like this:
vim.keymap.set({'o','x'}, 'i%', '<Plug>(matchwith-operator-i)')
vim.keymap.set({'o','x'}, 'a%', '<Plug>(matchwith-operator-a)')
vim.keymap.set({'o','x'}, 'iP', '<Plug>(matchwith-operator-parent-i)')
vim.keymap.set({'o','x'}, 'aP', '<Plug>(matchwith-operator-parent-a)')