Skip to content
dubiousdavid edited this page Sep 6, 2012 · 4 revisions

Note - Clojure support in Sublime Text 2 (build 2216) is broken with Leiningen 2 prev 10.

Install Sublime Text 2, install Sublime Text Package Control, use that to install the SublimeREPL package, and finally, install Leiningen 1.7.

From the Sublime Text 2 menu, Preferences > Browse Packages. You'll be taken to the Packages folder, open SublimeREPL/config/Clojure/Main.sublime-menu. Add a new command that looks like this:

{"command": "repl_open", 
 "caption": "ClojureScript",
 "id": "repl_clojurescript",
 "args": {
    "type": "subprocess",
    "encoding": "utf8",
    "cmd": {"windows": ["lein.bat", "repl"],
            "linux": ["lein", "repl"],
            "osx":  ["lein", "trampoline", "cljsbuild", "repl-listen"]},
    "soft_quit": "\n(. System exit 0)\n",
    "cwd": {"windows":"c:/Clojure", // where the lein.bat lives!
            "linux": "$file_path",
            "osx": "$file_path"},
    "syntax": "Packages/Clojure/Clojure.tmLanguage",
    "external_id": "clojure",
    "extend_env": {"INSIDE_EMACS": "1"}
    }
}

You will also need to add the following to Default.sublime-commands.

{
    "caption": "SublimeREPL: ClojureScript",
    "command": "run_existing_window_command", "args":
    {
        "id": "repl_clojurescript",
        "file": "config/Clojure/Main.sublime-menu"
    }
}

You may also need to enable keyboard shortcuts for SublimeRepl. Again open packages SublimeREPL and open the keymap that pertains to your OS (e.g: Default (Linux).sublime-keymap)

Now uncomment the lines at the bottom. You can use these commands to send code straight to the REPL and trigger browser evaluation. (Roughly equivalent to emacs C-c C-e)