Saturday, 1 June 2013

Set imap depending on filetype

Set imap depending on filetype

I'm using the xml and omnicppcompl plugins for Vim, and making use of two insert mappings these plugins define for the '>' key. My problem is that while the omnicppcompl plugin will happily imap the '>' key when I enter a buffer of filetype cpp or c, but when it does, the xml plugin's imap of the '>' key will no longer work, as it wont remap itself when I enter a buffer of filetype xml. This causes me to be unable to further use the functionality the mapping provides when I edit xml files, which is to automatically write a closing tag (the omnicppcompl map stays though).
What I'm looking for is that these two mappings are available in their respective filetype, and I believe the issue lies in the xml plugin not remapping itself the way omnicppcompl can. I tried writing quick autocmd's in my .vimrc to manually remap the '>' key, but the xml plugin imap's to a local function in its script with the <SID> bit.
Does anyone know how I can work around this? Is there a way to force the xml plugin to re-run its mapping? I don't know very much about vim scripting and how plugins operate, but is it because the xml plugin has no autoload scripts?
For reference, the xml plugin maps the '>' key on line 1485 of ftplugin/xml.vim, and the omnicppcompl plugin maps the '>' key on line 40 of autoload/omni/cpp/complete.vim
I would greatly appreciate any help and suggestions for how to fix/workaround this.

No comments:

Post a Comment