0

I use a completely remapped layout to match the traditional qwerty action position over a bépo layout.

Lately, using NVIM v0.4.3, my binding to map the % to = (format auto) ceased to work. This is very strange as all other binding seems to work fine, and actually if I run noremap % = at run time, everything comes back at the expected behaviour. Before manual intervention, a session will act like this:

:noremap %
o  %             <Plug>(MatchitOperationForward)                                                                                                                                              
x  %             <Plug>(MatchitVisualForward)                                                                                                                                                 
n  %             <Plug>(MatchitNormalForward)                                                                                                                                                 
s  %           * =                                                                                                                                                                            

More information about my configuration

cat ~/.config/nvim/init.vim 
source ~/.config/vim/general

cat ~/.config/vim/general 
source ~/.config/vim/mapleader
source ~/.config/vim/paths
source ~/.config/vim/browse
source ~/.config/vim/indent-policy
source ~/.config/vim/rendering
source ~/.config/vim/save-policy
source ~/.config/vim/buffers
source ~/.config/vim/filetype
source ~/.config/vim/bépo

tail ~/.config/vim/bépo
noremap 4 $
noremap 5 %
noremap 6 ^
noremap 7 &
noremap 8 *
noremap 9 (
noremap 0 )
noremap ° _
noremap ` +
noremap % =

As you can see, as far as my custom configuration noremap % = is the last instruction and shouldn't be overwritten by something else as I don't have any after/ftplugin in my personal vim directories.

What am I missing?

7
  • You need to stop matchit from overriding your key-binds, since it comes later in the list of files vim sources when starting. More to follow. – D. Ben Knoble May 2 '20 at 12:13
  • It must be remembered that Neovim, unlike Vim, loads matchit plugin by default. – Matt May 2 '20 at 12:48
  • Ok, thanks for the tip, can you give me direct indication on how to either prevent the load of matchit, or defer my noremap after its load? – psychoslave May 2 '20 at 15:00
  • psychoslave, as usual, let g:loaded_matchit = 1 – Matt May 2 '20 at 15:12
  • 1
    Oh, actually putting "let g:loaded_matchit = 1" before the bépo remapings works fine. Much thanks. – psychoslave May 2 '20 at 15:23
2

Unlike Vim, Neovim by default loads :h matchit plugin. As plugins are normally loaded after vimrc, your mapping gets redefined inside matchit.

If you don't use matchit anyway, you can forbid it to load by adding let g:loaded_matchit = 1 to your vimrc.

9
  • As I'm currently working on a Rails project, I guess Matchit might help me with do … end block, might not it? In that case, it seems that this solution fake that the Matchit plugin was loaded. Wouldn't be possible to also manually force the plugin loading? – psychoslave May 3 '20 at 5:04
  • Ok, with a locate matchit.vim | xargs nvim, I came to the conclusion that :source /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim what was I was looking for. But Matchit doesn't seem to come with Ruby support after all, or does it? – psychoslave May 3 '20 at 5:13
  • According to github.com/chrisbra/matchit the ex command :packadd! matchit should also do the trick. – psychoslave May 3 '20 at 5:15
  • 1
    @ChristianBrabandt Personally, I think it's enough to add support for :h no_plugin_maps and no_matchit_maps, as in a bunch of other standard plugins. – Matt May 3 '20 at 17:31
  • 1
    I think I have fixed it – Christian Brabandt May 4 '20 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.