Open-source IntelliJ IDEA plugin to support Mathematica development

This is a constantly growing answer. To make it easier to track the updates of this answer, I separate every added section and give appropriate headings. If you read this for the first time, please start directly below. Updates to this answer can be found at the end.

Most important thing first: There is an

  • Official website for the plugin

and here is a quick howto install

  • Download the free Community Edition of IDEA
  • start it and go to Settings -> Plugins -> Browse Repositories
  • Search for "Mathematica" and install the Mathematica Support plugin: Right click (on OSX Ctrl+MouseClick) on Mathematica Support and Install Plugin.
  • After a restart everything is set up and you can create a File -> New Project where you find now a Mathematica section.

(Original answer)

Yes, we can...

...extend IntelliJIDEA and make it a smart IDE for Mathematica package development. I started to develop such a plugin for IDEA a while ago and before going into the details, let me show you how it looks.

enter image description here

What you see above is the IDE with an opened Mathematica package. The code is highlighted and fully parsed, therefore when you made any syntactical errors, the green point at the upper right corner wouldn't be green. The parser gives you helpful messages when you made an error and shows you the point where it recognises that something is wrong. Furthermore, you see the documentation popup showing you on-the-fly help for built-in functions and operators. Let's look at some specific things in detail.

Autocompletion

Currently the plugin autocompletes built-in functions while you are typing. You can use of course the famous Camel hump completion, meaning you don't have to type all the sub-words to a function: to get a completion for AlgebraicIntegerQ you can just have to type the sub-word starts AlInQ. Here is an example

enter image description here

The first choice is always selected automatically, so you can accept it with Enter or (if you want to insert brackets for functions automatically) Shift+Enter. Usually, there is no need to trigger the completion manually, but you can always use Ctrl+Space to do so. Using the arrow keys you can navigate through the list of suggestions and note, that you can call the QuickDocumentation with Ctrl+Q even inside this completion list.

Quick usage lookup of functions and operators

Pressing Ctrl+Q (OSX Ctrl+j) when you are over or beside a function or operator opens instantly a popup window showing you the usage, options and attributes of it. For instance in this example while being over Message

enter image description here

This even works for all (but the most trivial) operators. With this, you never have to remember whether to use @@ or @@@.

enter image description here

Matching braces, brackets and parenthesis

IDEA always tries to keep your braces correct. This means, if required it inserts matching braces and even if you close already closed braces, it tries to make intelligent decisions. Furthermore, matching braces are highlighted when you navigate through the code.

Further development

Everything related to the development of the plugin will be announced and documented in the Wiki of the GitHub repository. First of all, I have to test parser and fix some minor bugs before continuing. Although I have a detailed list of features which you find in the README.md, I invite everyone to edit the Wish List in the Wiki. If someone thinks he/she can contribute to the Java-code itself, feel free ping me in the chat room for the plugin dev.

Important links

  • BugTracker where you can report any issue/bug.
  • GitHub repository for the plugin
  • Development Wiki page where I will add helpful information
  • The Plugin in the official Jetbrains Plugin Repo. This is the Due to the really easy update process, you can find the most recent version there.

Update (5. October 2013)

A lot of bugfixes, mostly under the hood, were done but additionally, some fancy features were added too. Here are the most important

Smart completion of Options

Smart option completion gives you only the options which are valid in the function you are currently in. Therefore, if you are in a position where you want to add an option to a function, pressing Ctrl+Shift+Space shows (or completes) only options which are possible at this place:

enter image description here

Completion of function arguments or local Module/Block/Table/.. variables

IDEA is now fully aware of all the local variables you have defined. Therefore, it will suggest them for you while you are typing (or when you press Ctrl+Space explicitely). Note that, of course, Camel Humps are working there too. This lets you use verbose variable names and it pushes your programming speed off limits.

enter image description here

Renaming, resolving and showing usages of local variables

IDEA lets you now easily see where you defined and used a symbol. Additionally, renaming of all instances is done in one step:

enter image description here

Update: Formatting engine working (14.11.2013)

Although not perfect, I want to make an unofficial release which includes the Formatting engine. If you want to try it, please deinstall your current plugin first, download the plugin zip file from here and install it with Preferences -> Plugins -> Install From Disk.

The core part is the reformat code functionality which can be triggered with Ctrl+Alt+L (Cmd+Alt+L on OSX) or the line-wise auto-indent code which can be triggered by using I instead of L.

Formatter

In addition to this, I had to improve the smart enter which helps you to complete a statement and can be triggered by Ctrl+Shift+Enter.

Therefore, try writing

Module[{blub},|]

with the cursor at | and the press smart enter. You see that it automatically puts the braces down and indents your cursor. Or type

Module[{var},
  var = 1;
  var+=v|
]

end when the autocompletion for var pops up, press smart enter. You see that it not only completes the variable name, it additionally reformats the line, puts a semicolon at the end and goes one line below

enter image description here

And before I forget, we have now our own Code Style settings section when you go to Preferences -> Code Style

enter image description here

There you can adjust which operators should be surrounded by space and you can define the indent. Wrapping and Blank Lines is not working right now.


Actually IntelliJ IDEA can build and run Wolfram code.

Mathematica REPL on Github

I think it's a good start. Let me explain what happened in the GIF below.

After I change the code in IntelliJ IDEA, I press Command+R, then the REPL(Mathematica) will build and run the code. I don't have to leave IntelliJ IDEA, I can code In IntelliJ on the fly and see the results in the REPL.

enter image description here

Tags:

Development