chrisbra / matchit

The matchit plugin from Vim
61 stars 9 forks source link

Matchit won't work with rebinded `%` keys. #22

Closed psychoslave closed 4 years ago

psychoslave commented 4 years ago

Hello,

As exposed in the Why is my 'noremap % =' not taken into account? Stackexchange entry, Matchit create some conflicts when the % is remapped.

The thread bring a solution to avoid a binding overwrite by completely preventing Matchit to load.

But it would be fine to be able to use it Matchit and still have the custom bindings working.

Here are the two concerned mappings:

noremap % =
noremap 5 %

The Stackexchange entry advise to add any required remap to the corresponding Matchit behavior. Is there a quick way to do it, like say let g:matchit_key = 5?

In any case, it would be fine that Matchit detect remaps of %, both ways, and set everything up seamlessly to just work out of the box.

psychoslave commented 4 years ago

Thanks @chrisbra for the fix.

I have a few question that pop up into my head:

chrisbra commented 4 years ago

simply clone this in your packpath, (create non-existing directories): 1)

cd ~/.vim/pack/dist/start
git clone https://github.com/chrisbra/matchit

2) <Plug> is like a virtual key, that can be bound to an actual key. See :h <Plug> 3) The patch disables all matchit key mappings to keys like %, g% and a few others, if you set :let g:no_plugin_maps=1 If you want to use them, you need to manually setup those maps to any key of your liking.

psychoslave commented 4 years ago

Ok, thank you @chrisbra.

So the patch actually allows to avoid the overwriting of custom key bindings, but doesn't provide a way to configure Matchit on a specific key, right?

What would you think of a possibility to configure Matchit through something like let g:plugin_matchit_trigger_key=5?

chrisbra commented 4 years ago

What would you think of a possibility to configure Matchit through something like let g:plugin_matchit_trigger_key=5?

Apart from that it is not directly known, what trigger key is meant (because matchit maps a couple of keys), how is that different than directly binding it to whatever key you like?

nmap <silent> <f5>  <Plug>(MatchitNormalForward)
psychoslave commented 4 years ago

I'll investigate that. Thank you for your feedback.