-
Notifications
You must be signed in to change notification settings - Fork 111
Home
-
ad
: add declaration for current top-level form -
ai
: add import to namespace declaration, then jump back -
am
*: add a missing libspec -
ap
*: add a dependency to yourproject.clj
and hotload into the repl. -
ar
: add require to namespace declaration, then jump back (see optional setup) -
as
*: Add stub(s) for the interface at point -
au
: add "use" to namespace declaration, then jump back -
cc
***:cycle surrounding collection type - convert to collection type
-
ci
**: cycle betweenif
andif-not
-
cn
*: Clean namespace form -
cp
**: cycle privacy ofdefn
s anddef
s -
dk
: destructure keys -
ec
: extract constant -
ed
: extract def -
ef
*: extract function -
el
: expand let -
fe
: create function from example stub -
fu
*: find usages -
hd
*: hotload dependency -
il
: introduce let -
is
*: inline symbol -
mf
: move one or more forms to another namespace,:refer
any functions -
ml
: move to let -
pc
: run project clean functions on the whole project -
pf
*: promote function literal to fn, or fn to defn -
rf
*: rename file or dir updating any affected files -
rl
*: remove let, inline all variables and remove the let form -
rs
*: rename symbol -
sc
: show the changelog, to learn about recent changes -
sp
: sort project dependencies found inproject.clj
-
sr
: stop referring (removes:refer [...]
from current require, fixing references) -
tf
**: wrap in thread-first (->) and fully thread -
th
**: thread another expression -
tl
**: wrap in thread-last (->>) and fully thread -
ua
**: fully unwind a threaded expression -
up
: update project dependencies (lein only) -
uw
**: unwind a threaded expression -
?
: describe refactoring -
hh
: parent menu for hydra menus -
hn
: hydra menu namespace related refactorings -
hc
: hydra menu for code refactorings -
hp
: hydra menu for project related refactorings -
ht
: hydra menu for top level form refactorings -
hs
: hydra menu for features related to clj-refactor itself
*: These functions require an active repl connection and our middleware.
**: These functions got moved to Clojure mode but aliased here with the usual memnonics.
***: These functions got removed as an improved version was added to Clojure mode.
A cheatsheat is available here (pdf version).
These functions are available, but used so rarely they're not given a keybinding default:
-
cljr-reify-to-defrecord
* replace a call to reify with a call to a defrecord constructor. -
cljr-version
Display version information for clj-refactor and the refactor-nrepl middleware. -
cljr-toggle-debug-mode
When something isn't working as intended debug mode can be toggled to get some more information about what's going on.
To take a look at the available settings do: M-x customize-group <RET> cljr <RET>
Common namespace shorthands are automatically required when you type them:
For instance, typing (io/)
adds [clojure.java.io :as io]
to the requires.
-
io
isclojure.java.io
-
set
isclojure.set
-
str
isclojure.string
-
walk
isclojure.walk
-
zip
isclojure.zip
The namespaces in cljr-magic-require-namespaces
act like seed values, but once you start writing your own aliases those will be used as candidates in addition to the seed values. Note that since the result of looking up an alias in the project itself is considered to be more current, cljr-magic-require-namespaces
is never consulted if the alias lookup in the project provides a hit.
You can turn this off with:
(setq cljr-magic-requires nil)
or set it to :prompt
if you want to confirm before it inserts.
(after #532 is merged)
Optionally, recommendations for magic libspec requires from an alias can be guided by language context of the file or the current reader conditional language using the new suggest-libspec
middleware op.
This can be enabled with
(setq cljr-slash-uses-suggest-libspec t)
Enabling this feature will ensure cljr-slash
will prompt at most once to add a require. Without this feature, using cljr-slash
in a cljc file will prompt first for the language context and then again for which libspec to add to the namespace.
When you open a blank .clj
-file, clj-refactor inserts the namespace declaration for you.
It will also add the relevant :use
clauses in test files, normally using clojure.test
, but if you're depending on midje or expectations in your project.clj
it uses that instead.
Prefer to insert your own ns-declarations? Then:
(setq cljr-add-ns-to-blank-clj-files nil)
With clj-refactor enabled, any keybindings for paredit-raise-sexp
is
replaced by cljr-raise-sexp
which does the same thing - except it
also removes any #
in front of function literals and sets.
You might also like
- cljr-helm Helm wrapper for cljr.
- Max Penet maintains clojure-snippets.
- Magnar Sveen made some datomic-snippets.
- Discover CLJ Refactor