tpope / vim-unimpaired

unimpaired.vim: Pairs of handy bracket mappings
https://www.vim.org/scripts/script.php?script_id=1590
3.31k stars 205 forks source link

If loaded before vim-fugitive -- some mappings conflict #202

Closed nebbish closed 4 years ago

nebbish commented 4 years ago

Hello - I have just committed to using VIM as my IDE, and your plugins are so polished and replaced just about all of my own initial mappings -- and often with mappings that even felt more natural.

Now that I am working out my Git muscles with vim-fugitive... I think I found a mapping conflict between that plugin and this one.

This plugin will create mappings for co and cop if both c and co are still available (I think I'm reading this correctly):

if empty(maparg('co', 'n')) && empty(maparg('c', 'n'))
  nmap <silent><expr> co <SID>legacy_option_map(nr2char(getchar()))
  nnoremap cop <Nop>
endif

Anyhow... in my own .vimrc file, in my plugin defiinition section - I had vim-unimpaired before vim-fugitive -- so the mappings for checkout were not working.

I am fine now that I put vim-fugitive first :)

Just wanted to let you know. Cheers

tpope commented 4 years ago

Fugitive's checkout mappings are buffer local, which means they will always override Unimpaired's global mappings. Furthermore, Fugitive's maps are 3 characters, for example coo, and the longer mapping has precedence as long as the shorter mapping doesn't have <nowait>. Save for a very weird Vim bug, your analysis is, I regret to inform you, faulty. One possible cause is you typed the mapping too slow on your first test and fast enough once you switched the dependency order.

nebbish commented 4 years ago

Thanks for the quick response. After reading it I wanted to retrace my steps to see what I might have missed. So I re-arranged back to unimpaired first, and yeah I was able to get co to work. I still could not get coo to work - but now I think that is user error.

Thanks again for the explanation of how <nowait> plays a part in these.