Emacs: CIDER
This is the one that started it all, and its Orchard ecosystem powers many of the other plug-ins.
-
Install Emacs for your platform.
-
Choose an existing emacs distribution (Prelude, Spacemacs and Doom Emacs are all great) or add this to your
init.el
:
(unless (package-installed-p 'cider)
(package-install 'cider))
(add-hook 'clojure-mode-hook #'cider-mode)
Summarized from the CIDER docs:
Start the nREPL server from the project directory:
$ bb --nrepl-server
Create or open any Clojure file (.clj
) with C-x C-f
and connect to it using C-c C-x c j
(cider-connect-clj).
cider-load-buffer
-C-c C-k
cider-eval-last-sexp
-C-x C-e
orC-c C-e
cider-eval-defun-at-point
-C-M-x
orC-c C-c
VSCode: Calva
Currently, Calva understands your source code to be in the context of a folder, i.e. a Clojure project. A nice way to create one is with clj-new:
$ clj -A:new lib myorg/bbtest
Generating a project called bbtest based on the 'lib' template.
The lib template is intended for library projects, not applications.
- Start the nREPL server from the project's directory:
$ cd bbtest
bbtest$ bb --nrepl-server 1667
Started nREPL server at localhost:1667
For more info visit https://github.com/borkdude/babashka/blob/master/doc/repl.md#nrepl.
Open the project folder in VSCode (Ctrl+K Ctrl+O) or from another terminal:
$ cd bbtest
bbtest$ code .
- In VSCode, run the Calva command
Connect to a running REPL
(ctrl+alt+c ctrl+alt+c). ChooseGeneric
project when prompted, and enterlocalhost:1667
.
REPL commands:
Load Current File and Dependencies
ctrl+alt+c enterEvaluate Current Form Inline
ctrl+alt+c eEvaluate Current Top Level Form (defun)
ctrl+alt+c space
IntelliJ: Cursive
- Download IntelliJ here.
- Install Cursive by following the user guide and configure deps.
- See Cursive: Working with Babashka for more info.
Atom: chlorine
-
Install atom
-
Install the
chlorine
package -
Start socket REPL:
$ bb --socket-repl 1666
Babashka socket REPL started at localhost:1666
-
Open Atom command palette (ctrl+shift+p) and execute command
Connect Clojure Socket REPL
withlocalhost
1666
-
Edit key bindings in keymap.cson via
Edit
menu ->Keymap...
:
'atom-text-editor[data-grammar="source clojure"]':
'ctrl-; y': 'chlorine:connect-clojure-socket-repl'
'ctrl-; e': 'chlorine:disconnect'
'ctrl-; k': 'chlorine:clear-console'
'ctrl-shift-enter': 'chlorine:load-file'
'ctrl-enter': 'chlorine:evaluate-block'
'shift-enter': 'chlorine:evaluate-top-block'
'ctrl-; i': 'chlorine:inspect-block'
'ctrl-; I': 'chlorine:inspect-top-block'
'ctrl-; s': 'chlorine:evaluate-selection'
'ctrl-; c': 'chlorine:break-evaluation'
'ctrl-; S': 'chlorine:source-for-var'
'ctrl-; d': 'chlorine:doc-for-var'
'ctrl-; x': 'chlorine:run-tests-in-ns'
'ctrl-; t': 'chlorine:run-test-for-var'
Emacs: inf-clojure
For Emacs, install inf-clojure by adding this to your init.el
:
(unless (package-installed-p 'inf-clojure)
(package-refresh-contents)
(package-install 'inf-clojure))
(add-hook 'clojure-mode-hook #'inf-clojure-minor-mode)
Start the socket REPL as above, and in emacs execute M-x inf-clojure-connect
(C-c M-c).
Evaluate forms with C-c C-e. For a list of all available commands in inf-clojure-mode (a.k.a. the REPL) and inf-clojure-minor-mode you can either invoke C-h f RET inf-clojure-mode and C-h f RET inf-clojure-minor-mode or simply browse their menus.
Vim: vim-iced
Download the Neovim appimage and alias it to vim
.
- Install vim-plug:
$ curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Create ~/.config/nvim/init.vim
:
call plug#begin('~/.vim/plugged')
Plug 'liuchengxu/vim-clap'
Plug 'guns/vim-sexp', {'for': 'clojure'}
Plug 'liquidz/vim-iced', {'for': 'clojure'}
call plug#end()
" Enable vim-iced's default key mapping
" This is recommended for newbies
let g:iced_enable_default_key_mappings = v:true
Open Neovim and run the command :PlugInstall
.
Add the iced
command to the $PATH:
$ export PATH=$PATH:~/.vim/plugged/vim-iced/bin
- Start the socket REPL server, open source file and execute
:IcedConnectSocketRepl 1666
.
Default REPL commands (default <Leader>
is \
):
<Leader>ei
: Evaluate inner element<Leader>ee
: Evaluate outer list<Leader>et
: Evaluate outer top list