Wednesday, December 30, 2015

D plugin for Intellij IDEA

I've been programming in D for over a year now and for the most part I've used Sublime Text as my editor of choice. This has been fine for experimenting with little bits of code but a proper IDE with good auto completion, code inspections and other such features can really boost productivity.

For the last five years I've been using Intellij IDEA and have grown accustomed to it's ease of use so using it for D projects would be really handy. Fortunately Kingsley Hendrickse (kingsleyh) wrote a D Programming Language plugin for Intellij (there is another plugin for dlang in the JetBrains plugin repo but this is the one to use). Kingsleyh's plugin makes use of some D tools that were written by Brian Schott (Hackerpilot):

DCD (D Completion Daemon, auto-complete program for the D programming language)
D-Scanner (tool for analyzing D source code)
dfmt (formatter for D source code)
dfix (Tool for automatically upgrading D source code)

Brian Schott did a talk about these projects at this years DConf so it's worth checking out the video on youtube. As they are stand-alone programs they need to be installed on your system manually. There are not pre-compiled binaries available currently so to get them installed you have to clone the repositories, build the projects, then put them somewhere on the system PATH. This can be done with the following steps:
git clone
git clone
git clone

cd DCD
git submodule update --init --recursive
sudo mv bin/dcd-client /usr/local/bin/
sudo mv bin/dcd-server /usr/local/bin/

cd ../Dscanner
git submodule update --init --recursive
sudo mv bin/dscanner /usr/local/bin/

cd ../dfmt
git submodule update --init --recursive
sudo mv bin/dfmt /usr/local/bin/
Then it's just a case of installing the plugin from the plugin repo and configuring it to use the tools. This is done in:

File > Settings > Other Settings > D Tools

Simply clicking the 'Auto Find' buttons should do the job.

Now that's all done you're good to go with dlang on Intellij.

No comments: