Quickstart: Getting Started with Clojure via Vim, Lein, Slimv (Windows + Linux)
You'll need a command line for this. Here's the quick view:
- Install leiningen
- Install Slimv
- Install swank-clojure
- Create a project and get started
Leiningen is a combination buildout/package management script for clojure. In Windows, you'll need lein.bat; on *nix, just lein will do.
Get the one you need from the link, and make sure it's in your PATH. You have a user-space bin/ area where you keep your command-line executables, right? That's outside the scope of this article, but if you don't have one, get one.
I also had to get wget.exe and put it in the path; I got mine from http://users.ugent.be/~bpuype/wget/wget.exe.
Once you have lein, you can run the self-install to finish the job:
> lein self-install
I assume you found this article looking for something like "vim clojure", so I assume you have pathogen. If not, get it. After that, it's as easy as downloading slimv and putting its contents in the bundle/ directory. We'll see if it worked later.
Leiningen makes this as easy as
> lein plugin install swank-clojure 1.4.0
I'm not actually sure this is necessary, but hey, it worked for me.
Lein really prefers that you do your development in a well-defined project directory. You can make one with:
> lein new test-app
This will create a new clojure project "test-app" in a new directory from where you ran the command. Then, cd into that directory and run:
> lein swank
Slimv claims to have the ability to run this for you, but it didn't work for me on windows. Besides, this way you're running it from your proper project. Now, you can open the src/test-app/core.clj file in vim (this might be called something else for you). It will have a namespace at the top already; I added the rest in so that you had something to test on:
|1 2 3 4 5||
(defn fact [x] (reduce * (range 1 (inc x))))
1) Turn off paredit using ",(". It will be annoying for you until you get used to it.
2) Open up the swank connection using ",c", outside of insert mode of course.
3) Go within the (defn...) and type ",d". This is a shortcut to evaluating the defn that your cursor is in.
4) Highlight the opening paren of the (fact 5) statement and type ",e". This will evaluate the current form.
That's about it! You should see the results in the swank window in vim as you do all that.