Weekly Update 11 - VimAddin custom keybindings progress

25 Jan 2015 / Filed under Weekly Update

Any Command that you add can be rebound by the user through Preferences > Key Bindings. I register a command for page down as follows:

<Extension path="/MonoDevelop/Ide/Commands">
    <Category _name="VimAddin" id="VimAddin">
        <Command id="VimAddin.VimAddinCommands.PageDown"
            _label="Page Down"
            _description="Page down in the text editor"
            shortcut="Control|F"
            defaultHandler="VimAddin.NullHandler" />
    </Category>
</Extension>

This creates a categorized command as follows:

The nice thing is once this is set up, the user will be able to see at a glance if there are any conflicting key bindings.

With this setup, the Control+F will trigger the handler, but the key event stops there; however, it needs to continue to the VimAddin edit mode so that it executes the page down action. I’m trying to programmatically send the Control+F but it results in an odd null pointer exception:

Error while executing command: Page Down
System.NullReferenceException: Object reference not set to an instance of an object
  at VimAddin.ViEditMode.CheckVisualMode () [0x00000] in <filename unknown>:0 
  at VimAddin.ViEditMode.HandleKeypress (Key key, UInt32 unicodeKey, ModifierType modifier) [0x00000] in <filename unknown>:0 
  at VimAddin.IdeViMode.HandleKeypress (Key key, UInt32 unicodeKey, ModifierType modifier) [0x00000] in <filename unknown>:0 
  at VimAddin.IdeViMode.SendKeys (Key key, UInt32 unicodeKey, ModifierType modifier) [0x00000] in <filename unknown>:0 
  at VimAddin.NullHandler.Run () [0x00000] in <filename unknown>:0 
  at MonoDevelop.Components.Commands.CommandHandler.Run (System.Object dataItem) [0x00002] in ../monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandHandler.cs:61 
  at MonoDevelop.Components.Commands.CommandHandler.InternalRun (System.Object dataItem) [0x00003] in ../monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandHandler.cs:42 
  at MonoDevelop.Components.Commands.CommandManager.DefaultDispatchCommand (MonoDevelop.Components.Commands.ActionCommand cmd, MonoDevelop.Components.Commands.CommandInfo info, System.Object dataItem, System.Object target, CommandSource source) [0x00085] in ../monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1151 
  at MonoDevelop.Components.Commands.CommandManager.DispatchCommand (System.Object commandId, System.Object dataItem, System.Object initialTarget, CommandSource source) [0x002fc] in ../monodevelop/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs:1118

I have a feeling it’s something simple and have already asked about it on the Xamarin forums. Once I get it, I’ll go ahead and make key bindings for the other Control actions.

Weekly Update 10

18 Jan 2015 / Filed under Weekly Update

In short, I spend this weekend learning more about the hype that is neovim.

Considering neovim

I first heard it posted on Xamarin forums a week or two ago. As far as I understand it, it’s a massive overhaul of vim to make it more modular and extensible with any programming language. I think two big goals for doing this is:

  1. Make it easy to contribute to. There was an interview last November with Bram Moolenaar where he jokes that the way to ensure future success of the Vim project is to keep him alive. I laughed, but I guess it’s partly true.
  2. Make it easy to embed in other editors. Since it runs headless and receives input remotely, the interface can be anything from traditional curses to your favorite editor or IDE. Just a few days ago, there was a video showing neovim embedded in the Atom editor. Also, trolling the neovim Google group, there’s neovim support for Floobits, one of those collaborative code editing services, so you can collaborate from the comfort of your terminal while people can chime in from their own instance of neovim or the web.

Well, let’s not get carried away, though. It’s not like we can suddenly do this.

I think it would be great to just embed vim in MonoDevelop rather than emulate it. I will have to check out the proof of concept, which has been in the works for 11 months now. And neovim’s website states it is pre-alpha, with features still missing. Neocomplete, for example, doesn’t work because Lua support is still coming. In spite of the long road ahead, I can only conclude by stating the emotion I am filled with at the moment: Excitement!

Gedit python plugin

Another detour that I took is fiddle with making a gedit plugin. The plugin tutorial is written for gedit 3, but it didn’t mention that it requires python 3 to be used as the loader. Anyways, I got it working and I think I can hack jedi in without too much trouble. More on this later.

Weekly Update 9

11 Jan 2015 / Filed under Weekly Update

Made a baby step with VimAddin. Basically, the issue I discovered a few months back that prevented you from effectively scrolling down in VimAddin had to do with conflicting keybindings.

Bad keybindings

To perform these debugger actions, the user would hit Control+D first, followed by the second key. This broke the only way VimAddin had to scroll down and made it impossible for me to use.

Now that I know this, the workaround is to unbind/rebind the conflicting key bindings using Control+D or Control+F.

The solution moving forward is to split out the actions into actual extension points provided by the addin. I’m not sure how this is going to look exactly or how I have to refactor, since right now, VimAddin reads keyboard input and does things automatically. I plan to read over the Monodevelop addin tutorial to remind myself of how to go about creating a command, because I think that seems to be the minimum unit of functionality that you can bind with key bindings.

The latest checkin 1.1.10 introduces no new functionality but just reads the version info from the assembly and puts it in the preferences panel. I just wanted to bump to let people know the project has a pulse. Look forward to the next commit being a fix to the above-mentioned issue.

← Older

Newer →

Alex Tsui

Alex Tsui

CS grad @ UC Davis who wishes to have nice things in C++, Python, Bash, C# and so, writes them.