vrapper/vrapper — pull request #205 by albertdev (2013-05-09 21:14:31+00:00)
Title: Add PlatformSpecificModeProvider extension point

I'm currently trying to implement another feature of Surround.vim into the Surround plugin: XML tag replacing. For this, I need a command-line like mode, but I found no way to add new modes from a plugin.

This pull request provides the basic stuff needed to add modes through an extension point. Anyone implementing a new mode needs to make both a state provider to provide a ChangeModeCommand and a mode provider to actually hook in the new mode.
Key parsing is then handled in the mode's handleKey method, so no other changes should be necessary. You can't override existing modes nor can you define a mode twice. The modes are currently lazily initialized, it's only when a ChangeModeCommand to an extension mode is given that will they all be loaded.

Note that I stripped out the editor detection logic. It could have been nice to keep it, but I didn't see the point given that you can only switch to an extension mode if its state provider got loaded (and that one is editor-aware).