Due to Android, I did a comeback to Java couple months ago and again struggled while making the choice between Eclipse and Vim. I chose to do all the coding in Vim eventually.
Last week I learnt about Eclim. The project looks so mature, I wonder why I didn't hear about it earlier. It gets the best of both worlds. It provides a script that runs eclipse in headless mode and it has Vim plugins that provide the functionality like code-completion (among others) inside the Vim editor. (There are two other scenarios as well, but I use this one, check their docs for more info).
Here is a small guide on how to set this up for doing Android coding.
My setup: Fedora 10 x86_64 linux, vim-enhanced-7.2.148, Eclipse SDK 3.4.2, Eclim 1.4.7, using Sun's JDK 1.6.0 (although gnu jre is installed, I avoid it by using custom JAVA_HOME).
Install Eclipse. I download the tarball and untar it somewhere (mostly /opt).
mkdir ~/.vim/eclim
Download eclim from here.
One thing that annoyed me was lack of installation instructions. The project page has good overall documentation, but it doesn't mention that you need to compile and install it using ant. Thanks to this post, I figured that out.
As the post says, you need ant 1.7.1. Fedora 10 has the right version. Check what you have. I tried this incantation:
JAVA_HOME=/usr/java/default ant -Declipse.home=/opt/eclipse -Dplugins=ant,jdt
It failed complaining that ant didn't find org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp.
After some googling I found a list of jars that have this class. I downloaded the ant-nodeps-1.7.1.jar, then tried following command. It built and installed eclim successfully.
JAVA_HOME=/usr/java/default CLASSPATH=$CLASSPATH:./ant-nodeps-1.7.1.jar ant -Declipse.home=/opt/eclipse -Dplugins=ant,jdt
The installation deploys necessary vim scripts under ~/.vim and installs the plugins and some scripts to your eclipse installation.
Follow Android SDK directions on how to setup eclipse environment (installation of Android plugin, etc.) and how to create a sample project. If you have created a project using activitycreator (like me), then you can still create a new project in eclipse and choose the option of creating project from "existing source".
Now start the eclimd server (/opt/eclipse/eclimd for me). It starts listening on port 9091.
Navigate to your project directory (which has .project file) and start Vim. Execute ":ProjectSettings", if you don't get any error, but see a new buffer with folded lines, then you have a working setup.
To try code completion (probably the most important feature), write an incomplete pacakge name and hit "Ctrl x Ctrl u". You should see a drop-down list like this.

If you prefer to use Tab for this purpose install the supertab vim plugin and copy few lines to your .vimrc from the end of this post.
These instructions should work more-or-less for other Linux installations too. For Mac OSX, see the post I have linked twice above.
It looks like Eclim has a lot of features, I have yet to try most of them. But this clearly feels like a great addition to my toolbox.
Ads:
* Eclipse Plug-ins (3rd Edition)
* Eclipse IDE Pocket Guide
* Hacking Vim: A Cookbook to get the Most out of the Latest Vim Editor: From personalizing Vim to productivity optimizations: Recipes to make life easier for experienced Vim users
6 comments:
Just and FYI, you can find the eclim install guide here.
Perhaps there needs to be a more prominent link on the site.
You should be able to use the .sh installer on linux and mac (and hopefully freebsd), which alleviates much of the manual build steps.
Thanks Eric for the link. I recall seeing this link a week back, but yesterday I must have had my 'dumb user hat' on. I was so convinced that if "Installation" isn't part of "Documentation" immediately after "Introduction" then it won't be available anywhere. So I overlooked the "Guides" section. I will try the script next time I need to install eclim.
After ":ProjectSettings" I get this:
Unable to determine the project. Please specify a project name or execute from a valid project directory.
Should be a valid project, at least it is for eclipse. E.g. contains .project
Ideas?
@Martin
Do you see your project listed when you run :ProjectList? If not then it could be that your project is located in another workspace than the one eclimd was started with (~/workspace by default).
Feel free to send an email to the eclim-user google group for additional help on resolving this (I don't want to hijack Jayesh's blog with general eclim support).
Android application development has brought about change in way people have using their hand held devices. The entire system of application development has made huge impact in daily lives & made our mobile phones much more than simple calling devices. These days, through various kinds of applications, they be used for just about anything from finding the closest place to eat to giving life saving treatment to neighbor in trouble.
Android Game Development
I would strongly recommend you to use Vim plugin Eclim for Android development in Vim. I use it, and I found it extremely useful. Code autocomplete, refactoring and so on, is just awesome.
Post a Comment