I no longer actively use or maintain this configuration. This still works but I encourage you to try my Atom editor package Proto REPL.
A description of how I setup Sublime Text for Clojure development. It's a bit hacky but it works if you prefer to use Sublime Text for your editing. This is specific to my own workflow on a Mac but should be mostly applicable to development on other platforms with Sublime Text.
Initially based on instructions here: https://gist.github.com/jamesmacaulay/5457344
Install it then create ~/.lein/profiles.clj
. See profiles.clj
in this repo for contents.
This documents how to setup Sublime Text 2 with Clojure. It uses the sublime text package manager. Follow the installation instructions to install the package manager into Sublime Text 2. If you already have the package manager installed make sure all packages are up to date.
The Sublime REPL is used to open a REPL within Sublime Text. It can be opened by:
repl
and select SublimeREPL: Clojure
repl
Very Important: Most of the time you'll want a REPL open for the current project. Sublime REPL only knows to connect the REPL to the current project if you start the REPL with a Clojure file open in the project and your cursor is in it.
These are setup in the instructions Sublime Text setup instructions below.
subl
command line argument works. See https://www.sublimetext.com/docs/2/osx_command_line.htmlInstall these packages using the package manager.
Add this code to your user preferences
~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/Preferences.sublime-settings
// This needs to be disabled since we're using Bracket Highlighter for highlighting brackets
"match_brackets": false
Sublime Text doesn't correctly identify Clojure symbols.
~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/Clojure.sublime-settings
with the following contents.{
"extensions":
[
"cljs"
],
"word_separators": "\\()\"',;@$%^&|[]{}`~"
}
Clojure uses single quote characters by themselves like (def my-literal-list '(1 2 3))
. Sublime Text will automatically close single quotes. This becomes annoying when writing Clojure code in sublime text. Turn it off by following these steps:
~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Default/Default (OSX).sublime-keymap
This file updates SublimeREPL settings so leiningen in on the path. Update this file to include the directory where you installed leiningen.
~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/SublimeREPL.sublime-settings
with the following changes{
// Has to include path to lein
"default_extend_env":
{
"PATH": "REPLACE_ME_WITH_LEIN_DIR:{PATH}:/usr/local/bin"
}
}
The lispindent.sublime-settings defines which forms use function style indentation. I've added additional ones that are typically used in Clojure Applications
* `cp lispindent.sublime-settings ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/`
Change ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/SublimeREPL/config/Clojure/Main.sublime-menu
line 22 from
"osx": ["lein", "repl"]
to:
"osx": ["lein", "trampoline", "run", "-m", "clojure.main"]
This greatly improves the speed at which text is sent from a Clojure window to the REPL. Based on answer here http://stackoverflow.com/questions/20835788/is-it-normal-to-have-really-slow-text-transfer-in-sublime-text-2-with-the-clojur
We'll setup some keybindings in Sublime Text to make it easier to send code to the repl, run tests, etc.
clojure_keybindings.sublime-keymap
in this repo to ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/Default (OSX).sublime-keymap
The ClojureHelpers.py
file provides some helper functions that make working with Sublime REPL and Clojure a little better. These are associated with key bindings. You can also add your own helpers to this file.
ClojureHelpers.py
to ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/
cp ClojureHelpers.py ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/
Copy the file clojure_snippets.sublime-snippet
to ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/clojure_snippets.sublime-snippet
. It contains some useful completions.