Leiningen is the de facto clojure project and package manager. It can be installed via homebrew on OS X
brew install leiningenor just download the shell script and put it on your path. If ~/bin is on your path, then you would do:
curl https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > ~/bin/lein
chmod +x ~/bin/lein
leinThe final invocation of lein performs the full installation.
Vim and Emacs integration use nREPL to run the Clojure REPL. Add the following to
~/.lein/profiles.clj to add the nrepl plugin to all leiningen projects
{:user {:plugins [[cider/cider-nrepl "LATEST"]]}}I use Emacs primarily, and it probably has the best Clojure setup. But it can be a burden to learn a new editor and a new language at the same time, so don't feel you have to make the switch if you're not already an Emacs user.
Be sure you're using at least Emacs 24, and add the following ELPA respository:
(setq package-archives (cons '("melpa-stable" . "http://melpa-stable.milkbox.net/packages/")
package-archives))Then install the following ELPA packages (M-x package-list-packages to bring up the listing):
clojure-mode
clojure-mode-extra-font-locking
cider
ac-cider
And I recommend adding the following hooks to your ~/.emacs or ~/.emacs.d/init.el file:
(require 'clojure-mode-extra-font-locking)
(eval-after-load 'clojure-mode
'(progn
(add-hook 'clojure-mode-hook (lambda ()
(paredit-mode +1)
(local-set-key (kbd "RET") 'newline-and-indent))))
(eval-after-load 'cider-repl-mode
'(progn
(add-hook 'cider-repl-mode-hook (lambda () (paredit-mode +1)))
(add-hook 'cider-mode-hook 'cider-turn-on-eldoc-mode)
(define-key cider-repl-mode-map (kbd "RET")
(lambda ()
(interactive)
(if (eobp)
(funcall 'cider-repl-return)
(flet ((cider-repl--input-complete-p (&rest args) nil))
(funcall 'cider-repl-return)))))))Emacs help for clojure-mode and paredit-mode will contain the various keybindings, or just ask me.
If you haven't already, install Tim Pope's vim-pathogen plugin
mkdir -p ~/.vim/autoload
curl https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim > ~/.vim/autoload/pathogen.vimAnd add the following to ~/.vimrc
execute pathogen#infect()Now install vim-fireplace and paredit.vim
mkdir -p ~/.vim/bundle
git clone https://github.com/tpope/vim-fireplace ~/.vim/bundle/vim-fireplace
git clone https://github.com/vim-scripts/paredit.vim ~/.vim/bundle/paredit.vimMany paredit commands use the <Leader> key and bind with noremap, so if you have
remapped yours (or would like to) be sure to put pathogen#infect() call after the
remapping. For example, I like to use \ as my <Leader> and <LocalLeader>:
let mapleader = "\\"
let maplocalleader = "\\"
execute pathogen#infect()If you don't remap, it uses , by default.
After you run :Helptags (capital H is significant!) then you can run :help fireplace
and :help paredit to get keybindings and other info.
Install Package Control. Open the console (ctrl+` ).
In Sublime Text 2, paste and run:
import urllib2,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')In Sublime Text 3, paste and run:
import urllib.request,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)Then press cmd+shift+p and run Package Control: Install Package and install SublimeREPL and paredit
Add the following to your user preferences (in menu Sublime Text > Preferences > Settings - User)
"auto_match_enabled": falseNote that that will disable quote and paren/bracket matching globally, but it's necessary for proper Clojure+Paredit usage. I don't know if there is a way to toggle that setting on a per-file or per-project basis.
You can find SublimeREPL docs here and paredit docs here