Wednesday, February 5, 2014

A Few Essential Vim Tweaks for Working in Haskell

One of the things I found most annoying about Haskell when I started working with it was the lack of a real IDE.  I searched around for a while and found nothing all that good (except maybe FP Haskell Center, but I like being able to work offline).  At first I worked with Sublime Text 2, for which there are several very useful packages available through the package manager.  And that was fine for a while.  But there were still a few things missing.  It didn't have good command line integration, and SublimeREPL just wasn't cutting it.  Around the time that this was becoming most annoying, I had also gotten to an introduction to Vim in a Unix course I was taking.  This got me investigating different editors again, this time focusing mainly on Vim and Emacs (though others were considered), and I ended up settling on Vim (though I'm considering trying to switch to Emacs again).  For some reason the modal interface seems more natural, though your mileage may vary.

Anyway, after installing Vim, I wasn't quite done - I still needed to add a few packages to make editing convenient.

Pathogen makes plugin management a whole lot easier.  Install it before anything else here to preempt headaches.

2) A Good Color Scheme
While it isn't specific to Haskell, you should care about your color schemes.  I plan to write a full post on this at some point, but for today I'm just going to assume you agree that pretty colors are important.  Anyway, there are lots of good ones to choose from.  As you might be able to tell from the colors on the blog, I'm a fan of Ethan Schoonover's Solarized, though there are plenty of others worth looking at.  A good color scheme will make it much easier to read your code at a glance while greatly reducing eye strain.

This package consists of a few plugins aimed at making Haskell development easier - GHC support, syntax highlighting, the works.  It doesn't do everything, but it sure does a lot.  You could start working in Haskell with just this and a color scheme.

Syntastic is another one that's not Haskell specific, but adds enough general functionality that it's definitely worth getting - it'll add some type checking capability to vim before you hit the compile button.  Speaking of...

I threw those lines into my .vimrc for one very simple reason:
GHC gives very useful information when you compile
Going to a different tab in iTerm and typing out ghc (filename) is annoying.
So I just nmapped F5-F7 to ghc, ghci, and ghc --make respectively

File management.  'Nuff said.  I personally prefer to use Vifm for most things, but it's really a difference of preference.  From what I understand, NERDTree is a bit more powerful, but I also find it a bit less elegant.

Better support for quick commenting - not much more to say really.  A useful feature, really strangely lacking from vim.  Much faster than 0i--.  It makes debugging a good bit easier (you can quickly comment out different pattern matches and recompile to test where the bug is, things like that).

YankRing improves copying and pasting in a lot of ways -
It allows you to copy and paste across buffers.  It essentially emulates Emacs' "kill ring" while adding a few other nice features.  


Anyway, those are the main tweaks that I use.  I've heard many times that I should use SHIM, but I've never really seen the need for it.  This may turn out to be isomorphic to the blub paradox, but until I get around to testing it I won't know.

No comments:

Post a Comment