4

One of the neat features in Neovim is that it should be possible to embed it into other applications, to make it look it as if it was the built in editor an IDE for example!

I really want to do this with MATLAB.

1. Is it possible to embed Neovim into Matlab "in place of" the default MATLAB editor?

If so: how?

If that is not the case:

2. Would it need to be implemented on MATLAB's side, or could it be done with a plugin or something?

  • There's vim-matlab... I have no idea how well it works... But you can try it :-) – Martin Tournoij Mar 16 '16 at 2:56
  • No, I'm not looking for a matlab cli. I know how to use it, for the most part, even in headless mode. I do prefer this to using the GUI, but some things are hard to get by in -nodisplay mode. I don't think there is a way to run a section of a script (a section devided by a %% comment, I mean), skip the second section and run the third section. Also (very strangely) I can't find a way to list the variables as it does in the GUI workspace. These, and a few other things (mostly regarding plots) keep me from using -nodisplay full time. – lindhe Mar 17 '16 at 19:27
1

Is it possible

One of the major changes Neovim made was to decouple the GUI implementation from the core application. All GUI (and TUIs for that matter) communicate with the core application using the msgpack RPC protocol. msgpack works over stdin/stdout, named pipes, tcp, etc. so its possible for pretty much any application to support neovim as its embedded editor. It just requires the GUI to handle all the GUI stuff, while pushing down keystrokes and text to the core to handle processing.

Would it need to be implemented on MATLAB's side

As for MATLAB or any preexisting application, there is quite a few steps that need to be taken to implement this change. Basically all input and output needs to now be directed to and from the nvim RPC system. The text area needs to get its content from nvim. Each keystroke event handler needs to decide if its a vim request and send to nvim, or if it is something that MATLAB would handle. And of course, MATLAB would need to implement the startup of the nvim process and be able to do bi-directional communication (using msgpack).

While it would be nice to have vi-keybindings and even plugin support in MATLAB, I don't see there would be a huge motivation to do this, especially when you have plugins and access to the MATLAB cli. It would be quite a bit amount of work to wedge this in there.

When is this feature awesome

Where Neovim's embedded feature really shines is in new development and atypical installations.

Cloud9 is an online editor and IDE. It currently has a vim mode which gives you key-bindings, etc. Just think if you were able to remove all the code required to reinvent the "vim wheel" by creating a text area and an event handler to capture key presses and make a background nvim process do all the work? A JS based web-page that actually uses all of your VimL plugins you have on your desktop, how awesome would that be? When new features are added and bugs are fixed, just drop in a replacement nvim and you're good to go.

Do you currently have a GUI application that is in need of an editor function? Maybe you want a more powerful editor than just Backspace and Delete. Using an embedded version of nvim can give you that functionality very quickly. vi-keybindings are very common but most people don't notice (Gmail uses them for navigation for instance). If you don't like using hjkl, then setup a custom vimrc to remap all the key-bindings so no one knows its vim.

Think of all those devices out there with "Easy to Use" Configuration UIs that provide little advanced user functionality unless you go in and monkey with config files. Add in a button to edit the file right in your app.

More Info

For more information on the entire UI architecture check out the Neovim wiki. There are also a bunch of GUI implementations and Programming Language bindings available on the Related Projects page.

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.