2014-12-11 12:07:49 +00:00
|
|
|
# Clojure contribution layer for Spacemacs
|
|
|
|
|
2015-02-25 01:38:53 +00:00
|
|
|
![logo_clojure](img/clojure.png) ![logo_cider](img/cider.png)
|
2014-12-11 12:07:49 +00:00
|
|
|
|
2014-12-12 00:43:03 +00:00
|
|
|
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc/generate-toc again -->
|
|
|
|
**Table of Contents**
|
|
|
|
|
|
|
|
- [Clojure contribution layer for Spacemacs](#clojure-contribution-layer-for-spacemacs)
|
|
|
|
- [Description](#description)
|
2015-02-24 02:50:32 +00:00
|
|
|
- [Features](#features)
|
2014-12-12 00:43:03 +00:00
|
|
|
- [Install](#install)
|
2015-01-28 15:24:24 +00:00
|
|
|
- [Layer](#layer)
|
|
|
|
- [Pretty Symbols](#pretty-symbols)
|
2015-02-24 02:50:32 +00:00
|
|
|
- [Cider and clj-refactor](#cider-and-clj-refactor)
|
|
|
|
- [Quick Start with lein](#quick-start-with-lein)
|
|
|
|
- [More details](#more-details)
|
2014-12-12 00:43:03 +00:00
|
|
|
- [Key Bindings](#key-bindings)
|
|
|
|
- [Documentation](#documentation)
|
|
|
|
- [Evaluation](#evaluation)
|
|
|
|
- [Goto](#goto)
|
|
|
|
- [REPL](#repl)
|
|
|
|
- [Tests](#tests)
|
2015-02-24 02:50:32 +00:00
|
|
|
- [Refactoring](#refactoring)
|
2015-02-24 02:58:18 +00:00
|
|
|
- [Reformatting](#reformatting)
|
2014-12-11 12:07:49 +00:00
|
|
|
|
2014-12-12 00:43:03 +00:00
|
|
|
<!-- markdown-toc end -->
|
2014-12-11 12:07:49 +00:00
|
|
|
|
2014-12-12 00:43:03 +00:00
|
|
|
## Description
|
2014-12-11 12:07:49 +00:00
|
|
|
|
2014-12-12 00:50:04 +00:00
|
|
|
This layer adds support for [Clojure][] language using [Cider][].
|
2014-12-11 12:07:49 +00:00
|
|
|
|
2015-02-24 02:50:32 +00:00
|
|
|
## Features
|
2014-12-11 12:07:49 +00:00
|
|
|
|
2015-02-24 02:50:32 +00:00
|
|
|
- REPL via [cider][]
|
|
|
|
- Refactoring via [clj-refactor][]
|
|
|
|
- Auto completion via [ac-cider][]
|
|
|
|
- Automatic formatting via [align-cljlet][]
|
2014-12-11 12:07:49 +00:00
|
|
|
|
|
|
|
## Install
|
|
|
|
|
2015-01-28 15:24:24 +00:00
|
|
|
### Layer
|
|
|
|
|
2014-12-11 12:07:49 +00:00
|
|
|
To use this contribution add it to your `~/.spacemacs`
|
|
|
|
|
|
|
|
```elisp
|
2015-02-18 03:36:12 +00:00
|
|
|
(setq-default dotspacemacs-configuration-layers '(clojure))
|
2014-12-11 12:07:49 +00:00
|
|
|
```
|
|
|
|
|
2015-01-28 15:24:24 +00:00
|
|
|
### Pretty Symbols
|
|
|
|
|
2015-02-04 16:06:11 +00:00
|
|
|
Pretty symbols for anonymous functions, set literals and partial, like `(λ [a] (+ a 5))`, `ƒ(+ % 5)`, `∈{2 4 6}` and `Ƥ`.
|
2015-01-28 15:24:24 +00:00
|
|
|
|
|
|
|
To enable this feature, add the following snippet to the dotspacemacs/config
|
|
|
|
section of your `~/.spacemacs` file:
|
|
|
|
|
|
|
|
```elisp
|
|
|
|
(setq clojure-enable-fancify-symbols t)
|
|
|
|
```
|
|
|
|
|
|
|
|
Or set this variable when loading the configuration layer:
|
|
|
|
```elisp
|
2015-02-18 03:36:12 +00:00
|
|
|
(setq-default dotspacemacs-configuration-layers
|
|
|
|
'((clojure :variables clojure-enable-fancify-symbols t)))
|
2015-01-28 15:24:24 +00:00
|
|
|
```
|
|
|
|
|
2015-02-24 02:50:32 +00:00
|
|
|
### Cider and clj-refactor
|
2014-12-12 00:43:03 +00:00
|
|
|
|
2015-02-24 02:50:32 +00:00
|
|
|
#### Quick Start with lein
|
|
|
|
|
|
|
|
- Install `lein` via your OS package manager.
|
|
|
|
- Create a file `~/.lein/profiles.clj` with the following content:
|
|
|
|
|
|
|
|
```clj
|
|
|
|
{:user {:plugins [[cider/cider-nrepl "0.9.0-SNAPSHOT"]
|
|
|
|
[refactor-nrepl "0.3.0-SNAPSHOT"]]}}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### More details
|
|
|
|
|
|
|
|
More info regarding installation of nREPL middleware can be found here:
|
|
|
|
- cider: [cider repo][cider_install]
|
|
|
|
- clj-refactor: [refactor-nrepl][]
|
2014-12-11 12:07:49 +00:00
|
|
|
|
|
|
|
## Key Bindings
|
|
|
|
|
2014-12-12 00:43:03 +00:00
|
|
|
### Documentation
|
2014-12-11 12:07:49 +00:00
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
2014-12-15 19:21:08 +00:00
|
|
|
<kbd>SPC m d d</kbd> | cider doc
|
|
|
|
<kbd>SPC m d g</kbd> | cider grimoire
|
2014-12-11 12:07:49 +00:00
|
|
|
<kbd>SPC m d j</kbd> | cider javadoc
|
2014-12-12 00:43:03 +00:00
|
|
|
|
|
|
|
### Evaluation
|
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
2014-12-11 12:07:49 +00:00
|
|
|
<kbd>SPC m e b</kbd> | eval buffer
|
2015-02-24 02:05:15 +00:00
|
|
|
<kbd>SPC m e e</kbd> | eval last sexp
|
2014-12-11 12:07:49 +00:00
|
|
|
<kbd>SPC m e r</kbd> | eval region
|
2014-12-12 00:43:03 +00:00
|
|
|
|
|
|
|
### Goto
|
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
2015-02-18 16:13:05 +00:00
|
|
|
<kbd>SPC m g g</kbd> | goto var
|
2014-12-11 12:07:49 +00:00
|
|
|
<kbd>SPC m g e</kbd> | goto error
|
2015-02-18 16:13:05 +00:00
|
|
|
<kbd>SPC m g r</kbd> | goto resource
|
|
|
|
<kbd>SPC m g b</kbd> | go back
|
2014-12-12 00:43:03 +00:00
|
|
|
|
|
|
|
### REPL
|
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
2015-02-20 03:50:34 +00:00
|
|
|
<kbd>SPC m s b</kbd> | send and eval buffer in REPL
|
|
|
|
<kbd>SPC m s B</kbd> | send and eval buffer and switch to REPL in `insert state`
|
|
|
|
<kbd>SPC m s e</kbd> | send and eval last sexp in REPL
|
|
|
|
<kbd>SPC m s E</kbd> | send and eval last sexp and switch to REPL in `insert state`
|
|
|
|
<kbd>SPC m s f</kbd> | send and eval function in REPL
|
|
|
|
<kbd>SPC m s F</kbd> | send and eval function and switch to REPL in `insert state`
|
|
|
|
<kbd>SPC m s i</kbd> | start REPL
|
|
|
|
<kbd>SPC m s n</kbd> | send and eval ns form in REPL
|
|
|
|
<kbd>SPC m s N</kbd> | send and eval ns form and switch to REPL in `insert state`
|
2015-02-24 03:09:39 +00:00
|
|
|
<kbd>SPC m s r</kbd> | send and eval region in REPL
|
|
|
|
<kbd>SPC m s R</kbd> | send and eval region and switch to REPL in `insert state`
|
2015-02-20 03:50:34 +00:00
|
|
|
<kbd>SPC m s s</kbd> | switch to REPL
|
2014-12-12 00:43:03 +00:00
|
|
|
|
|
|
|
### Tests
|
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
2014-12-11 12:07:49 +00:00
|
|
|
<kbd>SPC m t t</kbd> | run tests
|
2014-12-12 00:43:03 +00:00
|
|
|
|
2015-02-20 03:50:34 +00:00
|
|
|
### Refactoring
|
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
------------------------|------------------------------------------------------------
|
|
|
|
<kbd>SPC m r a d</kbd> | add declaration
|
|
|
|
<kbd>SPC m r a i</kbd> | add import to ns
|
|
|
|
<kbd>SPC m r a m</kbd> | add missing libspec
|
|
|
|
<kbd>SPC m r a p</kbd> | add project dependency
|
|
|
|
<kbd>SPC m r a r</kbd> | add require to ns
|
|
|
|
<kbd>SPC m r a u</kbd> | add use to ns
|
|
|
|
<kbd>SPC m r c c</kbd> | cycle coll
|
|
|
|
<kbd>SPC m r c i</kbd> | cycle if
|
|
|
|
<kbd>SPC m r c n</kbd> | clean ns
|
|
|
|
<kbd>SPC m r c p</kbd> | cycle privacy
|
|
|
|
<kbd>SPC m r d k</kbd> | destructure keys
|
|
|
|
<kbd>SPC m r e f</kbd> | extract function
|
|
|
|
<kbd>SPC m r e l</kbd> | expand let
|
|
|
|
<kbd>SPC m r f u</kbd> | find usages
|
|
|
|
<kbd>SPC m r h d</kbd> | hotload dependency
|
|
|
|
<kbd>SPC m r i l</kbd> | introduce let
|
|
|
|
<kbd>SPC m r m f</kbd> | move form
|
|
|
|
<kbd>SPC m r m l</kbd> | move to let
|
|
|
|
<kbd>SPC m r p c</kbd> | project clean
|
|
|
|
<kbd>SPC m r p f</kbd> | promote function
|
|
|
|
<kbd>SPC m r r d</kbd> | remove debug fns
|
|
|
|
<kbd>SPC m r r f</kbd> | rename file
|
|
|
|
<kbd>SPC m r r l</kbd> | remove let
|
|
|
|
<kbd>SPC m r r r</kbd> | remove unused requires
|
|
|
|
<kbd>SPC m r r s</kbd> | rename symbol
|
|
|
|
<kbd>SPC m r r u</kbd> | replace use
|
|
|
|
<kbd>SPC m r s n</kbd> | sort ns
|
|
|
|
<kbd>SPC m r s p</kbd> | sort project dependencies
|
|
|
|
<kbd>SPC m r s r</kbd> | stop referring
|
|
|
|
<kbd>SPC m r t f</kbd> | thread first all
|
|
|
|
<kbd>SPC m r t h</kbd> | thread
|
|
|
|
<kbd>SPC m r t l</kbd> | thread last all
|
|
|
|
<kbd>SPC m r u a</kbd> | unwind all
|
|
|
|
<kbd>SPC m r u w</kbd> | unwind
|
|
|
|
|
2015-02-24 02:58:18 +00:00
|
|
|
### Reformatting
|
|
|
|
|
|
|
|
Forms currently handled:
|
|
|
|
- let
|
|
|
|
- when-let
|
|
|
|
- if-let
|
|
|
|
- binding
|
|
|
|
- loop
|
|
|
|
- with-open
|
|
|
|
- literal hashes {}
|
|
|
|
- defroute
|
|
|
|
- cond
|
|
|
|
- condp (except :>> subforms)
|
|
|
|
|
|
|
|
More info [here][align-cljlet].
|
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
------------------------|------------------------------------------------------------
|
2015-02-24 03:18:48 +00:00
|
|
|
<kbd>SPC m f l</kbd> | reformat current form
|
2015-02-24 02:58:18 +00:00
|
|
|
|
2014-12-12 00:43:03 +00:00
|
|
|
[Clojure]: http://clojure.org
|
|
|
|
[Cider]: https://github.com/clojure-emacs/cider
|
2014-12-15 19:22:33 +00:00
|
|
|
[cider_install]: https://github.com/clojure-emacs/cider#installation
|
2014-12-12 00:50:04 +00:00
|
|
|
[clojure-mode]: https://github.com/clojure-emacs/clojure-mode
|
2015-02-24 02:50:32 +00:00
|
|
|
[clj-refactor]: https://github.com/clojure-emacs/clj-refactor.el
|
2015-02-24 07:26:24 +00:00
|
|
|
[ac-cider]: https://github.com/clojure-emacs/ac-cider
|
2014-12-15 19:22:33 +00:00
|
|
|
[align-cljlet]: https://github.com/gstamp/align-cljlet
|
2015-02-24 02:50:32 +00:00
|
|
|
[refactor-nrepl]: https://github.com/clojure-emacs/refactor-nrepl
|